Skip to content

Commit e14bf7a

Browse files
authored
Update build setup to Gradle 9.4.1 (#82)
1 parent 8e00b22 commit e14bf7a

File tree

15 files changed

+85
-67
lines changed

15 files changed

+85
-67
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
gradle.properties
21
bin/
32
.gradle/
43
repos/

build.gradle

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22

3+
import java.nio.file.Files
4+
import java.nio.file.Paths
5+
36
plugins {
47
id 'java'
58
id 'eclipse'
69
id 'maven-publish'
7-
id 'com.github.johnrengelman.shadow' version '8.1.1'
8-
id 'com.github.ben-manes.versions' version '0.49.0'
9-
id 'net.minecraftforge.licenser' version '1.0.1'
10-
id 'net.minecraftforge.gradleutils' version '[2.3,2.4)'
10+
id 'com.gradleup.shadow' version '9.4.1'
11+
id 'net.minecraftforge.gitversion' version '3.1.7'
12+
id 'net.minecraftforge.licenser' version '1.2.0'
13+
id 'net.minecraftforge.gradleutils' version '3.4.4'
14+
id 'net.minecraftforge.changelog' version '3.2.1'
1115
}
1216

17+
gradleutils.displayName = 'Installer'
1318
group = 'net.minecraftforge'
14-
version = gradleutils.tagOffsetVersion
19+
version = gitversion.tagOffset
1520
println "Version: $version"
1621

1722
repositories {
@@ -25,9 +30,7 @@ license {
2530
}
2631

2732
java {
28-
toolchain {
29-
languageVersion = JavaLanguageVersion.of(8)
30-
}
33+
toolchain.languageVersion = JavaLanguageVersion.of(8)
3134
withSourcesJar()
3235
}
3336

@@ -42,34 +45,36 @@ dependencies {
4245
testRuntimeOnly(libs.bundles.junit.runtime)
4346
}
4447

45-
46-
def installerFiles = new FileNameFinder().getFileNames(projectDir.absolutePath, '*-installer.jar')
47-
if (!installerFiles.isEmpty()) {
48-
def first = file(installerFiles.get(0))
49-
logger.lifecycle("Detected test installer: " + first.name)
50-
dependencies.implementation(files(first))
51-
}
52-
53-
tasks.named('jar', Jar).configure {
48+
Files.list(Paths.get(projectDir.absolutePath))
49+
.filter(Files::isRegularFile)
50+
.filter(path -> path.getFileName().toString().endsWith('-installer.jar'))
51+
.findFirst()
52+
.ifPresent(path -> {
53+
var firstFile = path.toFile()
54+
logger.lifecycle("Detected test installer: ${firstFile.name}")
55+
dependencies.implementation(files(firstFile))
56+
})
57+
58+
tasks.named('jar', Jar) {
5459
manifest {
5560
attributes('Main-Class': 'net.minecraftforge.installer.SimpleInstaller')
5661
attributes([
5762
'Specification-Title': 'Installer',
5863
'Specification-Vendor': 'Forge Development LLC',
59-
'Specification-Version': gradleutils.gitInfo.tag,
64+
'Specification-Version': gitversion.info.tag,
6065
'Implementation-Title': 'SimpleInstaller',
6166
'Implementation-Vendor': 'Forge Development LLC',
6267
'Implementation-Version': project.version
6368
] as LinkedHashMap, 'net/minecraftforge/installer/')
6469
}
6570
}
6671

67-
tasks.named('shadowJar', ShadowJar).configure {
72+
tasks.named('shadowJar', ShadowJar) {
6873
archiveClassifier = 'fatjar'
6974
minimize()
7075
}
7176

72-
compileJava {
77+
tasks.withType(JavaCompile).configureEach {
7378
options.encoding = 'UTF-8'
7479
}
7580

@@ -83,6 +88,9 @@ changelog {
8388

8489
publishing {
8590
publications.register('mavenJava', MavenPublication) {
91+
changelog.publish(it)
92+
gradleutils.promote(it)
93+
8694
from components.java
8795

8896
artifactId = 'installer'
@@ -92,12 +100,12 @@ publishing {
92100
description = 'Minecraft Forge Installer'
93101
url = 'https://github.com/MinecraftForge/Installer'
94102

95-
gradleutils.pom.setGitHubDetails(pom, 'Installer')
103+
gradleutils.pom.addRemoteDetails(pom)
96104

97105
license gradleutils.pom.licenses.LGPLv2_1
98106

99107
developers {
100-
developer gradleutils.pom.Developers.LexManos
108+
developer gradleutils.pom.developers.LexManos
101109
}
102110
}
103111
}

file_publisher.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.transform.CompileStatic
2+
13
import java.security.MessageDigest
24
import java.net.URL
35

@@ -8,16 +10,19 @@ repositories {
810
maven { url = 'https://libraries.minecraft.net/' }
911
}
1012

11-
def sha1(file) {
13+
@CompileStatic
14+
static String sha1(File file) {
1215
MessageDigest md = MessageDigest.getInstance('SHA-1')
13-
file.eachByte 4096, {bytes, size ->
16+
file.eachByte 4096, { bytes, size ->
1417
md.update(bytes, 0, size)
1518
}
1619
return md.digest().collect {String.format "%02x", it}.join()
1720
}
18-
def md5(file) {
21+
22+
@CompileStatic
23+
static String md5(File file) {
1924
MessageDigest md = MessageDigest.getInstance('MD5')
20-
file.eachByte 4096, {bytes, size ->
25+
file.eachByte 4096, { bytes, size ->
2126
md.update(bytes, 0, size)
2227
}
2328
return md.digest().collect {String.format "%02x", it}.join()
@@ -77,7 +82,7 @@ def artifactTree(repo, artifact, transitive) {
7782
}
7883
}
7984

80-
def checkExists(url) {
85+
boolean checkExists(String url) {
8186
def code = new URL(url).openConnection().with {
8287
requestMethod = 'HEAD'
8388
connect()
@@ -86,11 +91,11 @@ def checkExists(url) {
8691
return code == 200
8792
}
8893
//TODO: Make Forge's build explode if a file is missing from our repo
89-
task artifacts() {
94+
tasks.register('artifacts') {
9095
doLast {
9196
file('dep_repo').deleteDir()
9297
[
9398
'com.google.code.findbugs:jsr305:3.0.1'
9499
].forEach{art -> artifactTree('dep_repo', art, false)}
95100
}
96-
}
101+
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.configuration-cache=true
2+
org.gradle.configuration-cache.problems=warn

gradle/wrapper/gradle-wrapper.jar

-17.1 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ pluginManagement {
99
}
1010

1111
plugins {
12-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
12+
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
1313
}
1414

1515
dependencyResolutionManagement {
1616
versionCatalogs {
1717
libs {
18-
library('gson', 'com.google.code.gson:gson:2.10.1')
18+
library('gson', 'com.google.code.gson:gson:2.13.2')
1919
library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3')
2020

2121
version('junit', '5.10.1')

src/main/java/net/minecraftforge/installer/DownloadUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private static boolean download(ProgressCallback monitor, Mirror mirror, Downloa
199199

200200
public static String getSha1(File target) {
201201
try {
202-
return HashFunction.SHA1.hash(Files.readAllBytes(target.toPath())).toString();
202+
return HashFunction.SHA1.hash(Files.readAllBytes(target.toPath()));
203203
} catch (IOException e) {
204204
e.printStackTrace();
205205
return null;

0 commit comments

Comments
 (0)