-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
243 lines (212 loc) · 7.02 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
// Plugins
plugins {
id "de.carne.java-tools" version "1.2.0" apply false
id "org.sonarqube" version "3.3" apply false
id "com.install4j.gradle" version "9.0.5" apply false
id "org.owasp.dependencycheck" version "6.5.1"
}
// Build helpers
def snapshotBuild = project.version.endsWith("-SNAPSHOT")
def releaseBuild = !snapshotBuild
def mavenPublicRepository = "https://s01.oss.sonatype.org/content/groups/public/"
def mavenReleaseRepository = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def mavenSnapshotRepository = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
def mavenI4jRepository = "https://maven.ej-technologies.com/repository/"
apply plugin: "de.carne.java-tools"
javatools {
githubRelease {
enabled = true
releaseAssets = fileTree(".") {
include("**/filescanner-cocoa-macosx-x86_64_*.dmg")
include("**/filescanner-gtk-linux-x86_64-*.tar.gz")
include("**/filescanner-win32-win32-x86_64_*.exe")
}
overwrite = true
githubToken = project.findProperty('githubToken')
ignoreDirty = true
}
}
subprojects.each { draftGitHubRelease.dependsOn("${it.name}:assembleMedia") }
// Projects
defaultTasks "classes", "testClasses"
subprojects {
apply plugin: "java"
apply plugin: "de.carne.java-tools"
apply plugin: "jacoco"
apply plugin: "org.sonarqube"
apply plugin: "distribution"
apply plugin: "com.install4j.gradle"
apply plugin: "eclipse"
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
maven { url mavenPublicRepository }
maven { url mavenI4jRepository }
if(snapshotBuild) {
maven { url mavenSnapshotRepository }
}
mavenLocal()
}
def sharedSrcDir = "../filescanner-gtk-linux-x86_64/shared-src"
javatools {
generateI18N {
enabled = true
bundles = fileTree("${sharedSrcDir}/main/resources").include("**/*I18N.properties")
lineSeparator = "\n"
}
}
sourceSets {
main {
java {
srcDir "${sharedSrcDir}/main/java"
srcDir javatools.generateI18N.genDir
}
resources {
srcDir "${sharedSrcDir}/main/resources"
}
}
test {
java {
srcDir "${sharedSrcDir}/test/java"
}
}
}
def platformSuffix = project.name.substring(rootProject.name.length())
dependencies {
implementation(group: "org.eclipse.jdt", name: "org.eclipse.jdt.annotation", version: project.annotationVersion)
implementation(group: "de.carne", name: "java-default", version: project.javaDefaultVersion)
implementation(group: "de.carne", name: "java-swt${platformSuffix}", version: project.javaSwtVersion)
implementation(group: "de.carne", name: "filescanner-engine", version: project.filescannerEngineVersion)
implementation(group: "org.glassfish.grizzly", name: "grizzly-http-server", version: project.glassfishGrizzlyVersion)
implementation(group: "org.apache.lucene", name: "lucene-analyzers-common", version: project.luceneVersion)
implementation(group: "org.apache.lucene", name: "lucene-queryparser", version: project.luceneQueryParserVersion) {
exclude(group: "org.apache.lucene", module: "lucene-sandbox")
}
compileOnly(group: "com.install4j", name: "install4j-runtime", version: project.i4jVersion)
testImplementation(group: "com.install4j", name: "install4j-runtime", version: project.i4jVersion)
testImplementation(group: "de.carne", name: "java-test", version: project.javaTestVersion)
testImplementation(group: "de.carne", name: "java-test-swt${platformSuffix}", version: project.javaTestSwtVersion)
}
test {
useJUnitPlatform()
// SWT display can only be created once per VM
forkEvery = 1
testLogging {
events "started", "failed", "passed", "skipped"
exceptionFormat "full"
}
enabled = project.name.endsWith(javatools.platform.swtToolkit)
}
project.tasks["sonarqube"].enabled = test.enabled
jar {
manifest {
attributes(
'Created-By': "Gradle ${gradle.gradleVersion} (${System.properties['os.name']}:${System.properties['os.arch']}:${System.properties['os.version']})",
'Build-Jdk' : System.properties['java.version'],
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ").format(new Date()),
'X-Compile-Target-JDK': targetCompatibility,
'X-Compile-Source-JDK': sourceCompatibility,
'X-Module-Id': project.name,
'X-Module-Name': "FileScanner",
'X-Module-Version': project.version,
'X-Module-DocURL': projectUrl,
'X-Module-License': projectLicenseUrl
)
}
}
task bootJar(type: Jar) {
archiveAppendix = "boot"
entryCompression = ZipEntryCompression.STORED
from jar
from configurations.runtimeClasspath.collect {
it.name.matches("java-default-.*.jar") ? zipTree(it) : it
}
manifest {
attributes(
'Main-Class': "de.carne.boot.Application"
)
}
}
distributions {
main {
contents {
from bootJar
}
}
}
tasks.withType(Tar){
compression = Compression.GZIP
archiveExtension = "tar.gz"
}
install4j {
installDir = file(project.hasProperty("install4jHome") ? install4jHome : ".")
}
task assembleMedia(type: com.install4j.gradle.Install4jTask, dependsOn: assembleDist) {
def i4jProjectApplicationID = project.getProperty(project.name + ".i4jProjectApplicationID")
def i4jProjectMediaID = project.getProperty(project.name + ".i4jProjectMediaID")
enabled = i4jProjectApplicationID != "false"
projectFile = file("../src/main/install4j/filescanner.install4j")
variables = [
i4jProjectBaseName: rootProject.name,
i4jProjectName: project.name,
i4jProjectVersion: version,
i4jProjectBaseDir: projectDir,
i4jProjectBuildDir: buildDir,
i4jProjectSigningDir: file(project.hasProperty("install4jSigningHome") ? install4jSigningHome : "."),
i4jProjectApplicationID: i4jProjectApplicationID
]
buildIds = [
i4jProjectMediaID
]
if(project.hasProperty("install4jSigningPassword")) {
disableSigning = false
macKeystorePassword = install4jSigningPassword
} else {
disableSigning = true
}
quiet = true
}
jacoco {
toolVersion = project.jacocoVersion
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
xml.destination file("${buildDir}/reports/jacoco/coverage.xml")
}
}
test.finalizedBy jacocoTestReport
sonarqube {
properties {
property 'sonar.projectKey', "${rootProject.group}:${rootProject.name}"
property 'sonar.projectName', rootProject.name
property 'sonar.coverage.jacoco.xmlReportPaths', jacocoTestReport.reports.xml.destination
}
}
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
file {
whenMerged {
def eeaPath = project.findProperty("eclipse.eeaPath");
entries.forEach {
if(it.path.startsWith("org.eclipse.jdt.launching.JRE_CONTAINER")) {
if(eeaPath != null) {
it.entryAttributes.put("annotationpath", eeaPath)
}
} else if(it.path.contains("/caches/modules-2/")) {
if(eeaPath != null) {
it.entryAttributes.put("annotationpath", eeaPath)
}
} else if(it.path.contains("/generated-src/")) {
it.entryAttributes.put("ignore_optional_problems", "true")
}
}
}
}
}
}
}