Skip to content

Commit 0b12f8a

Browse files
authored
build(gradle): prepare gradle convert to kotlin, permit rerun build locally (#717)
1 parent 13f4108 commit 0b12f8a

File tree

4 files changed

+98
-102
lines changed

4 files changed

+98
-102
lines changed

build.gradle

Lines changed: 68 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// Copyright 2020 The Terasology Foundation
22
// SPDX-License-Identifier: Apache-2.0
33

4-
/*
5-
* This is a Gradle build file:
6-
* - Gradle Homepage: http://gradle.org/
7-
* - Gradle Documentation: http://gradle.org/documentation
8-
* - View tasks for this project: $ gradlew tasks
9-
*/
104

115
buildscript {
126
repositories {
@@ -19,21 +13,21 @@ buildscript {
1913
}
2014

2115
plugins {
22-
id 'application'
23-
id 'checkstyle'
24-
id "com.github.spotbugs" version "5.2.3"
25-
id 'de.undercouch.download' version '5.3.0'
26-
id 'java'
16+
id("application")
17+
id("checkstyle")
18+
id("com.github.spotbugs") version "5.2.3"
19+
id("de.undercouch.download") version "5.3.0"
20+
id("java")
2721
// to help clarify conflicting logging providers
28-
id 'name.remal.component-metadata' version '1.5.0'
29-
id 'nebula.release' version '16.0.0'
30-
id 'pmd'
31-
id 'project-report'
32-
id 'org.openjfx.javafxplugin' version '0.0.13'
33-
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.5"
22+
id("name.remal.component-metadata") version "1.5.0"
23+
id("nebula.release") version "16.0.0"
24+
id("pmd")
25+
id("project-report")
26+
id("org.openjfx.javafxplugin") version "0.0.13"
27+
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.5"
3428
}
3529

36-
apply plugin: 'org.terasology.gradlegoo'
30+
apply plugin: "org.terasology.gradlegoo"
3731
apply from: "./config/gradle/jre.gradle"
3832

3933
// Test for right version of Java in use for running this script
@@ -62,10 +56,10 @@ ext {
6256
startDateTimeString = dateTimeFormat.format(new Date())
6357

6458
// Splash image for the JAR
65-
splashImage = 'org/terasology/launcher/images/splash.jpg'
59+
splashImage = "org/terasology/launcher/images/splash.jpg"
6660

6761
// Shared code analytics configurations via retrieved config zip
68-
metricsConfigDir = layout.getProjectDirectory().dir('config/metrics')
62+
metricsConfigDir = layout.getProjectDirectory().dir("config/metrics")
6963
}
7064

7165
// Declare remote repositories we're interested in - library files will be fetched from here
@@ -97,61 +91,61 @@ dependencies {
9791
because "1.3 series uses ServiceLoader (more packaging friendly?)"
9892
}
9993

100-
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
101-
implementation group: "com.google.guava", name: "guava", version: "31.1-jre"
102-
implementation group: 'com.github.everit-org.json-schema', name: 'org.everit.json.schema', version: '1.14.1'
94+
implementation("com.google.code.gson:gson:2.8.5")
95+
implementation("com.google.guava:guava:31.1-jre")
96+
implementation("com.github.everit-org.json-schema:org.everit.json.schema:1.14.1")
10397

104-
implementation group: 'org.kohsuke', name: 'github-api', version: '1.318'
105-
implementation group: 'org.semver4j', name: 'semver4j', version: '5.2.2'
106-
implementation group: 'com.vladsch.flexmark', name: 'flexmark-all', version: '0.64.0'
98+
implementation("org.kohsuke:github-api:1.318")
99+
implementation("org.semver4j:semver4j:5.2.2")
100+
implementation("com.vladsch.flexmark:flexmark-all:0.64.0")
107101

108-
implementation('org.hildan.fxgson:fx-gson:5.0.0') {
102+
implementation("org.hildan.fxgson:fx-gson:5.0.0") {
109103
because "de-/serialization of launcher properties to JSON"
110104
}
111105

112-
implementation('com.squareup.okhttp3:okhttp:4.12.0') {
106+
implementation("com.squareup.okhttp3:okhttp:4.12.0") {
113107
because "built-in caching of HTTP requests"
114108
}
115109

116110
// These dependencies are only needed for running tests
117111

118-
testImplementation 'org.hamcrest:hamcrest:2.2'
119-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
120-
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
121-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
112+
testImplementation("org.hamcrest:hamcrest:2.2")
113+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2")
114+
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.2")
115+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2")
122116

123-
testImplementation('org.mockito:mockito-inline:5.2.0') {
117+
testImplementation("org.mockito:mockito-inline:5.2.0") {
124118
because "-inline build enables mocking final classes"
125119
// https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.2
126120
// > Be aware that this artifact may be abolished when the inline mock making feature is integrated into the default mock maker.
127121
}
128-
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
122+
testImplementation("org.mockito:mockito-junit-jupiter:5.2.0")
129123

130-
testImplementation('org.spf4j:spf4j-slf4j-test:8.10.0') {
124+
testImplementation("org.spf4j:spf4j-slf4j-test:8.10.0") {
131125
because "testable logging"
132126
}
133-
testImplementation('org.slf4j:slf4j-api:2.0.13')
127+
testImplementation("org.slf4j:slf4j-api:2.0.13")
134128

135129
testImplementation("org.testfx:testfx-core:4.0.18") {
136130
because "to test JavaFX Application"
137131
// -alpha because that's the only kind of release they have?
138132
}
139-
testImplementation "org.testfx:testfx-junit5:4.0.18"
133+
testImplementation("org.testfx:testfx-junit5:4.0.18")
140134

141135
testImplementation("org.testfx:openjfx-monocle:17.0.10") {
142136
// nobody's uploaded a jdk-14 build yet. does the jdk-12 one work?
143137
because "CI builders are headless environments"
144138
}
145139

146-
testImplementation('com.github.gmazzo.okhttp.mock:mock-client:2.0.0') {
140+
testImplementation("com.github.gmazzo.okhttp.mock:mock-client:2.0.0") {
147141
because "to easily write OkHttpClient interceptors for testing"
148142
}
149-
testImplementation('com.squareup.okhttp3:mockwebserver:4.10.0') {
143+
testImplementation("com.squareup.okhttp3:mockwebserver:4.10.0") {
150144
because "to control server responses for testing"
151145
}
152146

153147
// Config for our code analytics from: https://github.com/MovingBlocks/TeraConfig
154-
codeMetrics group: 'org.terasology.config', name: 'codemetrics', version: '1.7.1', ext: 'zip'
148+
codeMetrics group: "org.terasology.config", name: "codemetrics", version: "1.7.1", ext: "zip"
155149
}
156150

157151
configurations.matching({ it =~ ~/test(Runtime|Compile|Implementation|PmdAux)Classpath/ }).all {
@@ -161,7 +155,7 @@ configurations.matching({ it =~ ~/test(Runtime|Compile|Implementation|PmdAux)Cla
161155
"spf4j-slf4j-test", "tests use slf4j-test"))
162156

163157
// SPF4J has a dependency on "avro-logical-types-gen:1.3", which does not exist. However, version "1.3p" does.
164-
resolutionStrategy.force('org.spf4j:avro-logical-types-gen:1.3p')
158+
resolutionStrategy.force("org.spf4j:avro-logical-types-gen:1.3p")
165159
// old hamcrest versions exist only to spite us
166160
// http://hamcrest.org/JavaHamcrest/distributables#upgrading-from-hamcrest-1x
167161
exclude group: "org.hamcrest", module: "hamcrest-core"
@@ -178,9 +172,9 @@ compileTestJava.options.encoding = "UTF-8"
178172
javafx {
179173
version = "17.0.2"
180174
modules = [
181-
'javafx.graphics',
182-
'javafx.fxml',
183-
'javafx.web'
175+
"javafx.graphics",
176+
"javafx.fxml",
177+
"javafx.web"
184178
]
185179
}
186180

@@ -209,11 +203,11 @@ pmd {
209203

210204
spotbugs {
211205
ignoreFailures = true
212-
effort = 'max'
213-
reportLevel = 'medium'
206+
effort = "max"
207+
reportLevel = "medium"
214208
}
215209

216-
mainClassName = 'org.terasology.launcher.TerasologyLauncher'
210+
mainClassName = "org.terasology.launcher.TerasologyLauncher"
217211

218212
def convertGitBranch = { gitBranch ->
219213
if (gitBranch != null) {
@@ -225,10 +219,10 @@ def convertGitBranch = { gitBranch ->
225219
}
226220

227221
task createVersionInfoFile {
228-
inputs.property('version', version.toString())
222+
inputs.property("version", version.toString())
229223

230-
File versionInfoFileDir = new File(sourceSets.main.output.resourcesDir, 'org/terasology/launcher/')
231-
File versionFile = new File(versionInfoFileDir, 'version.txt')
224+
File versionInfoFileDir = new File(sourceSets.main.output.resourcesDir, "org/terasology/launcher/")
225+
File versionFile = new File(versionInfoFileDir, "version.txt")
232226

233227
outputs.file(versionFile)
234228

@@ -258,11 +252,11 @@ clean {
258252
processResources.dependsOn(createVersionInfoFile)
259253

260254
jar {
261-
//TODO we only use this name because the `.exe` start scripts require the JAR to be named 'TerasologyLauncher.jar'
255+
//TODO we only use this name because the `.exe` start scripts require the JAR to be named "TerasologyLauncher.jar"
262256
jar.archiveFileName = "${project.name}.jar"
263257
// replace development "logback.xml" with productive "logback_jar.xml"
264258
exclude "logback.xml"
265-
rename('logback_jar.xml', 'logback.xml')
259+
rename("logback_jar.xml", "logback.xml")
266260
manifest {
267261
def manifestClasspath = configurations.runtimeClasspath.collect { it.getName() }.join(" ")
268262
attributes("Main-Class": mainClassName)
@@ -272,50 +266,50 @@ jar {
272266
attributes("SplashScreen-Image": splashImage)
273267

274268
// allow everything
275-
attributes('Permissions': 'all-permissions')
276-
attributes('Codebase': '*')
277-
attributes('Application-Name': project.name)
278-
attributes('Application-Library-Allowable-Codebase': '*')
279-
attributes('Caller-Allowable-Codebase': '*')
280-
attributes('Trusted-Only': 'false')
269+
attributes("Permissions": "all-permissions")
270+
attributes("Codebase": "*")
271+
attributes("Application-Name": project.name)
272+
attributes("Application-Library-Allowable-Codebase": "*")
273+
attributes("Caller-Allowable-Codebase": "*")
274+
attributes("Trusted-Only": "false")
281275
}
282276
}
283277

284278
task copyExtra(type: Copy) {
285279
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance("crlf"))
286280

287-
from('README.md') {
288-
rename('README.md', 'README.txt')
281+
from("README.md") {
282+
rename("README.md", "README.txt")
289283
}
290284

291-
from('CHANGELOG.md') {
292-
rename('CHANGELOG.md', 'CHANGELOG.txt')
285+
from("CHANGELOG.md") {
286+
rename("CHANGELOG.md", "CHANGELOG.txt")
293287
}
294288

295-
from('CONTRIBUTING.md') {
296-
rename('CONTRIBUTING.md', 'CONTRIBUTING.txt')
289+
from("CONTRIBUTING.md") {
290+
rename("CONTRIBUTING.md", "CONTRIBUTING.txt")
297291
}
298292

299-
from('LICENSE')
300-
from('NOTICE')
293+
from("LICENSE")
294+
from("NOTICE")
301295

302296
into "$buildDir/distributions"
303297
}
304298

305299
task copyExtraIntoResources(type: Copy) {
306-
from('README.md')
307-
from('CHANGELOG.md')
308-
from('docs/CONTRIBUTING.md')
309-
from('LICENSE')
300+
from("README.md")
301+
from("CHANGELOG.md")
302+
from("docs/CONTRIBUTING.md")
303+
from("LICENSE")
310304

311-
into('src/main/resources/org/terasology/launcher/about')
305+
into("src/main/resources/org/terasology/launcher/about")
312306
}
313307
processResources.dependsOn copyExtraIntoResources
314308

315309
task copyIconsIntoResources(type: Copy) {
316-
from('icons')
310+
from("icons")
317311

318-
into('src/main/resources/org/terasology/launcher/icons')
312+
into("src/main/resources/org/terasology/launcher/icons")
319313
}
320314
processResources.dependsOn copyIconsIntoResources
321315

@@ -329,7 +323,7 @@ idea {
329323
}
330324
}
331325

332-
tasks.named('wrapper') {
326+
tasks.named("wrapper") {
333327
// IDEA likes this distribution to better know things.
334328
distributionType = Wrapper.DistributionType.ALL
335329
}

buildSrc/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
plugins {
5-
id 'java-gradle-plugin'
6-
id 'groovy'
5+
id("java-gradle-plugin")
6+
id("groovy")
77
}
88

99
repositories {
@@ -17,8 +17,8 @@ dependencies {
1717
gradlePlugin {
1818
plugins {
1919
simplePlugin {
20-
id = 'org.terasology.gradlegoo'
21-
implementationClass = 'org.terasology.gradlegoo.GradleGooPlugin'
20+
id = "org.terasology.gradlegoo"
21+
implementationClass = "org.terasology.gradlegoo.GradleGooPlugin"
2222
}
2323
}
2424
}

0 commit comments

Comments
 (0)