-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbuild.gradle
220 lines (189 loc) · 6.91 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
/*
* PETEP Gradle Build
*/
plugins {
id 'java-library'
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.sonarqube' version '3.0'
}
repositories {
mavenCentral()
}
javafx {
version = "11.0.2"
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web']
}
java {
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.xerial:sqlite-jdbc:3.36.0.3'
implementation 'org.graalvm.sdk:graal-sdk:22.1.0.1'
implementation 'org.graalvm.sdk:polyglot-tck:22.1.0.1'
implementation 'org.graalvm.truffle:truffle-api:22.1.0.1'
implementation 'org.graalvm.js:js:22.1.0.1'
implementation group: 'org.openjfx', name: 'javafx-base', version: javafx.version, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javafx.version, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javafx.version, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafx.version, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafx.version, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafx.version, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafx.version, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafx.version, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafx.version, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafx.version, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafx.version, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafx.version, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-media', version: javafx.version, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-media', version: javafx.version, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-media', version: javafx.version, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-web', version: javafx.version, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-web', version: javafx.version, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-web', version: javafx.version, classifier: 'linux'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
testImplementation 'org.testng:testng:7.6.0'
testImplementation 'org.assertj:assertj-core:3.23.1'
testImplementation 'org.mockito:mockito-inline:4.6.1'
}
// UTF-8 encoding
compileJava.options.encoding = 'UTF-8'
mainClassName = 'com.warxim.petep.Main'
// Copy extensions from their build/libs/ to projects ext/
task copyExtensions(type: Copy, dependsOn: gradle.includedBuilds*.task(':jar')) {
into 'ext/'
gradle.includedBuilds.each { build ->
println 'Moving extension "' + build.rootDirectory + '" to ext/ directory.'
from build.rootDirectory.path + '/build/libs/'
}
}
// Run task
run {
if (gradle.ext.wizard) {
args = []
} else {
if (gradle.GUI) {
args = [gradle.ext.testProjectDirectory]
} else {
args = [gradle.ext.testProjectDirectory, "--nogui"]
}
}
dependsOn gradle.includedBuilds*.task(':jar'), copyExtensions
}
apply plugin: 'application'
// Export com.sun.javafx.css (for css editing)
application {
applicationDefaultJvmArgs = [
"--add-opens=javafx.graphics/com.sun.javafx.css=ALL-UNNAMED"
]
executableDir = ''
}
// Create jar library for extensions
task petepLibJar(type: Jar) {
println "Creating jar library"
includes = includedFiles(sourceSets.main.allSource.files)
archiveBaseName = "petep-lib"
with jar
}
task petepLibSourcesJar(type: Jar, dependsOn: classes) {
archiveBaseName = "petep-lib-sources"
includes = includedSourceFiles(sourceSets.main.allSource.files)
from sourceSets.main.allSource
}
// Create fat jar
jar {
from(sourceSets.main.output) {
println "Creating fat jar"
manifest {
attributes 'Main-Class': "$mainClassName"
}
archiveBaseName = 'petep'
}
duplicatesStrategy = 'exclude'
}
/**
* Include only Java @PetepAPI classes to jar and FXML files with <!-- PetepAPI -->
*/
def includedFiles(Collection<File> files) {
List<String> included = new ArrayList<>()
files.each { file ->
if (file.name.endsWith(".java") && file.text.contains("@PetepAPI") ) {
String temp = projectDir.toURI().relativize(
file.toURI()).toString()
.replace(".java", "**.class") // Include all
.replace("src/main/java/", "")
included += temp
println "- including: " + temp
} else if (file.name.endsWith(".fxml") && file.text.contains("<!-- PetepAPI -->")) {
String temp = projectDir.toURI().relativize(
file.toURI()).toString()
.replace("src/main/resources/", "")
included += temp
println "- including: " + temp
}
}
return included
}
/**
* Include only Java @PetepAPI annotated
*/
def includedSourceFiles(Collection<File> files) {
List<String> included = new ArrayList<>()
files.each { file ->
if (file.name.endsWith(".java") && (file.text.contains("@PetepAPI") || file.text.contains("@interface PetepAPI")) ) {
included += projectDir.toURI()
.relativize(file.toURI())
.toString()
.replace("src/main/java/", "")
}
}
return included
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
distributions {
main {
distributionBaseName = "petep"
contents {
from("LICENSE.md") {
into ""
}
from("CHANGELOG.md") {
into ""
}
from("README.md") {
into ""
}
from(petepLibJar) {
into "api"
}
from(petepLibSourcesJar) {
into "api"
}
from("ext") {
into "ext"
}
from("presets") {
into "presets"
}
from("project_template") {
into "project_template"
}
from("scripts") {
into ""
}
startScripts.onlyIf {false}
}
}
}
test {
useTestNG()
}
artifacts {
archives petepLibSourcesJar
}