forked from alkacon/modules-v8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
330 lines (302 loc) · 12.4 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
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = java_target_version
targetCompatibility = java_target_version
buildDir = build_directory
project.ext.currentDate=new Date().format('dd.MM.yy')
project.ext.modulesDistsDir = file("${project.buildDir}/modulesZip")
if (!project.hasProperty('max_heap_size')){
project.ext.max_heap_size='1024m'
}
Properties props = new Properties()
props.load(new FileInputStream("$projectDir/modules/all-modules.properties"))
project.ext.allModuleNames = props['modules.common.all']
project.ext.modulesDistsDir = file("${project.buildDir}/modulesZip")
repositories {
mavenLocal()
if (project.hasProperty('additional_repositories')){
additional_repositories.split(';').each{ repo ->
maven { url repo }
}
}
mavenCentral()
maven {
url "http://maven.vaadin.com/vaadin-addons"
}
maven {
url 'http://maven.restlet.org'
}
}
configurations { compile { description = 'used to compile the modules jars'
} }
// import dependencies
apply from: 'dependencies.gradle'
allModuleNames.split(',').each{ moduleName ->
sourceSets.create(moduleName,{
java {
srcDir "${projectDir}/src"
exclude '**/test/**'
}
resources.srcDir "${projectDir}/src"
});
sourceSets[moduleName].compileClasspath=configurations.compile
def moduleFolder = file("${projectDir}/modules/${moduleName}")
def srcGwtDir = file("${projectDir}/src-gwt")
def manifestFile = file("${moduleFolder}/resources/manifest.xml")
def gwtModule = null
def gwtSourceSetName = null
def propertyFile = file("${moduleFolder}/module.properties")
def gwtRename = null
if (propertyFile.exists()){
println "checking properties for module $moduleName"
Properties moduleProperties= new Properties()
moduleProperties.load(new FileInputStream(propertyFile))
if (moduleProperties['module.gwt']!=null){
gwtModule = moduleProperties['module.gwt']
gwtSourceSetName = moduleName.replace(".", "_")+'_gwt'
println "found GWT module $gwtModule"
def moduleXml = (new XmlParser()).parse(srcGwtDir.toString()+"/" +gwtModule.replaceAll('\\.','/')+'.gwt.xml')
gwtRename = moduleXml['@rename-to']
if (gwtRename==null){
gwtRename=gwtModule
}
}
}
def moduleDependencies=[]
def moduleVersion = version
if (manifestFile.exists()){
def parsedManifest= (new XmlParser()).parse("${moduleFolder}/resources/manifest.xml")
parsedManifest.module[0].dependencies[0].dependency.each{ dep ->
moduleDependencies.add(dep.@name)
}
moduleVersion = parsedManifest.module[0].version[0].text()
}
task "jar_$moduleName" (type: Jar) {
ext.moduleName = moduleName
ext.moduleVersion= moduleVersion
manifest {
attributes 'Implementation-Title': 'Alkacon OAMP', 'Implementation-Version': moduleVersion
}
from sourceSets[moduleName].output
archiveName moduleName+'.jar'
baseName moduleName
exclude '**/.gitignore'
exclude '**/test/**'
doFirst {
println '======================================================'
println "Building JAR for $moduleName version $moduleVersion"
println '======================================================'
}
}
task "dist_$moduleName" (dependsOn: "jar_$moduleName", type: Zip){
ext.moduleName = moduleName
ext.moduleFolder = moduleFolder
ext.dependencies = moduleDependencies
ext.gwtSourceSetName = gwtSourceSetName
ext.gwtRenameTo = gwtRename
if (project.hasProperty('noVersion')) {
version
} else {
version moduleVersion
}
destinationDir modulesDistsDir
// include the jar file
from( "${project.buildDir}/libs") {
include "${moduleName}.jar"
into "/system/modules/${moduleName}/lib/"
}
baseName moduleName
doFirst {
println '======================================================'
println "Building ZIP for $moduleName version $moduleVersion"
println '======================================================'
}
// include the GWT resources if necessary
if (gwtModule == null){
from "${moduleFolder}/resources"
}else{
// exclude the manifest for now, use the synced manifest later
from ("${moduleFolder}/resources") {
exclude 'manifest.xml'
exclude "system/modules/${moduleName}/resources/${gwtRenameTo}/**"
}
from( "${project.buildDir}/gwt/${moduleName}") {
exclude '**/WEB-INF/**'
into "/system/modules/${moduleName}/resources/"
}
def syncedManifest="${project.buildDir}/extra/${moduleName}/manifest.xml"
from syncedManifest
doFirst{
println "Syncing manifest from ${moduleFolder}/resources/manifest.xml to ${syncedManifest} using resources folder system/modules/${moduleName}/resources/${gwtRenameTo} with resources from ${project.buildDir}/gwt/${moduleName}/${gwtRenameTo}"
ant.taskdef(resource: 'org/opencms/util/ant/taskdefs.properties', classpath: configurations.compile.asPath)
ant.syncmanifest(
srcmanifestfile: "${moduleFolder}/resources/manifest.xml",
dstmanifestfile: syncedManifest,
base: "${moduleFolder}/resources/",
prefix: "system/modules/${moduleName}/resources/${gwtRenameTo}",
directory: "${project.buildDir}/gwt/${moduleName}/${gwtRenameTo}"
)
}
}
}
if (gwtModule != null){
println "creating sourceset for $gwtModule"
sourceSets.create(gwtSourceSetName,{
java {
srcDirs srcGwtDir
exclude '**/test/**'
}
resources {
srcDirs srcGwtDir
}
})
sourceSets[gwtSourceSetName].compileClasspath=configurations.compile
task "gwt_$moduleName" (dependsOn: "${gwtSourceSetName}Classes", type: JavaExec) {
ext.buildDir = project.buildDir.toString() +"/gwt/$moduleName"
ext.extraDir = project.buildDir.toString() + "/extra/$moduleName"
ext.moduleName = moduleName
inputs.source sourceSets[gwtSourceSetName].java.srcDirs
inputs.dir sourceSets[gwtSourceSetName].output.resourcesDir
outputs.dir buildDir
// Workaround for incremental build (GRADLE-1483)
outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
doFirst {
println '======================================================'
println "Building GWT resources for $gwtModule"
println '======================================================'
// to clean the output directory, delete it first
def dir = file(buildDir)
if (dir.exists()){
delete(dir)
}
dir.mkdirs()
}
main = 'com.google.gwt.dev.Compiler'
classpath {
[
sourceSets[moduleName].java.srcDirs,
sourceSets[moduleName].compileClasspath,
sourceSets[gwtSourceSetName].java.srcDirs,
sourceSets[gwtSourceSetName].output.resourcesDir,
sourceSets[gwtSourceSetName].output.classesDir
]
}
args =
[
gwtModule,
// Your GWT module
'-war',
buildDir,
'-logLevel',
'INFO',
'-localWorkers',
'2',
'-style',
'obfuscated',
'-extra',
extraDir,
'-strict'
// '-draftCompile' // Speeds up compile with 25%
]
maxHeapSize = max_heap_size
}
tasks["dist_$moduleName"].dependsOn tasks["gwt_$moduleName"]
}
task "javadoc_$moduleName" (type: Javadoc){
source = sourceSets[moduleName].allJava
classpath = project.sourceSets[moduleName].compileClasspath
destinationDir = file("${buildDir}/docs/javadoc${moduleName}")
options.addStringOption("sourcepath", "")
}
task "javadocJar_$moduleName"(type: Jar) {
it.dependsOn("javadoc_$moduleName")
classifier = 'javadoc'
from "${buildDir}/docs/javadoc${moduleName}"
baseName moduleName
}
task "sourcesJar_$moduleName"(type: Jar) {
from sourceSets[moduleName].allSource
classifier = 'sources'
baseName moduleName
}
}
task bindist {
doFirst{
println 'Done'
}
}
tasks.findAll{ task -> task.name.startsWith('dist_')}.each{ dist_task ->
dist_task.dependencies.each{ dep ->
def depCompileName = 'compile'+dep.replaceAll('\\.','')+'java'
tasks.findAll{ comp_task -> comp_task.name.toLowerCase().equals(depCompileName)}.each {comp_task ->
sourceSets[dist_task.moduleName].compileClasspath += files("${project.buildDir}/classes/$dep") { builtBy comp_task.name }
if (dist_task.gwtSourceSetName!=null){
sourceSets["${dist_task.gwtSourceSetName}"].compileClasspath += files("${project.buildDir}/classes/$dep") { builtBy comp_task.name }
// we need to manipulate the classpath of the java doc task specifically
tasks['javadoc_'+dist_task.moduleName].classpath += files("${project.buildDir}/classes/$dep") { builtBy comp_task.name }
}
}
}
tasks['jar_'+dist_task.moduleName].dependsOn{
tasks.findAll{ comp_task -> comp_task.name.toLowerCase().equals('compile'+dist_task.moduleName.replaceAll('\\.','')+'java')}
}
bindist.dependsOn dist_task
}
// fixed issue with libraries containing both .java and .class files
tasks.withType(JavaCompile) {
options.compilerArgs += ["-sourcepath", ""]
}
artifacts {
tasks.each{ task ->
if (task.name.startsWith("jar_com.alkacon.")){
def moduleName=task.baseName
archives task
archives tasks["javadocJar_$moduleName"]
archives tasks["sourcesJar_$moduleName"]
}
}
}
install {
repositories {
mavenInstaller {
artifacts.each{ arch ->
def filterName=arch.name
if (filterName.startsWith("com.alkacon")){
filterName=filterName.substring(0, filterName.lastIndexOf(".jar"))
addFilter(filterName){artifact, file ->
artifact.name.startsWith(filterName)
}
pom(filterName).project {
name 'Alkacon OAMP'
description 'Alkacon OAMP'
packaging 'jar'
groupId 'com.alkacon'
url 'http://www.alkacon.com'
scm {
url 'scm:[email protected]:alkacon/alkacon-oamp.git'
connection 'scm:[email protected]:alkacon/alkacon-oamp.git'
developerConnection 'scm:[email protected]:alkacon/alkacon-oamp.git'
}
licenses {
license {
name 'GNU General Public License'
url 'http://www.gnu.org/licenses/gpl.html'
distribution 'repo'
}
}
organization {
name 'Alkacon Software'
url 'http://www.alkacon.com'
}
developers {
developer {
name 'Alkacon Software'
url 'http://www.alkacon.com'
}
}
}
}
}
}
}
}