-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
225 lines (219 loc) · 8.42 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
allprojects {
apply plugin: 'maven'
group = 'eu.clarussecure'
version = '1.0.1'
task generatePom {
doLast {
pom {
project {
if (parent != null) {
parent {
groupId parent.group
artifactId parent.name
version parent.version
relativePath projectDir.toPath().relativize(parent.projectDir.toPath()).toString().replace('\\', '/')
}
}
packaging project.ext.packaging
name project.description
withXml {
Node root = new XmlParser().parse(new File("$mainProject/src/main/maven/pom-common.xml"))
Node node = asNode()
for (child in root.children()) {
node.append(child)
}
}
if (!subprojects.isEmpty()) {
modules {
for (Project subproject : subprojects.findAll { project -> !project.name.equals("proxy-main") }) {
module projectDir.toPath().relativize(subproject.projectDir.toPath()).toString().replace('\\', '/')
}
for (Project subproject : subprojects.findAll { project -> project.name.equals("proxy-main") }) {
module projectDir.toPath().relativize(subproject.projectDir.toPath()).toString().replace('\\', '/')
}
}
}
}
withXml {
String templateFilename = !subprojects.isEmpty() ? "pom-parent.xml" : "pom-module.xml"
String cnt = new File("$mainProject/src/main/maven/$templateFilename").text
if (project.hasProperty('mainClassName')) {
cnt = cnt.replace("@MAIN_CLASS@", project.ext.mainClassName)
} else {
cnt = cnt.replace("@MAIN_CLASS@", "")
}
Node root = new XmlParser().parseText(cnt)
Node node = asNode()
for (child in root.children()) {
node.append(child)
}
if (parent != null) {
String installDir = null;
if (projectDir.toPath().getParent().equals(parent.projectDir.toPath().resolve("modules"))
|| projectDir.toPath().getParent().equals(parent.projectDir.toPath().resolve("plugins"))) {
installDir = "install/ext-libs"
} else if (project.name.equals("proxy-main")) {
installDir = "install/libs"
}
if (installDir != null) {
String content = new File("$mainProject/src/main/maven/pom-profile-install-libs.xml").text
content = content.replace("@INSTALL_DIR@", "\${project.parent.relativePath}/$installDir")
root = new XmlParser().parseText(content)
for (child in root.children()) {
node.append(child)
}
}
asNode().remove(asNode().get('version'))
}
Node nodeRepos = null;
int repoId = 1;
repositories.each {
String name = it.name;
String url = it.url;
if (!"MavenLocal".equals(name) && !"MavenRepo".equals(name)) {
if (nodeRepos == null) {
nodeRepos = asNode().appendNode("repositories");
}
Node nodeRepo = nodeRepos.appendNode("repository");
nodeRepo.appendNode("id", "repo-" + repoId);
nodeRepo.appendNode("name", name);
nodeRepo.appendNode("url", url);
++ repoId;
}
}
}
}.writeTo("$projectDir/pom.xml")
}
}
configure(generatePom) {
group = 'Maven'
description = 'Generates the Maven pom.xml'
}
task deletePom {
doLast {
delete "$projectDir/pom.xml"
}
}
configure(deletePom) {
group = 'Maven'
description = 'Deletes the Maven pom.xml'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = "1.8";
targetCompatibility = "1.8";
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// Log
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'ch.qos.logback:logback-core:1.1.3'
compile ('ch.qos.logback:logback-classic:1.1.3') {
exclude group: 'org.slf4j'
}
// Test
testCompile 'junit:junit:4.12'
}
eclipse {
classpath {
downloadSources=true
}
}
ext {
packaging = 'jar'
}
jar.doFirst {
manifest = project.manifest {
attributes("Implementation-Title": project.description,
"Implementation-Version": version,
"Implementation-Vendor": "The CLARUS consortium",
"Class-Path": configurations.runtime.files.collect { it.getName() }.join(' '))
if (project.hasProperty('mainClassName')) {
attributes "Main-Class": project.ext.mainClassName
}
}
}
}
description = 'CLARUS proxy'
ext {
mainProject = project.projectDir
packaging = 'pom'
}
ext.moduleProjects = subprojects.findAll { project -> project.projectDir.toPath().getParent().equals(projectDir.toPath().resolve("modules")) }
ext.pluginProjects = subprojects.findAll { project -> project.projectDir.toPath().getParent().equals(projectDir.toPath().resolve("plugins")) }
ext.proxyProjects = subprojects.findAll { project -> project.name.equals("proxy-main") }
task installAll(type: Copy, dependsOn: ['installScripts', 'installLibs', 'installExtensionLibs']) {
}
configure(installAll) {
group = 'Install'
description = 'Copy all files to the install directory'
}
task uninstallAll {
doLast {
delete "$projectDir/install"
}
}
configure(uninstallAll) {
group = 'Install'
description = 'Delete the install directory'
}
task installScripts(type: Copy) {
from('src/main/scripts/')
into project.file("$projectDir/install")
}
configure(installScripts) {
group = 'Install'
description = 'Copy scripts to the install directory'
}
task uninstallScripts {
doLast {
delete fileTree(dir: "$projectDir/install", exclude: ["libs", 'ext-libs'])
}
}
configure(uninstallScripts) {
group = 'Install'
description = 'Delete the scripts in the install directory'
}
task installLibs(type: Copy, dependsOn: [proxyProjects.jar]) {
from([proxyProjects.jar])
into project.file("$projectDir/install/libs")
from([proxyProjects.configurations.runtime])
into project.file("$projectDir/install/libs")
}
configure(installLibs) {
group = 'Install'
description = 'Copy the proxy jars to the install/libs directory'
}
task uninstallLibs {
doLast {
delete "$projectDir/install/libs"
}
}
configure(uninstallLibs) {
group = 'Install'
description = 'Delete the install/libs directory'
}
task installExtensionLibs(type: Copy, dependsOn: [pluginProjects.jar, moduleProjects.jar]) {
from([pluginProjects.jar, moduleProjects.jar])
into project.file("$projectDir/install/ext-libs")
from([pluginProjects.configurations.runtime, moduleProjects.configurations.runtime])
into project.file("$projectDir/install/ext-libs")
}
configure(installExtensionLibs) {
group = 'Install'
description = 'Copy the plugins and modules jars to the install/ext-libs directory'
}
task uninstallExtensionLibs {
doLast {
delete "$projectDir/install/ext-libs"
}
}
configure(uninstallExtensionLibs) {
group = 'Install'
description = 'Delete the install/ext-libs directory'
}