1- import java.util.regex.Pattern
2-
31plugins {
2+ id " local.versions"
3+
44 id ' java-library'
55 id ' maven-publish'
66 id ' com.diffplug.spotless' version ' 6.25.0'
77 id ' org.asciidoctor.jvm.convert' version ' 4.0.2' apply false
88 id ' io.github.gradle-nexus.publish-plugin' version ' 1.3.0'
99}
1010
11+ group = " org.hibernate.reactive"
12+ // leverage the ProjectVersion which comes from the `local.versions` plugin
13+ version = project. projectVersion. fullName
14+
1115ext {
1216 if ( ! project. hasProperty( ' sonatypeOssrhUser' ) ) {
1317 sonatypeOssrhUser = null
@@ -17,57 +21,12 @@ ext {
1721 }
1822}
1923
20- ext {
21- projectGroup = ' org.hibernate.reactive'
22- projectVersionFile = file( " ${ rootProject.projectDir} /gradle/version.properties" )
23- projectVersion = Version . parseProjectVersion( readVersionFromProperties( projectVersionFile ) )
24-
25- if ( project. hasProperty(' releaseVersion' ) ) {
26- releaseVersion = Version . parseReleaseVersion( project. releaseVersion )
27- }
28- if ( project. hasProperty(' developmentVersion' ) ) {
29- developmentVersion = Version . parseDevelopmentVersion( project. developmentVersion )
30- }
31- }
32-
33- // nexusPublishing uses group and version
34- // as defaults
35- group = projectGroup
36- version = projectVersion
37-
3824// Versions which need to be aligned across modules; this also
3925// allows overriding the build using a parameter, which can be
4026// useful to monitor compatibility for upcoming versions on CI:
4127//
4228// ./gradlew clean build -PhibernateOrmVersion=5.6.15-SNAPSHOT
4329ext {
44- if ( ! project. hasProperty(' hibernateOrmVersion' ) ) {
45- hibernateOrmVersion = ' 6.6.0.Final'
46- }
47- if ( ! project. hasProperty( ' hibernateOrmGradlePluginVersion' ) ) {
48- // Same as ORM as default
49- hibernateOrmGradlePluginVersion = project. hibernateOrmVersion
50- }
51- // For ORM, we need a parsed version (to get the family, ...)
52-
53- // For ORM, we need a parsed version (to get the family for the documentation during release).
54- // We use intervals to build with the latest ORM snapshot and this will fail version check.
55- // Because we don't need to publish or release anything we can disable the check in this case.
56- // Example:
57- // ./gradlew build -PhibernateOrmVersion='[5.4,5.5)' -PskipOrmVersionParsing
58- if ( project. hasProperty( ' skipOrmVersionParsing' ) ) {
59- // Default to true if the property is null
60- skipOrmVersionParsing = project. skipOrmVersionParsing ?: true
61- }
62- else {
63- skipOrmVersionParsing = false
64- }
65-
66- if ( ! Boolean . valueOf( project. skipOrmVersionParsing ) ) {
67- logger. lifecycle " Parsing ORM version"
68- hibernateOrmVersion = Version . parseProjectVersion( project. hibernateOrmVersion )
69- }
70-
7130 // Mainly, to allow CI to test the latest versions of Vert.X
7231 // Example:
7332 // ./gradlew build -PvertxSqlClientVersion=4.0.0-SNAPSHOT
7736
7837 testcontainersVersion = ' 1.19.8'
7938
80- logger. lifecycle " Hibernate ORM Version: " + project. hibernateOrmVersion
81- logger. lifecycle " Hibernate ORM Gradle plugin Version: " + project. hibernateOrmGradlePluginVersion
8239 logger. lifecycle " Vert.x SQL Client Version: " + project. vertxSqlClientVersion
83- logger. lifecycle " Hibernate Reactive: " + project. version
8440}
8541
8642// To release, see task ciRelease in release/build.gradle
@@ -99,9 +55,8 @@ subprojects {
9955 apply plugin : ' java-library'
10056 apply plugin : ' com.diffplug.spotless'
10157
102- // FIXME: Also setting the group and version here otherwise not all tasks will find them
103- group = projectGroup
104- version = projectVersion
58+ group = rootProject. group
59+ version = rootProject. version
10560
10661 spotless {
10762 // Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
@@ -201,79 +156,3 @@ subprojects {
201156 }
202157}
203158
204- private static String readVersionFromProperties (File file ) {
205- if ( ! file. exists() ) {
206- throw new FileNotFoundException ( " Version file $file . canonicalPath does not exists" )
207- }
208- Properties versionProperties = new Properties ()
209- file. withInputStream {
210- stream -> versionProperties. load( stream )
211- }
212- return versionProperties. projectVersion
213- }
214-
215- class Version {
216-
217- private static final Pattern RELEASE_VERSION_PATTERN = ~/ ^(\d +)\. (\d +)\. (\d +)\. ((?:Alpha\d +|Beta\d +|CR\d +)|Final)$/
218-
219- private static final Pattern DEVELOPMENT_VERSION_PATTERN = ~/ ^(\d +)\. (\d +)\. (\d +)-SNAPSHOT$/
220-
221- static Version parseReleaseVersion (String versionString ) {
222- def matcher = (versionString =~ RELEASE_VERSION_PATTERN )
223- if ( ! matcher. matches() ) {
224- throw new IllegalArgumentException (
225- " Invalid version number: '$versionString '." +
226- " Release version numbers must match /$RELEASE_VERSION_PATTERN /."
227- )
228- }
229- return new Version ( matcher. group(1 ), matcher. group(2 ), matcher. group(3 ), matcher. group(4 ), false )
230- }
231-
232- static Version parseDevelopmentVersion (String versionString ) {
233- def matcher = (versionString =~ DEVELOPMENT_VERSION_PATTERN )
234- if ( ! matcher. matches() ) {
235- throw new IllegalArgumentException (
236- " Invalid version number: '$versionString '." +
237- " Development version numbers must match /$DEVELOPMENT_VERSION_PATTERN /."
238- )
239- }
240-
241- return new Version ( matcher. group(1 ), matcher. group(2 ), matcher. group(3 ), null , true )
242- }
243-
244- static Version parseProjectVersion (String versionString ) {
245- if ( (versionString =~ RELEASE_VERSION_PATTERN ). matches() ) {
246- return parseReleaseVersion( versionString )
247- }
248- if ( (versionString =~ DEVELOPMENT_VERSION_PATTERN ). matches() ) {
249- return parseDevelopmentVersion( versionString )
250- }
251- throw new IllegalArgumentException (
252- " Invalid version number: '$versionString '." +
253- " Project version numbers must match either /$RELEASE_VERSION_PATTERN / or /$DEVELOPMENT_VERSION_PATTERN /."
254- )
255- }
256-
257- final String major
258- final String minor
259- final String micro
260- final String qualifier
261- final boolean snapshot
262-
263- Version (String major , String minor , String micro , String qualifier , boolean snapshot ) {
264- this . major = major
265- this . minor = minor
266- this . micro = micro
267- this . qualifier = qualifier
268- this . snapshot = snapshot
269- }
270-
271- @Override
272- String toString () {
273- [major, minor, micro, qualifier]. findAll({ it != null }). join(' .' ) + (snapshot ? ' -SNAPSHOT' : ' ' )
274- }
275-
276- String getFamily () {
277- " $major . $minor "
278- }
279- }
0 commit comments