-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
101 lines (89 loc) · 2.64 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
plugins {
id "java"
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://maven.restlet.com" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
configurations.all {
resolutionStrategy {
force 'xml-apis:xml-apis:1.4.01'
force "org.xmlresolver:xmlresolver:${xmlresolverVersion}"
}
}
configurations {
standaloneClasspath.extendsFrom(testImplementation)
}
dependencies {
implementation (
[group: 'org.xmlresolver', name: 'xmlresolver', version: xmlresolverVersion],
[group: 'xml-apis', name: 'xml-apis', version: '1.4.01' ],
[group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30' ],
[group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30' ],
[group: 'com.beust', name: 'jcommander', version: '1.81' ]
)
}
task setupDist() {
FileCollection runtime = configurations.standaloneClasspath
String path = ""
runtime.each {
File file -> path += " lib/" + file.name
}
project.ext.runtimeClasspath = path.trim()
doLast {
copy {
into { "${buildDir}/dist/lib" }
from runtime
}
}
}
jar {
archiveBaseName = "xmlresolver-cachectrl-${relVersion}"
manifest {
attributes 'Built-By': 'Norman Walsh'
attributes 'Bundle-Vendor': 'Norman Walsh'
attributes 'Bundle-Description': 'XML Resolver cache control application.'
attributes 'Class-Path': "${project.ext.runtimeClasspath} lib"
attributes 'Implementation-Title': 'XML Resolver cache control'
attributes 'Implementation-Version': relVersion
attributes 'Main-Class': 'org.xmlresolver.apps.cachectrl.CacheCtrl'
}
}
jar.dependsOn setupDist
// Initially, I simply had the copyJar task copy the built jar
// into the build/dist directory. But on the CI instance, this
// always resulted in the files already in build/dist being
// deleted. I couldn't reliably reproduce that on a Mac or
// Linux, though I did think it happened once on my Linux test
// rig. I'm punting and doing this instead, which seems to work.
task copyJar(dependsOn: ["jar", "setupDist"]) {
doLast {
copy {
into "${buildDir}/stage"
from "${buildDir}/dist"
}
}
doLast {
copy {
into "${buildDir}/stage"
from "${buildDir}/libs"
}
}
}
task dist(dependsOn: ["copyJar", "setupDist"], type: Zip) {
from "${buildDir}/stage"
into 'xmlresolver-cachectrl-' + relVersion
archiveFileName = "xmlresolver-cachectrl-${relVersion}.zip"
}
// ======================================================================
task helloWorld() {
// My task for testing
doLast {
println("Hello, world.")
configurations.standaloneClasspath.each { jar ->
println("Classpath: ${jar}")
}
}
}