Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
gradle.properties
bin/
.gradle/
repos/
Expand Down
52 changes: 30 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

import java.nio.file.Files
import java.nio.file.Paths

plugins {
id 'java'
id 'eclipse'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.github.ben-manes.versions' version '0.49.0'
id 'net.minecraftforge.licenser' version '1.0.1'
id 'net.minecraftforge.gradleutils' version '[2.3,2.4)'
id 'com.gradleup.shadow' version '9.4.1'
id 'net.minecraftforge.gitversion' version '3.1.7'
id 'net.minecraftforge.licenser' version '1.2.0'
id 'net.minecraftforge.gradleutils' version '3.4.4'
id 'net.minecraftforge.changelog' version '3.2.1'
}

gradleutils.displayName = 'Installer'
group = 'net.minecraftforge'
version = gradleutils.tagOffsetVersion
version = gitversion.tagOffset
println "Version: $version"

repositories {
Expand All @@ -25,9 +30,7 @@ license {
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
toolchain.languageVersion = JavaLanguageVersion.of(8)
withSourcesJar()
}

Expand All @@ -42,34 +45,36 @@ dependencies {
testRuntimeOnly(libs.bundles.junit.runtime)
}


def installerFiles = new FileNameFinder().getFileNames(projectDir.absolutePath, '*-installer.jar')
if (!installerFiles.isEmpty()) {
def first = file(installerFiles.get(0))
logger.lifecycle("Detected test installer: " + first.name)
dependencies.implementation(files(first))
}

tasks.named('jar', Jar).configure {
Files.list(Paths.get(projectDir.absolutePath))
.filter(Files::isRegularFile)
.filter(path -> path.getFileName().toString().endsWith('-installer.jar'))
.findFirst()
.ifPresent(path -> {
var firstFile = path.toFile()
logger.lifecycle("Detected test installer: ${firstFile.name}")
dependencies.implementation(files(firstFile))
})

tasks.named('jar', Jar) {
manifest {
attributes('Main-Class': 'net.minecraftforge.installer.SimpleInstaller')
attributes([
'Specification-Title': 'Installer',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': gradleutils.gitInfo.tag,
'Specification-Version': gitversion.info.tag,
'Implementation-Title': 'SimpleInstaller',
'Implementation-Vendor': 'Forge Development LLC',
'Implementation-Version': project.version
] as LinkedHashMap, 'net/minecraftforge/installer/')
}
}

tasks.named('shadowJar', ShadowJar).configure {
tasks.named('shadowJar', ShadowJar) {
archiveClassifier = 'fatjar'
minimize()
}

compileJava {
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

Expand All @@ -83,6 +88,9 @@ changelog {

publishing {
publications.register('mavenJava', MavenPublication) {
changelog.publish(it)
gradleutils.promote(it)

from components.java

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

gradleutils.pom.setGitHubDetails(pom, 'Installer')
gradleutils.pom.addRemoteDetails(pom)

license gradleutils.pom.licenses.LGPLv2_1

developers {
developer gradleutils.pom.Developers.LexManos
developer gradleutils.pom.developers.LexManos
}
}
}
Expand Down
19 changes: 12 additions & 7 deletions file_publisher.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.transform.CompileStatic

import java.security.MessageDigest
import java.net.URL

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

def sha1(file) {
@CompileStatic
static String sha1(File file) {
MessageDigest md = MessageDigest.getInstance('SHA-1')
file.eachByte 4096, {bytes, size ->
file.eachByte 4096, { bytes, size ->
md.update(bytes, 0, size)
}
return md.digest().collect {String.format "%02x", it}.join()
}
def md5(file) {

@CompileStatic
static String md5(File file) {
MessageDigest md = MessageDigest.getInstance('MD5')
file.eachByte 4096, {bytes, size ->
file.eachByte 4096, { bytes, size ->
md.update(bytes, 0, size)
}
return md.digest().collect {String.format "%02x", it}.join()
Expand Down Expand Up @@ -77,7 +82,7 @@ def artifactTree(repo, artifact, transitive) {
}
}

def checkExists(url) {
boolean checkExists(String url) {
def code = new URL(url).openConnection().with {
requestMethod = 'HEAD'
connect()
Expand All @@ -86,11 +91,11 @@ def checkExists(url) {
return code == 200
}
//TODO: Make Forge's build explode if a file is missing from our repo
task artifacts() {
tasks.register('artifacts') {
doLast {
file('dep_repo').deleteDir()
[
'com.google.code.findbugs:jsr305:3.0.1'
].forEach{art -> artifactTree('dep_repo', art, false)}
}
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
15 changes: 7 additions & 8 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ pluginManagement {
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}

dependencyResolutionManagement {
versionCatalogs {
libs {
library('gson', 'com.google.code.gson:gson:2.10.1')
library('gson', 'com.google.code.gson:gson:2.13.2')
library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3')

version('junit', '5.10.1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private static boolean download(ProgressCallback monitor, Mirror mirror, Downloa

public static String getSha1(File target) {
try {
return HashFunction.SHA1.hash(Files.readAllBytes(target.toPath())).toString();
return HashFunction.SHA1.hash(Files.readAllBytes(target.toPath()));
} catch (IOException e) {
e.printStackTrace();
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/minecraftforge/installer/HashFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public enum HashFunction {
SHA1("SHA-1", 40),
SHA256("SHA-256", 64);

private String algo;
private String pad;
private final String algo;
private final String pad;

private HashFunction(String algo, int length) {
this.algo = algo;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/minecraftforge/installer/InstallerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ public InstallerPanel(File targetDir, InstallV1 profile, File installer, String
this.targetDir = targetDir;
selectedDirText = new JTextField();
selectedDirText.setEditable(false);
selectedDirText.setToolTipText("Path to minecraft");
selectedDirText.setToolTipText("Path to Minecraft");
selectedDirText.setColumns(30);
// homeDir.setMaximumSize(homeDir.getPreferredSize());
entryPanel.add(selectedDirText);
JButton dirSelect = new JButton();
dirSelect.setAction(new FileSelectAction());
dirSelect.setText("...");
dirSelect.setToolTipText("Select an alternative minecraft directory");
dirSelect.setToolTipText("Select an alternative Minecraft directory");
entryPanel.add(dirSelect);

entryPanel.setAlignmentX(LEFT_ALIGNMENT);
Expand Down Expand Up @@ -215,7 +215,7 @@ private void updateFilePath() {
targetDir = targetDir.getCanonicalFile();
selectedDirText.setText(targetDir.getPath());
} catch (IOException e) {
System.out.println("Failed to make cononical file: " + targetDir);
System.out.println("Failed to make canonical file: " + targetDir);
e.printStackTrace();
}

Expand Down Expand Up @@ -281,8 +281,8 @@ public void run(ProgressCallback monitor) {
String message = "There was an exception running task: " + e.toString();
if (badCerts != null && !badCerts.isEmpty()) {
message += "<br>" +
"The following addresse did not have valid certificates: " + badCerts + "<br>" +
"This typically happens with an outdated java install. Try updating your java install from https://adoptium.net/";
"The following address did not have valid certificates: " + badCerts + "<br>" +
"This typically happens with an outdated Java install. Try updating your Java install from https://adoptium.net/";
}
JOptionPane.showOptionDialog(null, message, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, new Object[]{"Ok", SwingUtil.createLogButton()}, "");
e.printStackTrace();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/minecraftforge/installer/SwingUtil.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) Forge Development LLC
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.installer;

import javax.swing.*;
Expand Down
Loading