forked from hibernate/hibernate-orm
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
362 lines (288 loc) · 11.7 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
name 'jboss-snapshots'
url 'https://repository.jboss.org/nexus/content/repositories/snapshots/'
}
// Location of org.codehaus.groovy.modules.http-builder:http-builder:0.7.2
maven {
name "cern"
url "https://nexus.web.cern.ch/nexus/content/repositories/public"
}
mavenLocal()
}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:2.0.0.Final'
classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0'
classpath 'org.hibernate.build.gradle:gradle-xjc-plugin:1.0.2.Final'
classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.1.1'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.3'
classpath 'de.thetaphi:forbiddenapis:2.5'
// Force a leter version of this JAR, 1.0.2 no longer available
classpath 'nu.studer:java-ordered-properties:1.0.4'
}
}
plugins {
id 'me.champeau.buildscan-recipes' version '0.2.3'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'nu.studer.credentials' version '2.1'
id 'org.hibernate.build.xjc' version '2.0.1' apply false
id 'org.hibernate.build.maven-repo-auth' version '3.0.3' apply false
id 'biz.aQute.bnd' version '5.1.1' apply false
}
ext {
sonatypeOssrhUser = project.findProperty( 'SONATYPE_OSSRH_USER' )
sonatypeOssrhPassword = project.findProperty( 'SONATYPE_OSSRH_PASSWORD' )
}
File versionFile = file( "${rootProject.projectDir}/gradle/version.properties" )
ext {
ormVersionFile = versionFile
ormVersion = HibernateVersion.fromFile( versionFile, project )
// Override during releases
if ( project.hasProperty( 'releaseVersion' ) ) {
ormVersion = new HibernateVersion( project.releaseVersion, project )
}
jpaVersion = new JpaVersion('2.2')
jakartaJpaVersion = new JpaVersion('3.0.0')
nuodbHibernateVersion = new NuodbHibernateVersion();
nuodbHibernateJarVersion = System.env['DIALECT_VERSION'] ?: nuodbHibernateVersion.latestVersion;
}
if (!nuodbHibernateJarVersion.endsWith('-hib5'))
nuodbHibernateJarVersion += '-hib5';
println " Expecting to use NuoDB Hibernate JAR nuodb-hibernate-${nuodbHibernateJarVersion}.jar"
// The Gradle Nexus Publish Plugin must be applied to the root project and requires group and version
group = 'org.hibernate'
version = project.ormVersion.fullName
nexusPublishing {
repositories {
sonatype {
username = project.sonatypeOssrhUser
password = project.sonatypeOssrhPassword
}
}
}
//plugins {
// id 'com.gradle.build-scan' version '1.16'
// id 'me.champeau.buildscan-recipes' version '0.2.3'
//}
allprojects {
repositories {
//ext.nuodbHibernateJarVersion = System.env['DIALECT_VERSION'] ?: nuodbHibernateVersion.latestVersion;
// Set SONATYPE_VERSION to pull our Jar from there
if (System.env['SONATYPE_VERSION'] != null) {
println "hibernate-orm: Using https://oss.sonatype.org/content/repositories/comnuodb-${System.env.SONATYPE_VERSION}/com/nuodb/hibernate/nuodb-hibernate/${nuodbHibernateJarVersion}-hib5/"
ivy {
url "https://oss.sonatype.org/content/repositories/comnuodb-${System.env.SONATYPE_VERSION}/"
layout 'pattern', {
artifact '/com/nuodb/hibernate/nuodb-hibernate/${nuodbHibernateJarVersion}-hib5/nuodb-hibernate-${nuodbHibernateJarVersion}-hib5.[ext]'
}
}
}
mavenCentral()
maven {
name "jboss-snapshots"
url "https://repository.jboss.org/nexus/content/repositories/snapshots/"
}
maven {
name "mvnrepository"
url "https://mvnrepository.com/artifact"
}
//Allow loading additional dependencies from a local path;
//useful to load JDBC drivers which can not be distributed in public.
if (System.env['ADDITIONAL_REPO'] != null) {
flatDir {
dirs "${System.env.ADDITIONAL_REPO}"
}
}
// NuoDB: Default to adding our dialect explicitly
else {
flatDir {
String mvnHome = "${System.properties.get('user.home').replace('\\', '/')}/.m2/repository";
//println "Using default repository: ${mvnHome}"
dirs "${mvnHome}/com/nuodb/hibernate/nuodb-hibernate/${nuodbHibernateJarVersion}"
}
}
}
apply plugin: 'idea'
// minimize changes, at least for now (gradle uses 'build' by default)..
buildDir = "target"
group = 'org.hibernate'
version = project.ormVersion.fullName
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Release Task
task release {
description = "The task performed when we are performing a release build. Relies on " +
"the fact that subprojects will appropriately define a release task " +
"themselves if they have any release-related activities to perform"
doFirst {
def javaVersionsInUse = [gradle.ext.javaVersions.main.compiler, gradle.ext.javaVersions.main.release,
gradle.ext.javaVersions.test.compiler, gradle.ext.javaVersions.test.release,
gradle.ext.javaVersions.test.launcher].toSet()
// Force to release with JDK 8. It used to not work on JDK11 because of the hibernate-orm-modules module,
// but this limitation might be resolved now that this module has been deleted?
if ( javaVersionsInUse != [JavaLanguageVersion.of( 8 )].toSet() ) {
throw new IllegalStateException( "Please use JDK 8 to perform the release. Currently using: ${javaVersionsInUse}" )
}
}
}
task publish {
description = "The task performed when we want to just publish maven artifacts. Relies on " +
"the fact that subprojects will appropriately define a release task " +
"themselves if they have any release-related activities to perform"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CI Build Task
task ciBuild {
description = "The task performed when one of the 'main' jobs are triggered on the " +
"CI server. Just as above, relies on the fact that subprojects will " +
"appropriately define a release task themselves if they have any tasks " +
"which should be performed from these CI jobs"
}
wrapper {
// To upgrade the version of gradle used in the wrapper, run:
// ./gradlew wrapper --gradle-version NEW_VERSION
distributionType = Wrapper.DistributionType.ALL
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
buildScanRecipes {
recipe 'git-commit', baseUrl: 'https://github.com/hibernate/hibernate-orm/tree'
}
class JpaVersion {
/** The *normal* name (1.0, 2.0, ..) */
final String name;
final String osgiName
JpaVersion(String version){
this.name = version
this.osgiName = version + ".0"
}
@Override
String toString() {
return name
}
}
class HibernateVersion {
final String fullName
final String majorVersion
final String family
final String osgiVersion
final boolean isSnapshot
HibernateVersion(String fullName, Project project) {
this.fullName = fullName
final String[] hibernateVersionComponents = fullName.split( '\\.' )
this.majorVersion = hibernateVersionComponents[0]
this.family = hibernateVersionComponents[0] + '.' + hibernateVersionComponents[1]
this.isSnapshot = fullName.endsWith( '-SNAPSHOT' )
this.osgiVersion = isSnapshot ? family + '.' + hibernateVersionComponents[2] + '.SNAPSHOT' : fullName
}
static HibernateVersion fromFile(File file, Project project){
def fullName = readVersionProperties(file)
return new HibernateVersion(fullName, project)
}
private static String readVersionProperties(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.hibernateVersion
}
@Override
String toString() {
return this.fullName
}
}
public class NuodbHibernateVersion {
public static final String unknownVersion = 'UNKNOWN';
public final String latestVersion
public NuodbHibernateVersion() {
latestVersion = getLatestVersion();
println "Latest NuoDB Hibernate dialect found in ~/.m2 is ${latestVersion}"
if (System.env['DIALECT_VERSION'] == null) {
println("DIALECT_VERSION environment variable should be set to 20.0.0 or later")
if (isUnknown()) {
println()
println(">> ERROR: Unknown Dialect JAR version, unable to continue")
println()
System.exit(-1)
}
println(" Defaulting to latest version in .m2 repo: ${latestVersion}")
}
else {
latestVersion = System.env['DIALECT_VERSION'];
println(" Using DIALECT_VERSION=${latestVersion}")
}
}
public boolean isUnknown() {
return latestVersion.equals(unknownVersion);
}
private String getLatestVersion() {
String splitAtPeriod = '\\.';
String NO_VALUE = '0.0.0';
File mavenHibDir = new File(System.getProperty('user.home'), '.m2/repository/com/nuodb/hibernate/nuodb-hibernate');
String latest = NO_VALUE;
String[] lbits = latest.split(splitAtPeriod);
if (!mavenHibDir.exists())
return unknownVersion;
for(File f : mavenHibDir.listFiles()) {
String dirName = f.name;
String originalDirName = dirName;
//println("dirName = ${dirName}");
if (dirName.startsWith('.') || dirName.startsWith('3.') ||
!dirName.endsWith('-hib5') || !Character.isDigit(dirName.charAt(0)))
continue;
int ix = dirName.indexOf('-');
if (ix != -1)
dirName = dirName.substring(0, ix);
String[] m = dirName.split(splitAtPeriod);
boolean later = false;
//println(" latest = ${Arrays.asList(lbits)}");
//println(" dirName = ${Arrays.asList(m)}");
// Version must be X.Y.Z, 3 components. Otherwise it is a dud.
if (m.length < 3) {
println("WARNING: Corrupt directory name $originalDirName");
continue;
}
if (m[0] > lbits[0])
later = true;
else if (m[0] == lbits[0]) {
if (m[1] > lbits[1])
later = true;
else if (m[1] == lbits[1] && m[2] > lbits[2])
later = true;
}
if (later) {
//println(" Change to ${dirName}")
latest = dirName;
lbits = latest.split(splitAtPeriod);
}
}
return latest.equals(NO_VALUE) ? unknownVersion : latest;
}
}
//idea {
// project {
// jdkName = gradle.ext.baselineJavaVersion
// languageLevel = gradle.ext.baselineJavaVersion
//
// vcs = 'Git'
// }
// module {
// name = "hibernate-orm"
// }
//}