forked from grails/grails-data-mapping
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
300 lines (253 loc) · 10.2 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
buildscript {
repositories {
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "io.github.gradle-nexus:publish-plugin:1.3.0"
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
}
}
ext {
groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion
// overall project version
isCiBuild = System.getenv().get("CI") as Boolean
isSnapshot = project.projectVersion.endsWith("-SNAPSHOT")
isReleaseVersion = !isSnapshot
nexusUsername = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
nexusPassword = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
}
def spockDependency = "org.spockframework:spock-core:$spockVersion"
def isGroovyProject(project) {
!project.name.contains("grails-plugins")
}
configurations {
all*.exclude group: "commons-logging"
}
version = project.projectVersion
group = "org.grails"
apply plugin: 'idea'
apply plugin: 'project-report'
allprojects {
ext.groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion
repositories {
mavenLocal()
mavenCentral()
maven { url = 'https://repo.grails.org/grails/core' }
if(isSnapshot) {
maven { url = 'https://repo.grails.org/grails/libs-snapshots-local' }
}
if(groovyVersion && groovyVersion.endsWith('-SNAPSHOT')) {
maven {
name = 'JFrog Groovy snapshot repo'
url = 'https://groovy.jfrog.io/artifactory/libs-snapshot-local'
}
}
}
configurations {
all {
resolutionStrategy {
force "org.codehaus.groovy:groovy:$groovyVersion"
force "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
force "org.codehaus.groovy:groovy-xml:$groovyVersion"
force "org.codehaus.groovy:groovy-templates:$groovyVersion"
}
}
}
}
apply from: "gradle/idea.gradle"
subprojects {
configurations {
documentation
}
version = project.projectVersion
group = "org.grails"
afterEvaluate { subproject ->
if (isGroovyProject(subproject)) {
def hasSnapshotVersion = subproject.version.endsWith("-SNAPSHOT")
if(isSnapshot != hasSnapshotVersion) {
throw new StopExecutionException("${subproject.name} has version \"${subproject.version}\" which is${isSnapshot ? 'n\'t' : ''} a snapshot version.")
}
}
}
def isStandardGroovyMavenProject = isGroovyProject(project)
if (isStandardGroovyMavenProject) {
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java-library'
sourceCompatibility = 1.11
targetCompatibility = 1.11
}
def isGormDatasource = project.name.startsWith("grails-datastore-gorm-") &&
!project.name.endsWith("tck") &&
!project.name.endsWith("-support") &&
!project.name.endsWith("-core") &&
!project.name.endsWith("-gorm-validation") &&
!project.name.contains("-rx") &&
project.name != 'grails-datastore-gorm-rest-client'
dependencies {
api "javax.annotation:javax.annotation-api:$javaAnnotationApiVersion"
if (isStandardGroovyMavenProject) {
documentation "org.fusesource.jansi:jansi:2.4.0"
documentation "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
documentation 'info.picocli:picocli:4.6.3'
documentation ("com.github.javaparser:javaparser-core:$javaParserCoreVersion")
api "org.codehaus.groovy:groovy:$groovyVersion"
testImplementation "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.9.1"
testImplementation "org.junit.platform:junit-platform-runner:1.9.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.9.1"
testImplementation(spockDependency) { transitive = false }
}
if (project.name == "grails-datastore-gorm-tck") {
api "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
api "org.junit.jupiter:junit-jupiter-api:5.9.1"
api "org.junit.platform:junit-platform-runner:1.9.1"
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:5.9.1"
implementation(spockDependency) { transitive = false }
}
}
if (isGormDatasource) {
dependencies {
testImplementation project(":grails-datastore-gorm-tck")
}
// We need to test against the TCK. Gradle cannot find/run tests from jars
// without a lot of plumbing, so here we copy the class files from the TCK
// project into this project's test classes dir so Gradle can find the test
// classes and run them. See grails.gorm.tests.GormDatastoreSpec for on the TCK.
// helper, used below.
def toBaseClassRelativePathWithoutExtension = { String base, String classFile ->
if (classFile.startsWith(base)) {
def sansClass = classFile[0 .. classFile.size() - ".class".size() - 1]
def dollarIndex = sansClass.indexOf('$')
def baseClass = dollarIndex > 0 ? sansClass[0..dollarIndex - 1] : sansClass
def relative = baseClass - base - '/'
relative
}
else {
null
}
}
compileTestGroovy {
configure(groovyOptions.forkOptions) {
jvmArgs = [ '-Xmx768m']
}
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat ='full'
}
if (isCiBuild) {
maxParallelForks = 2
jvmArgs = ['-server', '-Xmx1024M']
forkEvery = 20
afterSuite {
System.out.print('.')
System.out.flush()
}
} else {
maxParallelForks = 4
forkEvery = 100
jvmArgs = ['-server', '-Xmx2048M']
}
if(System.getProperty("debug.tests")) {
jvmArgs '-Xmx2g', '-Xdebug', '-Xnoagent', '-Djava.compiler=NONE',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
}
}
test.doFirst {
File tckClassesDir = project(":grails-datastore-gorm-tck").sourceSets.main.output.classesDirs.files.first()
def thisProjectsTests = // surely there is a less hardcoded way to do this
copy {
from tckClassesDir
into sourceSets.test.output.classesDirs.files.first()
include "**/*.class"
exclude { details ->
// Do not copy across any TCK class (or nested classes of that class)
// If there is a corresponding source file in the particular modules
// test source tree. Allows a module to override a test/helper.
if (!details.file.isFile()) {
return false
}
def candidatePath = details.file.absolutePath
def relativePath = toBaseClassRelativePathWithoutExtension(tckClassesDir.absolutePath, candidatePath)
if (relativePath == null) {
throw new IllegalStateException("$candidatePath does not appear to be in the TCK")
}
project.file("src/test/groovy/${relativePath}.groovy").exists()
}
}
}
// Only enable to force update dependencies
// configurations.all {
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
// }
}
if (isStandardGroovyMavenProject) {
configure([javadoc]) {
options.encoding "UTF-8"
options.docEncoding "UTF-8"
options.charSet "UTF-8"
options.jFlags "-Xms64M", "-Xmx512M"
}
configure([groovydoc]) {
classpath += configurations.documentation
}
}
}
configurations {
build
}
dependencies {
build "com.cenqua.clover:clover:3.3.0"
build "org.apache.ant:ant-junit:1.10.12"
build "org.apache.ant:ant-nodeps:1.8.1"
}
task install(dependsOn: subprojects*.tasks*.withType(PublishToMavenLocal))
apply from: 'https://raw.githubusercontent.com/grails/grails-common-build/master/common-publishing.gradle'
task test(dependsOn: getTasksByName("test", true)) {
doLast {
def reportsDir = "${buildDir}/reports"
// Aggregate the test results
ant.taskdef(
name: 'junitreport2',
classname: "org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator",
classpath: configurations.build.asPath
)
def testReportsDir = new File("${reportsDir}/tests")
if (testReportsDir.exists()) {
testReportsDir.deleteDir()
}
testReportsDir.mkdirs()
ant.junitreport2(todir: testReportsDir) {
subprojects.each {
def testResultsDir = "${it.buildDir}/test-results"
if (new File(testResultsDir).exists()) {
fileset(dir: testResultsDir) {
include(name: "TEST-*.xml")
}
}
}
report(todir: testReportsDir)
}
}
}
if (isReleaseVersion) {
nexusPublishing {
transitionCheckOptions {
maxRetries.set(50)
delayBetween.set(java.time.Duration.ofMillis(5000))
}
}
}
project.afterEvaluate {
allprojects.repositories.each { handler ->
handler.each {
if (it.url.toString().startsWith("http://")) {
throw new RuntimeException("Build should not define insecure HTTP-based Maven repostories")
}
}
}
}