/
build.gradle
164 lines (132 loc) · 4.89 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
import org.apache.tools.ant.taskdefs.Delete;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.resources.FileResource;
import groovy.xml.MarkupBuilder;
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'checkstyle'
version = '1.1'
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
mainClassName = 'de.tntinteractive.portalsammler.Portalsammler'
sourceCompatibility = '1.7'
repositories {
mavenCentral()
}
configurations {
classycle
}
dependencies {
compile 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.37.1',
'org.seleniumhq.selenium:selenium-support:2.37.1',
'org.bouncycastle:bcprov-jdk15on:1.49',
'org.swinglabs:pdf-renderer:1.0.5',
'com.jgoodies:jgoodies-forms:1.6.0',
'com.google.zxing:core:2.2',
'com.google.zxing:javase:2.2',
'com.github.sarxos:webcam-capture:0.3.9'
testCompile 'junit:junit:4.+'
classycle 'org.specs2:classycle:1.4.1'
}
jar {
manifest {
attributes 'Implementation-Title': 'Portalsammler',
'Implementation-Version': version,
'Main-Class': project.mainClassName,
'Application-Name': 'Portalsammler',
'Permissions': 'all-permissions'
}
}
task noCyclicDependencies(type: JavaExec) {
main = 'classycle.dependency.DependencyChecker'
classpath = configurations.classycle
args '-dependencies=check absenceOfPackageCycles > 1 in *', "${project.buildDir}/classes/main"
}
check.dependsOn noCyclicDependencies
task mergeJarsIntoOne(dependsOn: installApp) {
String libdir = "${project.buildDir}/install/Portalsammler/lib"
File output = file("${project.buildDir}/oneSignedJar/${project.name}-${project.version}.tmp.jar")
inputs.dir libdir
outputs.file output
doLast {
FileSet sourceJars = ant.fileset(dir : file(libdir)) {
}
sourceJars.setIncludes("*.jar");
ant.zip(destFile: output,
encoding: 'UTF-8',
duplicate: 'preserve') {
zipfileset(
src: file("$libdir/${project.name}-${project.version}.jar"),
includes: '**/META-INF/**'
);
for (FileResource filename in sourceJars) {
zipfileset(
src: filename,
excludes: '**/META-INF/**'
);
}
};
}
}
task repack200(dependsOn: mergeJarsIntoOne, type: Exec) {
String injar = "${project.buildDir}/oneSignedJar/${project.name}-${project.version}.tmp.jar";
String outjar = "${project.buildDir}/oneSignedJar/${project.name}-${project.version}.repacked.jar";
inputs.file injar
outputs.file outjar
commandLine System.getenv('JAVA_HOME') + '/bin/pack200', '--repack', outjar, injar
}
task signJar(dependsOn: repack200, type: Exec) {
String injar = "${project.buildDir}/oneSignedJar/${project.name}-${project.version}.repacked.jar";
String outjar = "${project.buildDir}/oneSignedJar/${project.name}-${project.version}.jar";
inputs.file injar
outputs.file outjar
commandLine System.getenv('JAVA_HOME') + '/bin/jarsigner',
'-storetype', 'pkcs12',
'-keystore', "${project.buildDir}/../../codesigning.p12",
'-tsa', 'http://time.certum.pl',
'-signedjar', outjar,
injar,
'root ca id von tobias baum'
doFirst {
String password = javax.swing.JOptionPane.showInputDialog('Enter keystore password');
args '-storepass', password
}
}
task pack200(dependsOn: signJar, type: Exec) {
String jar = "${project.buildDir}/oneSignedJar/${project.name}-${project.version}.jar";
String packgz = "${project.buildDir}/oneSignedJar/${project.name}-${project.version}.jar.pack.gz";
inputs.file jar
outputs.file packgz
commandLine System.getenv('JAVA_HOME') + '/bin/pack200', packgz, jar
}
build.dependsOn pack200
task createJnlp {
File output = file("${project.buildDir}/oneSignedJar/${project.name}-${project.version}.jnlp")
outputs.file output
doLast {
def out = new FileWriter(output)
def b = new MarkupBuilder(out)
b.jnlp(id: 'portalsammler', border: 0) {
information {
title('Portalsammler')
vendor('Tobias Baum / TNT Interactive')
homepage('http://github.com/tobiasbaum/Portalsammler')
'offline-allowed'()
}
security {
'all-permissions'()
}
resources {
j2se(version: '7.0+')
jar(href: "${project.name}-${project.version}.jar")
}
'application-desc'()
}
out.close();
}
}
build.dependsOn createJnlp