1
- import java.util.regex.Pattern
2
-
3
1
plugins {
2
+ id " local.versions"
3
+
4
4
id ' java-library'
5
5
id ' maven-publish'
6
6
id ' com.diffplug.spotless' version ' 6.25.0'
7
7
id ' org.asciidoctor.jvm.convert' version ' 4.0.2' apply false
8
8
id ' io.github.gradle-nexus.publish-plugin' version ' 1.3.0'
9
9
}
10
10
11
+ group = " org.hibernate.reactive"
12
+ // leverage the ProjectVersion which comes from the `local.versions` plugin
13
+ version = project. projectVersion. fullName
14
+
11
15
ext {
12
16
if ( ! project. hasProperty( ' sonatypeOssrhUser' ) ) {
13
17
sonatypeOssrhUser = null
@@ -17,57 +21,12 @@ ext {
17
21
}
18
22
}
19
23
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
-
38
24
// Versions which need to be aligned across modules; this also
39
25
// allows overriding the build using a parameter, which can be
40
26
// useful to monitor compatibility for upcoming versions on CI:
41
27
//
42
28
// ./gradlew clean build -PhibernateOrmVersion=5.6.15-SNAPSHOT
43
29
ext {
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
-
71
30
// Mainly, to allow CI to test the latest versions of Vert.X
72
31
// Example:
73
32
// ./gradlew build -PvertxSqlClientVersion=4.0.0-SNAPSHOT
77
36
78
37
testcontainersVersion = ' 1.19.8'
79
38
80
- logger. lifecycle " Hibernate ORM Version: " + project. hibernateOrmVersion
81
- logger. lifecycle " Hibernate ORM Gradle plugin Version: " + project. hibernateOrmGradlePluginVersion
82
39
logger. lifecycle " Vert.x SQL Client Version: " + project. vertxSqlClientVersion
83
- logger. lifecycle " Hibernate Reactive: " + project. version
84
40
}
85
41
86
42
// To release, see task ciRelease in release/build.gradle
@@ -99,9 +55,8 @@ subprojects {
99
55
apply plugin : ' java-library'
100
56
apply plugin : ' com.diffplug.spotless'
101
57
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
105
60
106
61
spotless {
107
62
// Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
@@ -201,79 +156,3 @@ subprojects {
201
156
}
202
157
}
203
158
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