-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
156 lines (137 loc) · 5.55 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
defaultTasks 'jar'
buildscript {
repositories { mavenCentral() }
dependencies {
classpath 'com.admc:gradle-javaPropFile-plugin:latest.milestone'
classpath 'com.admc:gradle-ivyxml-plugin:latest.milestone'
}
}
apply plugin: 'java'
apply plugin: 'ivyxml'
apply plugin: 'javaPropFile'
import com.admc.gradle.GradleUtil
ivyxml.load()
def localGradleFile = file('local.gradle')
if (localGradleFile.isFile()) {
logger.info('''Executing optional build file 'localGradleFile'.''')
apply from: localGradleFile
}
// Defaults that can be overridden with property files:
sourceCompatibility = '1.2'
targetCompatibility = sourceCompatibility
project.setProperty('org.name', System.properties['user.name'])
project.setProperty('jar.title', 'Customization')
propFileLoader.typeCasting = true
propFileLoader.traditionalPropertiesInit()
repositories { mavenCentral() }
// Work-around for Gradle bug where Runtime classpath must include every
// Compilation classpath element:
configurations { compileOnly }
task noop << { }
noop.description = 'Noop task for Gradle testing'
project.rtLibs = null
jar { doFirst {
project.rtLibs = []
Set<File> runtimeOnlyFiles = configurations.compileOnly.files as Set<File>
configurations.runtime.files.each {
if (!runtimeOnlyFiles.contains(it)) project.rtLibs << it.name
}
jar { manifest { attributes(
'Main-Class': 'com.sun.msv.schematron.Driver',
'Class-Path': project.rtLibs.join(' '),
'Specification-Title': 'Relames',
'Specification-Version': project.upstreamVersion,
'Specification-Vendor': 'Sun Microsystems, Inc.',
'Implementation-Title': project.property('jar.title'),
'Implementation-Version': project.version,
'Implementation-Vendor': project.property('org.name')
) } }
} }
// This task only for SCM administrator. Update version and execute this task.
task updateWrapper(type: Wrapper) { doFirst {
assert project.hasProperty('newVersion') :
'''Property 'newVersion' is required for task 'updateWrapper'.'''
assert project.newVersion == gradle.gradleVersion :
"You invoked Gradle system with version $gradle.gradleVersion instead of desired version $project.newVersion"
} }
updateWrapper << {
gradleVersion = project['newVersion']
println 'WARNING: Merge our customizations into the newly-generated wrapper scripts'
}
updateWrapper.description = 'Update Gradle version. For SCM Administrators.'
task serialver(dependsOn: compileJava) << {
assert project.hasProperty('className'):
'''Property 'className' is required for task 'serialver'.'''
String fileSep = System.properties['file.separator']
// Could alternatively use Gradle's ExecSpec via exec(...)
String javaHome = System.properties['java.home']
String javacHome = (javaHome.endsWith("jre")
? javaHome.substring(0, javaHome.length() - "/jre".length())
: javaHome)
Process process = new ProcessBuilder([
javacHome + fileSep + 'bin' + fileSep + 'serialver',
'-classpath',
'build/classes/main' + System.properties['path.separator']
+ configurations.runtime.asPath,
project.property('className')
]).redirectErrorStream(true).start()
// Must read input before waitFor-ing
File outFile = new File(System.properties['java.io.tmpdir'],
'serialVer-' + System.properties['user.name'] + '.txt')
process.inputStream.eachLine { println it; outFile.write(it + '\n') }
assert process.waitFor() == 0: '''Execution of 'serialver' failed'''
println """Also written to file '$outFile.absolutePath'
so you can read it into your editor."""
}
serialver.description = "Generates Java serialversion for specified 'classname'"
task checkTabs << {
FileTree tree = fileTree(dir: '.')
tree.exclude '**/.*/**'
tree.include '*.*'
tree.include 'gradlew'
tree.include 'src/**'
tree.include 'doc/**'
tree.include 'schemas/**'
def tabFiles = []
tree.each { if (it.text.indexOf('\t') > -1) tabFiles << relativePath(it) }
if (tabFiles.size() > 0) println ' ' + tabFiles.join('\n ')
}
checkTabs.description = 'Reports on any text files containing tab characters'
task zip(dependsOn: jar, type: Zip) {
from configurations.runtime.allArtifacts.files
from configurations.runtime
from new File(buildDir, 'filtered-docs')
into(project.name + '-' + project.version)
exclude '**/crimson-*.jar'
}
zip.description =
'Build zip of end-user executable relames jar with dependencies'
compileJava.dependsOn << { GradleUtil.verifyResolve(configurations.compile) }
zip.dependsOn << { GradleUtil.verifyResolve(configurations.runtime) }
import java.text.SimpleDateFormat
import org.apache.tools.ant.filters.ReplaceTokens
import org.apache.tools.ant.filters.FixCrLfFilter
zip { doFirst {
copy {
from 'doc'
into new File(buildDir, 'filtered-docs')
exclude '**/.*/**'
filter(ReplaceTokens, tokens: [
VERSION: (upstreamVersion
+ ' (ADMC Relames v. ' + project.version + ')'),
YEAR: new SimpleDateFormat("yyyy").format(new Date())
])
//Ask how to do this at Gradle forum:
//filter(FixCrLfFilter, eol: 'lf')
}
} }
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
sourcesJar.description = 'Build sources jar file'
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadocJar.description = 'Build javadoc jar file'