forked from hibernate/hibernate-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
450 lines (376 loc) · 14 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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
import org.apache.tools.ant.filters.ReplaceTokens
/*
* 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 {
mavenCentral()
mavenLocal()
jcenter()
maven {
name 'jboss-nexus'
url "http://repository.jboss.org/nexus/content/groups/public/"
}
maven {
name "jboss-snapshots"
url "http://snapshots.jboss.org/maven2/"
}
}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:2.0.0-SNAPSHOT'
classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0'
classpath 'org.hibernate.build.gradle:gradle-xjc-plugin:1.0.2.Final'
classpath 'com.github.lburgazzoli:lb-karaf-features-gen:1.0.0-SNAPSHOT'
}
}
plugins {
id 'com.gradle.build-scan' version '1.1.1'
}
apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: "./libraries.gradle"
apply from: "./databases.gradle"
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
name 'jboss-nexus'
url "http://repository.jboss.org/nexus/content/groups/public/"
}
maven {
name "jboss-snapshots"
url "http://snapshots.jboss.org/maven2/"
}
}
}
ext {
hibernateTargetVersion = '5.2.5-SNAPSHOT'
expectedGradleVersion = '3.0-milestone-1'
baselineJavaVersion = '1.8'
osgiExportVersion = hibernateTargetVersion.replaceAll( '-SNAPSHOT', '.SNAPSHOT' )
final String[] versionComponents = hibernateTargetVersion.split( '\\.' );
hibernateFullVersion = hibernateTargetVersion
hibernateMajorMinorVersion = versionComponents[0] + '.' + versionComponents[1]
hibernateMajorVersion = versionComponents[0]
}
idea {
project {
jdkName = baselineJavaVersion
languageLevel = baselineJavaVersion
vcs = 'Git'
}
module {
name = "hibernate-orm"
}
}
// Used in MANIFEST.MF for OSGi Bundles
def osgiDescription() {
return "A module of the Hibernate O/RM project"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subprojects { subProject ->
apply plugin: 'idea'
apply plugin: 'eclipse'
defaultTasks 'build'
group = 'org.hibernate'
version = rootProject.hibernateTargetVersion
ext.exportPackageVersion = rootProject.osgiExportVersion
// minimize changes, at least for now (gradle uses 'build' by default)..
buildDir = "target"
if ( subProject.name.startsWith( 'release' ) || subProject.name.startsWith( 'documentation' ) ) {
return;
}
if ( subProject.name.startsWith( 'hibernate-orm-modules' ) ) {
return;
}
// everything below here in the closure applies to java projects
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
apply plugin: 'osgi'
apply plugin: 'findbugs'
apply plugin: 'checkstyle'
apply plugin: 'build-dashboard'
apply plugin: 'project-report'
apply plugin: org.hibernate.build.HibernateBuildPlugin
sourceCompatibility = rootProject.baselineJavaVersion
targetCompatibility = rootProject.baselineJavaVersion
configurations {
provided {
// todo : need to make sure these are non-exported
description = 'Non-exported compile-time dependencies.'
}
jbossLoggingTool {
description = 'Dependencies for running the jboss-logging tooling.'
}
configurations {
all*.exclude group: 'xml-apis', module: 'xml-apis'
}
}
// appropriately inject the common dependencies into each sub-project
dependencies {
compile libraries.logging
provided libraries.logging_annotations
jbossLoggingTool( libraries.logging_processor )
testCompile( libraries.junit )
testCompile( libraries.byteman )
testCompile( libraries.byteman_install )
testCompile( libraries.byteman_bmunit )
testRuntime( libraries.log4j )
testRuntime( libraries.javassist )
testRuntime( libraries.woodstox )
//Databases
testRuntime( libraries.h2 )
testRuntime( libraries.hsqldb )
testRuntime( libraries.postgresql )
testRuntime( libraries.mysql )
testRuntime( libraries.mariadb )
testRuntime( libraries.informix )
if (db.equalsIgnoreCase("oracle")) {
dependencies {
testRuntime( libraries.oracle )
}
}
if (db.equalsIgnoreCase("mssql")) {
dependencies {
testRuntime( libraries.mssql )
}
}
// 6.6 gave me some NPE problems from within checkstyle...
checkstyle 'com.puppycrawl.tools:checkstyle:6.5'
}
// mac-specific stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// should really use Jvm.current().toolsJar
ext.toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
if ( ext.toolsJar.exists() ) {
dependencies{
testCompile files( toolsJar )
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// compilation
task compile
compile.dependsOn compileJava, processResources, compileTestJava, processTestResources
sourceSets.main {
compileClasspath += configurations.provided
compileClasspath += configurations.jbossLoggingTool
}
subProject.getConvention().findPlugin( JavaPluginConvention.class ).sourceSets.each { sourceSet ->
JavaCompile javaCompileTask = project.tasks.findByName( sourceSet.compileJavaTaskName ) as JavaCompile
// NOTE : this aptDir stuff is needed until we can have IntelliJ run annotation processors for us
// which cannot happen until we can fold hibernate-testing back into hibernate-core/src/test
// which cannot happen until... ugh
File aptDir = subProject.file( "${subProject.buildDir}/generated-src/apt/${sourceSet.name}" )
sourceSet.allJava.srcDir( aptDir )
javaCompileTask.options.compilerArgs += [
"-nowarn",
"-encoding", "UTF-8",
"-s", "${aptDir.absolutePath}"
]
javaCompileTask.doFirst {
aptDir.mkdirs()
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// testing
subProject.tasks.withType( Test.class ).all { task ->
task.jvmArgs += [
'-XX:+HeapDumpOnOutOfMemoryError',
"-XX:HeapDumpPath=${project.file( "${project.buildDir}/OOM-dump.hprof" ).absolutePath}",
'-XX:MetaspaceSize=512M'
]
task.maxHeapSize = '2G'
task.systemProperties['hibernate.test.validatefailureexpected'] = true
task.systemProperties += System.properties.findAll { it.key.startsWith( "hibernate.") }
// uncomment to help identify pauses in test executions : where they occur
// task.beforeTest { descriptor ->
// println "Starting test: " + descriptor
// }
// task.afterTest { descriptor ->
// println "Completed test: " + descriptor
// }
}
processTestResources.doLast( {
copy {
from( sourceSets.test.java.srcDirs ) {
include '**/*.properties'
include '**/*.xml'
}
into sourceSets.test.output.classesDir
}
copy {
from file('src/test/resources')
into file( "${buildDir}/resources/test" )
exclude 'src/test/resources/arquillian.xml'
exclude 'src/test/resources/hibernate.properties'
}
copy {
from file('src/test/resources/hibernate.properties')
into file( "${buildDir}/resources/test" )
filter( ReplaceTokens, tokens: dbBundle[db] )
}
} )
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// artifact
jar {
manifest = osgiManifest {
// GRADLE-1411: Even if we override Imports and Exports
// auto-generation with instructions, classesDir and classpath
// need to be here (temporarily).
classesDir = sourceSets.main.output.classesDir
classpath = configurations.runtime
instruction 'Import-Package',
// Temporarily support JTA 1.1 -- Karaf and other frameworks still
// use it. Without this, the plugin generates [1.2,2).
'javax.transaction;version="[1.1,2)"',
// Tell Gradle OSGi to still dynamically import the other packages.
// IMPORTANT: Do not include the * in the modules' .gradle files.
// If it exists more than once, the manifest will physically contain a *.
'*'
instruction 'Bundle-Vendor', 'Hibernate.org'
instruction 'Bundle-Description', subProject.osgiDescription()
instruction 'Implementation-Url', 'http://hibernate.org'
instruction 'Implementation-Version', version
instruction 'Implementation-Vendor', 'Hibernate.org'
instruction 'Implementation-Vendor-Id', 'org.hibernate'
instruction 'Implementation-Title', name
instruction 'Specification-Title', name
instruction 'Specification-Version', version
instruction 'Specification-Vendor', 'Hibernate.org'
}
}
task sourcesJar(type: Jar, dependsOn: compileJava) {
from sourceSets.main.allSource
classifier = 'sources'
}
sourcesJar {
manifest = jar.manifest
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// IDE options
idea {
module {
jdkName = subProject.sourceCompatibility
excludeDirs = [file( ".gradle" )]
excludeDirs += file( "$buildDir/classes" )
excludeDirs += file( "$buildDir/bundles" )
excludeDirs += file( "$buildDir/packages" )
excludeDirs += file( "$buildDir/dependency-cache" )
excludeDirs += file( "$buildDir/libs" )
excludeDirs += file( "$buildDir/reports" )
excludeDirs += file( "$buildDir/test-results" )
excludeDirs += file( "$buildDir/tmp" )
excludeDirs += file( "$buildDir/matrix" )
excludeDirs += file( "$buildDir/resources" )
downloadSources = true
scopes.PROVIDED.plus += [configurations.provided]
}
}
eclipse {
jdt {
sourceCompatibility = subProject.sourceCompatibility
targetCompatibility = subProject.targetCompatibility
}
classpath {
plusConfigurations.add( configurations.provided )
}
}
// eclipseClasspath will not add sources to classpath unless the dirs actually exist.
// TODO: Eclipse's annotation processor handling is also fairly stupid (and completely lacks in the
// Gradle plugin). For now, just compile first in order to get the logging classes.
eclipseClasspath.dependsOn compile
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Report configs
checkstyle {
sourceSets = [ subProject.sourceSets.main ]
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
showViolations = false
}
// exclude generated java sources - by explicitly setting the base source dir
checkstyleMain.source = 'src/main/java'
findbugs {
sourceSets = [ subProject.sourceSets.main, subProject.sourceSets.test ]
ignoreFailures = true
toolVersion = '3.0.1'
// for now we need to set this to low so that FindBugs will actually report the DM_CONVERT_CASE warning we care about
reportLevel = 'low'
// remove all low level bug warnings except DM_CONVERT_CASE
excludeFilterConfig=resources.text.fromString(excludeAllLowLevelBugsExcept('DM_CONVERT_CASE'))
}
// exclude generated java sources and cfg package is a mess mainly from annotation stuff
findbugsMain.doFirst {
classes = classes.filter {
!it.path.contains( 'org/hibernate/hql/internal/antlr' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/cfg/spi' ) &&
!it.path.contains( 'org/hibernate/sql/ordering/antlr/Generated' ) &&
!it.path.contains( 'org/hibernate/sql/ordering/antlr/OrderByTemplateTokenTypes' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/Jaxb' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/Adapter' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/ObjectFactory' ) &&
!it.path.contains( 'org/hibernate/cfg' ) &&
!it.path.contains( '_\$logger' )
}
}
// because cfg package is a mess mainly from annotation stuff
checkstyleMain.exclude '**/org/hibernate/cfg/**'
checkstyleMain.exclude '**/org/hibernate/cfg/*'
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Publishing
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact( sourcesJar ) {
classifier 'sources'
}
}
// http://issues.gradle.org/browse/GRADLE-2966
// Once ^^ is resolved:
// 1) Move hibernate-testing module into hibernate-core tests
// 2) Define a second publication on hibernate-core for publishing the testing jar
// We could kind of do this now, but it would just be the jar. Every module would still need
// to duplicate the testing dependencies. Well, on second thought, we could centralize the
// testing dependencies here within the subprojects block
}
}
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file( "$subProject.buildDir/generated-pom.xml" )
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
task release(type: Task, dependsOn: 'release:release')
task wrapper(type: Wrapper) {
gradleVersion = expectedGradleVersion
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
def excludeAllLowLevelBugsExcept(String[] bugTypes){
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer);
xml.FindBugsFilter {
Match {
Confidence( value: '3' )
bugTypes.each { bug ->
Not {
Bug( pattern: "${bug}" )
}
}
}
}
return writer.toString( )
}