-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
199 lines (162 loc) · 6.66 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
apply plugin: "java"
def File weldDir
def String releaseVersion
def String examplesDir
def String cdiArtifactsDir
def String weldArtifactsDir
def String cdiApiDocsDir
def String finalName
def String distDir
def String docDir
def String defaultReadmePreface
def console = System.console()
task setup {
if (!project.hasProperty("weldPath"))
weldDir = file(console.readLine("\n Path to Weld Core source directory: \n"))
else
weldDir = new File(weldPath)
if(!project.hasProperty("weldVersion"))
releaseVersion = new String(console.readLine("\n Weld Core Version (used to locate built Weld jars): \n"))
else
releaseVersion = weldVersion
if (!weldDir.exists())
throw new FileNotFoundException("Cannot find " + weldDir.absolutePath);
if (releaseVersion.equals(""))
throw new IllegalArgumentException("You must specify valid Weld version.")
println "Using " + weldDir.toString() + " as Weld Core source directory."
println "Using " + releaseVersion + " as Weld Core version."
finalName = "weld-".concat(releaseVersion)
distDir = project.projectDir.absolutePath + "/" + finalName
examplesDir = distDir.concat("/examples")
cdiArtifactsDir = distDir.concat("/artifacts/cdi")
weldArtifactsDir = distDir.concat("/artifacts/weld")
docDir = distDir.concat("/doc")
cdiApiDocsDir = docDir.concat("/apidocs/cdi")
}
// create dependencies (including javadoc and sources artifacts) according given coords and version
def dep(coords, version = null) {
def coord = "$coords:$version"
def result = [dependencies.create(coord)]
result << dependencies.create("$coord:javadoc")
result << dependencies.create("$coord:sources")
result
}
task cleanDir(type: Delete, dependsOn: setup) {
delete fileTree(dir: weldDir.getAbsolutePath(), includes: ["**/target/", ".project", ".classpath", ".wtpmodules"])
delete distDir
delete "build"
delete finalName.concat(".zip")
doLast {
new File(distDir).mkdirs()
new File(examplesDir).mkdirs()
new File(cdiArtifactsDir).mkdirs()
new File(weldArtifactsDir).mkdirs()
new File(cdiApiDocsDir).mkdirs()
}
}
task copyFiles(type: Copy, dependsOn: cleanDir) {
from project.projectDir.absolutePath
into distDir
include "README.md"
include "LICENSE.txt"
}
task copyExamples(type: Copy, dependsOn: copyFiles) {
from fileTree(dir: weldDir.getAbsolutePath().concat("/examples"), excludes: ["**/target", "**/.settings", "**/.project"])
into examplesDir
}
repositories {
mavenCentral()
maven {
url "https://repository.jboss.org/nexus/content/groups/public/"
}
maven {
url "https://repository.jboss.org/nexus/content/repositories/staging"
}
maven {
url "https://oss.sonatype.org/content/groups/staging"
}
// Maven Local repo is here so that this script can be built even on just SNAPSHOTS
mavenLocal()
}
dependencies {
implementation dep("org.jboss.weld:weld-core-impl", releaseVersion)
implementation dep("org.jboss.weld.environment:weld-environment-common", releaseVersion)
implementation dep("org.jboss.weld.se:weld-se-core", releaseVersion)
if(releaseVersion.startsWith("3") || releaseVersion.startsWith("4") || releaseVersion.startsWith("5") || releaseVersion.startsWith("6")){
implementation dep("org.jboss.weld.module:weld-ejb", releaseVersion)
implementation dep("org.jboss.weld.module:weld-jsf", releaseVersion)
implementation dep("org.jboss.weld.module:weld-jta", releaseVersion)
implementation dep("org.jboss.weld.module:weld-web", releaseVersion)
implementation dep("org.jboss.weld.se:weld-se-shaded", releaseVersion)
implementation dep("org.jboss.weld.servlet:weld-servlet-shaded", releaseVersion)
implementation dep("org.jboss.weld.servlet:weld-servlet-core", releaseVersion)
} else {
implementation dep("org.jboss.weld.se:weld-se", releaseVersion)
implementation dep("org.jboss.weld.servlet:weld-servlet", releaseVersion)
implementation dep("org.jboss.weld.servlet:weld-servlet-core", releaseVersion)
implementation dep("org.jboss.weld:weld-core", releaseVersion) // this is intentionally removed from 3.x
}
// listed only because we need to download javadoc and sources artifacts too
implementation dep("jakarta.enterprise:jakarta.enterprise.cdi-api")
implementation dep("org.jboss.weld:weld-api")
implementation dep("org.jboss.weld:weld-spi")
}
// helper function which returns version of transitive dependency according the given artifactId
def getVersion(artifactId) {
def result = null
configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact art ->
def id = art.moduleVersion.id
if (id.name.equals(artifactId))
result = id.version
}
result
}
task adjustReadme(type: Exec, dependsOn: copyExamples) {
workingDir distDir
commandLine "sed"
if(!project.hasProperty("readme"))
defaultReadmePreface = "Weld is the reference implementation of CDI ".concat(getVersion("jakarta.enterprise.cdi-api"))
else
defaultReadmePreface = readme
args "-i", "s/{CUSTOM_TEXT}/$defaultReadmePreface/", "README.md"
}
task copyCdiArtifacts(type: Copy, dependsOn: adjustReadme) {
from configurations.runtimeClasspath.findAll { dep -> dep.name.contains("cdi") }
into cdiArtifactsDir
def cdiVersion = getVersion("jakarta.enterprise.cdi-api")
// rename jars - remove version
rename { String fileName ->
fileName.replace("-".concat(cdiVersion), "")
}
}
task copyWeldArtifacts(type: Copy, dependsOn: copyCdiArtifacts) {
from configurations.runtimeClasspath.findAll { dep -> dep.name.contains("weld") }
into weldArtifactsDir
def weldApiVersion = getVersion("weld-api")
// rename jars - remove version
rename { String fileName ->
fileName.replace("-".concat(releaseVersion), "").replace("-".concat(weldApiVersion), "")
}
}
task extractCdiApiDoc(type: Copy, dependsOn: copyWeldArtifacts) {
from zipTree(cdiArtifactsDir.concat("/jakarta.enterprise.cdi-api-javadoc.jar"))
into cdiApiDocsDir
}
task buildDocs(type: Exec, dependsOn: extractCdiApiDoc) {
workingDir weldDir.path.concat("/docs/reference")
commandLine "mvn"
args "clean", "compile"
}
task copyDocs(type: Copy, dependsOn: buildDocs){
from weldDir.path.concat("/docs/reference/target/docbook")
into docDir
}
task zipDist(type: Zip, dependsOn: copyDocs){
from (file(distDir)){
into finalName
}
baseName finalName
extension "zip"
destinationDir file(project.projectDir.absolutePath)
}
defaultTasks 'zipDist'