forked from jpos/jPOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
301 lines (268 loc) · 10.1 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.3.1'
classpath 'org.owasp:dependency-check-gradle:5.3.2.1'
}
}
apply plugin: 'biz.aQute.bnd.builder'
apply plugin: 'org.owasp.dependencycheck'
import aQute.bnd.gradle.Bundle
dependencies {
api libraries.jdom
api libraries.javatuples
api libraries.jline
api libraries.beanshell
api libraries.commons_cli
api libraries.bouncycastle
api libraries.slf4j_api
api libraries.hdrhistogram
implementation libraries.osgi_core
implementation libraries.javassist
implementation libraries.yaml;
implementation libraries.jdbm
implementation libraries.sleepycat_je
implementation libraries.sshd
testImplementation libraries.commons_lang3
testImplementation libraries.hamcrest
testImplementation libraries.fest_assert
testImplementation libraries.xmlunit
testImplementation libraries.junit
testImplementation (libraries.mockito) {
exclude(module: 'hamcrest-core')
}
testImplementation libraries.mockito_jupiter
// JSONPackager on hold
// compile (libraries.jsonsimple) {
// exclude(module: 'junit')
// exclude(module: 'hamcrest-core')
// }
// Integrated OSGI framework
// compile 'org.apache.felix:org.apache.felix.framework:5.0.0'
}
def archiveJarName="${project.name}-${project.version}.jar"
def q2ArchiveJarName="${project.name}-${project.version}-q2.jar"
def jposCopySpec = copySpec {
def cfg = new Properties()
def target = project.hasProperty('target') ? target : 'devel'
cfg.put('jarname', q2ArchiveJarName.toString())
cfg.put('target', target.toString())
File cfgFile = file("${target}.properties")
if (cfgFile.exists()) {
cfgFile.withInputStream{
cfg.load(it);
}
}
from(file("src/dist")) {
exclude 'cfg/*.lmk'
exclude 'cfg/*.jks'
exclude 'cfg/*.ks'
exclude 'cfg/*.ser'
exclude 'cfg/authorized_keys'
filter(
org.apache.tools.ant.filters.ReplaceTokens,
tokens: cfg
)
}
from(file("src/dist")) {
include 'cfg/*.lmk'
include 'cfg/*.ks'
include 'cfg/*.jks'
include 'cfg/*.ser'
include 'cfg/authorized_keys'
fileMode 0400
}
from(file("${project.buildDir}/${project.libsDirName}/${q2ArchiveJarName}"))
into("lib") {
from(configurations.runtimeClasspath)
}
}
def moduleName='org.jpos.jpos'
def bundleVendor='jPOS.org'
def bundleDescription="jPOS ${project.version}"
def bundleActivator = 'org.jpos.q2.Activator'
def bundleImportPackage = 'javax.crypto,javax.crypto.spec,javax.management,javax.naming,javax.net.ssl,javax.security.cert,javax.swing,javax.swing.border,javax.swing.event,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.tree,javax.xml.transform,javax.xml.transform.stream,org.osgi.framework;version="[1.6,2)",org.osgi.framework.launch;version="[1.0,2)",org.w3c.dom,org.xml.sax,org.xml.sax.helpers,org.xml.sax.ext'
def bundleExportPackage = 'org.jpos.bsh,org.jpos.core,org.jpos.iso,org.jpos.iso.channel,org.jpos.iso.filter,org.jpos.iso.gui,org.jpos.iso.header,org.jpos.iso.packager,org.jpos.iso.validator,org.jpos.q2,org.jpos.q2.cli,org.jpos.q2.install,org.jpos.q2.iso,org.jpos.q2.qbean,org.jpos.q2.security,org.jpos.q2.ui,org.jpos.security,org.jpos.security.jceadapter,org.jpos.space,org.jpos.tlv,org.jpos.transaction,org.jpos.transaction.gui,org.jpos.transaction.participant,org.jpos.ui,org.jpos.ui.action,org.jpos.ui.factory,org.jpos.util,org.jpos.util.function.org.jpos.emv,org.jpos.core.handlers.exception,org.jpos.rc'
def bundleLicense = 'http://jpos.org/license'
def bundleDocURL = 'http://jpos.org/doc/javadoc/index.html'
task listJars {
doLast {
configurations.testCompile.each { File file -> println file.name }
println " libsDir: ${project.libsDir}"
println "libsDirName: ${project.libsDirName}"
println "libsDirName: ${project.libsDirName}"
println " project: ${project.buildDir}"
}
}
jar () {
manifest {
attributes 'Implementation-Title': 'jPOS',
'Implementation-Version': project.version,
'Automatic-Module-Name': moduleName
}
bnd (
'Bundle-Vendor': bundleVendor,
'Bundle-License': bundleLicense,
'Bundle-DocURL': bundleDocURL,
'Bundle-Description': bundleDescription,
'Bundle-Activator': bundleActivator,
'Import-Package': bundleImportPackage,
'Export-Package': bundleExportPackage
)
}
java {
withSourcesJar()
}
task q2jar (type: Bundle) {
dependsOn jar
archiveClassifier.set('q2')
from sourceSets.main.output.classesDirs, sourceSets.main.output.resourcesDir
manifest {
def manifestClasspath = configurations.runtimeClasspath.collect { "lib/" + it.getName() }.join(' ')
attributes 'Implementation-Title': 'jPOS',
'Implementation-Version': project.version,
'Automatic-Module-Name': moduleName,
'Main-Class': 'org.jpos.q2.Q2',
'Class-Path': manifestClasspath
}
bnd (
'Bundle-Vendor': bundleVendor,
'Bundle-License': bundleLicense,
'Bundle-DocURL': bundleDocURL,
'Bundle-Description': bundleDescription,
'Bundle-Activator': bundleActivator,
'Import-Package': bundleImportPackage,
'Export-Package': bundleExportPackage,
'Include-Resource': configurations.runtimeClasspath.collect { '-lib/' + it.getName() }.join(' ')
)
}
task bundleFull (type: Bundle) {
dependsOn jar
archiveClassifier.set('bundle-full')
from sourceSets.main.output.classesDirs, sourceSets.main.output.resourcesDir
manifest {
def manifestClasspath = configurations.runtimeClasspath.collect { "lib/" + it.getName() }.join(' ')
attributes 'Implementation-Title': 'jPOS',
'Implementation-Version': project.version,
'Automatic-Module-Name': moduleName,
'Main-Class': 'org.jpos.q2.Q2',
'Class-Path': manifestClasspath
}
bnd (
'Bundle-Vendor': bundleVendor,
'Bundle-License': bundleLicense,
'Bundle-DocURL': bundleDocURL,
'Bundle-Description': bundleDescription,
'Bundle-Activator': bundleActivator,
'Import-Package': bundleImportPackage,
'Export-Package': bundleExportPackage,
'Include-Resource': configurations.runtimeClasspath.collect { '-lib/' + it.getName() }.join(' ')
)
into ('lib') {
from configurations.runtimeClasspath {
exclude 'org.osgi.core*.jar'
}
}
}
task sourceJar( type: Jar ) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
artifacts {
archives sourceJar, javadocJar, bundleFull
}
task dist (type: Tar) {
dependsOn 'q2jar', 'assemble', 'sourceJar'
compression = Compression.GZIP
includeEmptyDirs true
with jposCopySpec
into "jpos-$project.version"
archiveExtension="tar.gz"
}
task zip (type: Zip) {
dependsOn 'q2jar', 'assemble', 'sourceJar'
includeEmptyDirs true
includeEmptyDirs true
with jposCopySpec
into "jpos-$project.version"
}
task version (type: JavaExec, dependsOn: classes) {
description = "Display jPOS Version"
main = 'org.jpos.q2.Q2'
args = "--version".split().toList()
classpath sourceSets.main.runtimeClasspath
}
// just an alias to keep the old install task name
task install(dependsOn: publishToMavenLocal) {}
class GitRevisionTask extends DefaultTask
{
@InputFile @Optional
File gitHead
@Input
boolean gotHead
@InputFile @Optional
File getRefFile() {
File rf = new File(gitHead.parent,gitHead.text.replace('ref: ', '').trim())
return rf.exists() ? rf : gitHead
}
@OutputFile
File outputFile
@TaskAction
public void writeFile()
{
Properties props=new Properties()
if (gotHead) {
File ref=getRefFile()
if (ref != null && ref.exists()) {
props.put("branch",ref.getName())
props.put("revision",ref.text.substring(0,7))
} else {
props.put("branch", "detached");
props.put("revision", gitHead.text.substring(0,7))
}
} else {
props.put("branch", "unknown");
props.put("revision", "unknown");
}
props.store(new FileOutputStream(outputFile),"Revision Properties")
}
}
class BuildTimestampTask extends DefaultTask {
@OutputFile
File outputFile
@TaskAction
public void writeFile() {
new File(outputFile.parent).mkdirs()
Properties props=new Properties()
props.put("version", project.version);
props.put("buildTimestamp", new Date().format("yyyy-MM-dd HH:mm:ss z"));
props.store(new FileOutputStream(outputFile),"Revision Properties")
}
}
task createRevisionPropertyFile(type: GitRevisionTask) {
gitHead = "$rootDir/.git/HEAD" as File
gotHead = gitHead.exists()
if (!gotHead)
gitHead = null;
outputFile = "$sourceSets.main.output.resourcesDir/org/jpos/q2/revision.properties" as File
}
task createBuildTimestampPropertyFile(type: BuildTimestampTask) {
outputFile = "$sourceSets.main.output.resourcesDir/org/jpos/q2/buildinfo.properties" as File
}
processResources.dependsOn createBuildTimestampPropertyFile, createRevisionPropertyFile
processResources.outputs.upToDateWhen{ false } // issue with Gradle 2.4 confused about UP-TO-DATE (works OK with 2.3)
task installApp(type: Sync) {
dependsOn q2jar
delete "${project.buildDir}/install/${project.name}/cfg"
description 'Installs jPOS based application'
into { file("${project.buildDir}/install/${project.name}") }
with jposCopySpec
}
task viewTests (description: 'Open Test Reports') {
doLast {
Class.forName("java.awt.Desktop").newInstance().browse(
new File("${buildDir}/reports/tests/test", 'index.html').toURI())
}
}