forked from jfrog/build-info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
538 lines (465 loc) · 18.9 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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
/*
* Copyright (C) 2011 JFrog Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
jcenter()
dependencies { classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0' }
}
}
import org.apache.tools.ant.filters.ReplaceTokens
import org.jfrog.build.Version
boolean excludeMavenPluginBuild = project.hasProperty('excludeMavenPluginBuild') && project.property('excludeMavenPluginBuild')
// Root project version should not be used
project.version = '2'
project.ext.baseProjectNames = ['build-info-api', 'build-info-client', 'build-info-extractor', 'build-info-vcs']
defaultTasks 'clean', 'build', 'install'
allprojects {
apply plugin: 'idea'
apply plugin: 'com.jfrog.artifactory'
group = 'org.jfrog.buildinfo'
repositories {
maven { url "https://oss.jfrog.org/jfrog-dependencies" }
jcenter()
}
}
artifactory {
contextUrl = 'https://localhost:8080/artifactory'
//contextUrl = 'https://oss.jfrog.org'
publish {
defaults {
publishConfigs('archives', 'published')
properties = ['build.status': "$it.project.status".toString(), 'bintray.repo': 'jfrog/jfrog-jars']
}
}
}
artifactoryPublish.skip = true
def baseProjects() {
subprojects.findAll { p -> baseProjectNames.contains(p.name) }
}
def extractorProjects() {
subprojects.findAll { p -> !baseProjectNames.contains(p.name) }
}
subprojects {
apply plugin: 'maven'
apply plugin: 'java'
repositories {
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
mavenLocal()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext.buildInfoVersion = new Version(rootProject, baseProjectNames)
configurations {
published
}
dependencies {
compile group: 'commons-lang', name: 'commons-lang', version: '2.4'
compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1'
compile group: 'commons-io', name: 'commons-io', version: '2.2'
testCompile group: 'org.testng', name: 'testng', version: '6.10'
}
// From the install task of the maven plugin (an upload task), take the RepositoryHandler (repositories) and for the
// MavenResolver (mavenInstaller) take the pomFilterContainer (pom) and configure the maven project
configure(install.repositories.mavenInstaller) {
pom.project {
url 'http://wiki.jfrog.org/confluence/display/RTF/Build+Integration'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
mailingLists {
mailingList {
name 'JFrog Mailing List'
subscribe 'https://lists.sourceforge.net/lists/listinfo/artifactory-users'
archive 'http://forums.jfrog.org/Artifactory-Users-f2377369.html'
}
}
issueManagement {
system 'jira'
url 'http://issues.jfrog.org/jira/browse/BI'
}
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
uploadArchives {
uploadDescriptor = true
}
artifactoryPublish {
dependsOn build
}
// Add the sourceJars to non-extractor modules
artifacts {
published jar
published sourceJar
published javadocJar
}
install {
configuration = configurations.published
}
idea.module {
downloadJavadoc = false
downloadSources = true
}
test {
test.useTestNG()
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
minGranularity 0
}
}
}
configure(baseProjects()) {
version = buildInfoVersion
status = version.status
dependencies {
compile group: 'com.google.guava', name: 'guava', 'version': '27.0.1-jre'
compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
}
artifactoryPublish {
properties {
all 'org.jfrog.buildinfo:build-info-*:*:*@*', 'bintray.package': 'build-info', 'bintray.version': version.toString()
}
}
}
// Create configurations for the extractor projects
configure(extractorProjects()) {
it.version = new Version(it)
it.status = version.status
configurations {
provided
tools
sources
uberJar {
description = 'All jars that should be included in the Uber Jar'
transitive = true
}
compile {
extendsFrom uberJar
extendsFrom provided
}
}
boolean extractorRelease = project.hasProperty('extractorRelease') //??????
dependencies {
//Binary depend on the latest extractor release artifact, if forced using the extractorRelease prop or if
//release version and current extractor is snapshot. Otherwise, use project build dependency
if (extractorRelease || (version.release && !buildInfoVersion.release)) {
uberJar group: "$group", name: 'build-info-extractor', version: project.getProperty('build-info-latest-release-version')
} else {
uberJar project(':build-info-extractor')
}
tools group: 'com.googlecode.jarjar', name: 'jarjar', version: '1.3'
}
task jarAll(type: Jar) {
inputs.files configurations.uberJar
inputs.files tasks.jar.outputs.files
dependsOn jar
//Add the directory of the archive as the input files for this task
classifier = 'uber'
doLast {
boolean debugJarJar = project.hasProperty('debugJarJar')
project.ant {
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.tools.asPath
//Zip the project's jar (jar.archivePath) and the dependencies defined for the uberJar conf into archivePath (with classifier)
if (debugJarJar) println "Creating Uber jar $archivePath with:"
jarjar(jarfile: archivePath) {
zipfileset(src: jar.archivePath)
configurations.uberJar.files.each { jarjarFile ->
if (!jarjarFile.name.endsWith("-sources.jar")) {
zipfileset(src: jarjarFile)
if (debugJarJar) println "\t$jarjarFile"
}
}
}
}
}
}
// Add the published artifact of the jarAll task to the list of published artifacts for the archives configuration
artifacts {
published jarAll
}
assemble {
dependsOn jarAll
}
// Treat the uberJar conf as a maven compile scope so that uberJar depenedncies are transformed into compile-scope
// dependencies in generated extractor poms
configure(install.repositories.mavenInstaller) {
pom.scopeMappings.addMapping(MavenPlugin.COMPILE_PRIORITY + 1, configurations.uberJar, "compile")
pom.scopeMappings.addMapping(MavenPlugin.COMPILE_PRIORITY + 2, configurations.provided, "provided")
}
artifactoryPublish {
properties {
all 'org.jfrog.buildinfo:build-info-*:*:*@*', 'bintray.package': project.name.toString(), 'bintray.version': project.version.toString()
if (!excludeMavenPluginBuild) {
all 'org.jfrog.buildinfo:artifactory-maven-plugin:*:*@*', 'bintray.package': project.name.toString(), 'bintray.version': project.version.toString()
}
}
}
}
// Declare the root project to build its children first
evaluationDependsOnChildren()
project('build-info-api') {
description = 'JFrog Build-Info API'
dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.9'
compile group: 'org.apache.commons', name: 'commons-compress', version: '1.18'
}
}
project('build-info-client') {
description = 'JFrog Build-Info Client'
dependencies {
compile project(':build-info-api')
compile("org.apache.httpcomponents:httpclient:4.5.2") {
exclude module: "commons-codec"
}
compile 'org.apache.httpcomponents:httpcore:4.4.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.9'
compile "commons-codec:commons-codec:1.8"
}
sourceSets {
main {
resources {
srcDir 'src/main/filtered-resources'
}
}
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include '**/*bi.client.properties'
filter(ReplaceTokens, tokens: ['project.version': project.version.toString()])
}
}
}
project('build-info-extractor') {
description = 'JFrog Build-Info Extractor'
dependencies {
compile project(':build-info-client')
testCompile "org.easymock:easymockclassextension:2.5.2"
}
}
project('build-info-vcs') {
description = 'JFrog Build-Info VCS'
dependencies {
compile(group: 'com.perforce', name: 'p4java', version: '2015.1.1210280')
}
}
project('build-info-extractor-ivy') {
description = 'JFrog Build-Info Ivy Extractor'
dependencies {
uberJar "org.slf4j:slf4j-api:1.5.8"
provided "com.google.code.findbugs:jsr305:1.3.9",
"org.apache.ivy:ivy:2.2.0",
"org.apache.ant:ant:1.8.4"
}
//Configure the Maven installer pom generation
configure(install.repositories.mavenInstaller) {
pom.project {
issueManagement {
system 'jira'
url 'http://issues.jfrog.org/jira/browse/IAP'
}
}
}
}
project('build-info-extractor-gradle') {
apply plugin: 'groovy'
description = 'JFrog Build-Info Gradle Extractor'
println description
dependencies {
compile gradleApi()
compile fileTree(dir: "${gradle.gradleHomeDir}/lib/plugins", include: '**/*.jar') //workaround for GRADLE-1699
provided "org.codehaus.plexus:plexus-component-annotations:1.5.5",
"com.google.code.findbugs:jsr305:1.3.9"
uberJar group: 'org.apache.ivy', name: 'ivy', version: '2.2.0'
compile localGroovy()
testCompile(group: 'org.spockframework', name: 'spock-core', version: '0.7-groovy-2.0') {
transitive = false
}
testCompile(group: 'net.java.dev.jna', name: 'jna', version: '3.2.2')
}
test {
//Spock runs with JUnit
test.useJUnit()
systemProperties['buildInfoConfig.propertiesFile'] = ''
environment['buildInfoConfig.propertiesFile'] = ''
}
configure(install.repositories.mavenInstaller) {
pom.project {
issueManagement {
system 'jira'
url 'http://issues.jfrog.org/jira/browse/GAP'
}
}
}
}
project('build-info-extractor-maven3') {
apply plugin: 'groovy'
description = 'JFrog Build-Info Maven 3 Extractor'
dependencies {
compile 'org.jdom:jdom:1.1.1',
'org.codehaus.groovy:groovy-all:2.4.12',
'plexus:plexus-container-default:1.0-alpha-6',
'org.sonatype.aether:aether-api:1.13.1',
'org.sonatype.aether:aether-util:1.13.1',
'org.sonatype.aether:aether-impl:1.13.1',
'org.eclipse.aether:aether-api:1.0.2.v20150114',
'org.eclipse.aether:aether-util:1.0.2.v20150114',
'org.eclipse.aether:aether-impl:1.0.2.v20150114',
'org.codehaus.plexus:plexus-utils:3.0.10',
'org.apache.maven:maven-repository-metadata:3.5.2',
'org.apache.maven:maven-model:3.1.0'
compile('org.apache.maven.plugins:maven-deploy-plugin:2.8.2') {
exclude group: 'org.codehaus.plexus', module: 'plexus-utils'
exclude group: 'org.apache.maven', module: 'maven-model'
}
compile('org.apache.maven:maven-core:3.3.3') {
exclude group: 'org.codehaus.plexus', module: 'plexus-utils'
exclude group: 'org.apache.maven', module: 'maven-model'
}
uberJar 'org.eclipse.aether:aether-impl:1.0.2.v20150114'
provided 'org.codehaus.plexus:plexus-component-annotations:1.6'
testCompile 'org.easymock:easymockclassextension:2.5.2'
}
configure(install.repositories.mavenInstaller) {
pom.project {
issueManagement {
system 'jira'
url 'http://issues.jfrog.org/jira/browse/MAP'
}
}
}
}
project('build-info-extractor-npm') {
description = 'JFrog Build-Info npm Extractor'
dependencies {
testCompile project(':build-info-extractor').sourceSets.test.output
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
}
}
if (!excludeMavenPluginBuild) {
project('artifactory-maven-plugin') {
Project p ->
apply plugin: 'groovy'
description = 'JFrog Build-Info Maven 3 Plugin'
dependencies {
compile project(':build-info-api'),
'org.apache.maven.plugin-tools:maven-plugin-annotations:3.5',
'org.gcontracts:gcontracts-core:1.2.12',
'org.codehaus.plexus:plexus-utils:3.0.13',
'org.apache.ant:ant:1.9.2'
compile(project(':build-info-extractor-maven3')) { exclude group: 'org.jdom', module: 'jdom' }
compile('org.codehaus.gmaven:gmaven-mojo:1.5') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all-minimal'
}
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
provided 'org.apache.maven:maven-core:3.3.3',
'org.apache.maven:maven-project:3.0-alpha-2'
}
clean { delete('pom.xml') }
task pluginDescriptor(type: Exec) {
// http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.Exec.html
final mvn = project.hasProperty('mvn') ? project.mvn :
!System.getProperty('os.name')?.toLowerCase()?.contains('win') ? 'mvn' :
new File('mvn.cmd').exists() ? 'mvn.cmd' : 'mvn.bat'
final mvnArgs = project.hasProperty('mvnArgs') ? project.mvnArgs : ''
final File pom = project.file("$buildDir/pom.xml")
final allArgs = ['-e', '-B', '-f', pom.canonicalPath, mvnArgs, 'org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor'].grep()
executable mvn
args allArgs
doFirst {
assert project.compileGroovy.destinationDir.directory
install.repositories.mavenInstaller.pom.writeTo(pom)
assert pom.file, "[$pom.canonicalPath] was not generated"
println "POM is generated at file:$pom.canonicalPath"
pom.text = pom.text.
replace('<groupId>unknown</groupId>', "<groupId>${project.group}</groupId>").
replace('<artifactId>empty-project</artifactId>', "<artifactId>${project.name}</artifactId>").
replace('<version>0</version>', """
|<version>${version}</version>
| <packaging>maven-plugin</packaging>
| <build>
| <directory>${project.buildDir.canonicalPath}</directory>
| <outputDirectory>${
project.compileGroovy.destinationDir.canonicalPath
}</outputDirectory>
| </build>""".stripMargin().trim())
println "Running '$mvn' with arguments $allArgs"
}
doLast {
final pluginDescriptor = new File((File) project.compileGroovy.destinationDir, 'META-INF/maven/plugin.xml')
assert pluginDescriptor.file, "[$pluginDescriptor.canonicalPath] was not created"
println "Plugin descriptor file:$pluginDescriptor.canonicalPath is created"
}
}
/**
* We need to ensure all other sub-projects are installed for 'mvn' to find their artifacts
*/
p.rootProject.subprojects.findAll { it.hasProperty('install') && (it.name != p.name) }.
each { pluginDescriptor.dependsOn(it.install) }
p.jar.dependsOn(pluginDescriptor)
configure(install.repositories.mavenInstaller) {
pom.project {
issueManagement {
system 'jira'
url 'http://issues.jfrog.org/jira/browse/MAP'
}
repositories {
for (String repoUrl in project.repositories*.url.toSet()) {
repository {
id repoUrl.toString().replaceAll(~/[^\w]/, '_')
url repoUrl
}
}
}
}
}
test{
//Spock runs with JUnit
test.useJUnit()
}
}
}
idea {
project {
jdkName = '1.8'
languageLevel = '1.8'
wildcards += '?*.gradle'
idea.project.ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
}
}
}
module {
excludeDirs += file('out')
iml.withXml {
provider ->
provider.node.component.first().appendNode('orderEntry', [type: 'library', name: 'Groovy', level: 'application'])
}
}
}