-
Notifications
You must be signed in to change notification settings - Fork 92
/
build.gradle
136 lines (116 loc) · 4.76 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import java.util.regex.Pattern
plugins {
id 'java-library'
id 'maven-publish'
id 'com.diffplug.gradle.spotless' version '4.0.1'
id 'nu.studer.credentials' version '2.1' apply false
id 'com.jfrog.bintray' version '1.8.5' apply false
id 'org.asciidoctor.convert' version '1.5.7' apply false
}
ext {
projectVersionFile = file( "${rootProject.projectDir}/gradle/version.properties" )
projectVersion = Version.parseProjectVersion( readVersionFromProperties( projectVersionFile ) )
if ( project.hasProperty('releaseVersion') ) {
releaseVersion = Version.parseReleaseVersion( project.releaseVersion )
}
if ( project.hasProperty('developmentVersion') ) {
developmentVersion = Version.parseDevelopmentVersion( project.developmentVersion )
}
}
// Versions which need to be aligned across modules; this also
// allows overriding the build using a parameter, which can be
// useful to monitor compatibility for upcoming versions on CI:
//
// ./gradlew clean build -PhibernateOrmVersion=5.4.9-SNAPSHOT
ext {
if ( !project.hasProperty('hibernateOrmVersion') ) {
hibernateOrmVersion = '5.4.20.Final'
}
// For ORM, we need a parsed version (to get the family, ...)
hibernateOrmVersion = Version.parseProjectVersion( project.hibernateOrmVersion )
vertxVersion = '3.9.2'
testcontainersVersion = '1.14.3'
baselineJavaVersion = 1.8
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'com.diffplug.gradle.spotless'
group = 'org.hibernate.reactive'
version = projectVersion
sourceCompatibility = project.baselineJavaVersion
targetCompatibility = project.baselineJavaVersion
compileJava.options.encoding = 'UTF-8'
repositories {
// Only enable these for local development, never push it:
// mavenLocal()
// jcenter()
// maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
ext.publishScript = rootProject.rootDir.absolutePath + '/publish.gradle'
}
private static String readVersionFromProperties(File file) {
if ( !file.exists() ) {
throw new GradleException( "Version file $file.canonicalPath does not exists" )
}
Properties versionProperties = new Properties()
file.withInputStream {
stream -> versionProperties.load( stream )
}
return versionProperties.projectVersion
}
class Version {
private static final Pattern RELEASE_VERSION_PATTERN = ~/^(\d+)\.(\d+)\.(\d+)\.((?<=\.0\.)(?:Alpha\d+|Beta\d+|CR\d+)|Final)$/
private static final Pattern DEVELOPMENT_VERSION_PATTERN = ~/^(\d+)\.(\d+)\.(\d+)-SNAPSHOT$/
static Version parseReleaseVersion(String versionString) {
def matcher = (versionString =~ RELEASE_VERSION_PATTERN)
if ( !matcher.matches() ) {
throw new IllegalArgumentException(
"Invalid version number: '$versionString'." +
" Release version numbers must match /$RELEASE_VERSION_PATTERN/."
)
}
return new Version( matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(4), false )
}
static Version parseDevelopmentVersion(String versionString) {
def matcher = (versionString =~ DEVELOPMENT_VERSION_PATTERN)
if ( !matcher.matches() ) {
throw new IllegalArgumentException(
"Invalid version number: '$versionString'." +
" Development version numbers must match /$DEVELOPMENT_VERSION_PATTERN/."
)
}
return new Version( matcher.group(1), matcher.group(2), matcher.group(3), null, true )
}
static Version parseProjectVersion(String versionString) {
if ( (versionString =~ RELEASE_VERSION_PATTERN).matches() ) {
return parseReleaseVersion( versionString )
}
if ( (versionString =~ DEVELOPMENT_VERSION_PATTERN).matches() ) {
return parseDevelopmentVersion( versionString )
}
throw new IllegalArgumentException(
"Invalid version number: '$versionString'." +
" Project version numbers must match either /$RELEASE_VERSION_PATTERN/ or /$DEVELOPMENT_VERSION_PATTERN/."
)
}
final String major
final String minor
final String micro
final String qualifier
final boolean snapshot
Version(String major, String minor, String micro, String qualifier, boolean snapshot) {
this.major = major
this.minor = minor
this.micro = micro
this.qualifier = qualifier
this.snapshot = snapshot
}
@Override
String toString() {
[major, minor, micro, qualifier].findAll({ it != null }).join('.') + (snapshot ? '-SNAPSHOT' : '')
}
String getFamily() {
"$major.$minor"
}
}