diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8d2181c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,23 @@ +name: Publish + +on: + push: + branches: [ "*" ] + +permissions: + contents: read + +jobs: + build: + uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main + with: + java: 8 + gradle_tasks: "publish" + artifact_name: "installer" + secrets: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }} + PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }} + PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }} + MAVEN_USER: ${{ secrets.MAVEN_USER }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 0cd09ea..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,85 +0,0 @@ -@Library('forge-shared-library')_ - -pipeline { - agent { - docker { - image 'gradle:jdk8' - args '-v forgegc:/home/gradle/.gradle' - } - } - environment { - GRADLE_ARGS = '--no-daemon --console=plain' - DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook') - DISCORD_PREFIX = "Job: Installer Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}" - JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png' - } - - stages { - stage('notify_start') { - when { - not { - changeRequest() - } - } - steps { - discordSend( - title: "${DISCORD_PREFIX} Started", - successful: true, - result: 'ABORTED', //White border - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - stage('buildandtest') { - steps { - withGradle { - sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build test' - } - script { - gradleVersion(this) - } - } - post { - success { - writeChangelog(currentBuild, 'build/changelog.txt') - } - } - } - stage('publish') { - when { - not { - changeRequest() - } - } - steps { - withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) { - withGradle { - sh './gradlew ${GRADLE_ARGS} publish' - } - } - } - post { - success { - build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote ${env.MYGROUP}:${env.MYARTIFACT} ${env.MYVERSION} latest")], propagate: false, wait: false - } - } - } - } - post { - always { - script { - if (env.CHANGE_ID == null) { // This is unset for non-PRs - discordSend( - title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}", - description: '```\n' + getChanges(currentBuild) + '\n```', - successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"), - result: currentBuild.currentResult, - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - } - } -} \ No newline at end of file diff --git a/LICENSE-header.txt b/LICENSE-header.txt index 18b094b..a43a5e3 100644 --- a/LICENSE-header.txt +++ b/LICENSE-header.txt @@ -1,16 +1,2 @@ -Installer -Copyright (c) 2016-2018. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation version 2.1 -of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Copyright (c) Forge Development LLC +SPDX-License-Identifier: LGPL-2.1-only \ No newline at end of file diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/build.gradle b/build.gradle index d899b8c..27cc733 100644 --- a/build.gradle +++ b/build.gradle @@ -1,189 +1,97 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() - } - dependencies { - classpath 'com.guardsquare:proguard-gradle:7.1.0' - classpath 'net.minecraftforge:GradleUtils:1.+' - } -} +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import net.minecraftforge.gradleutils.PomUtils plugins { - id 'org.cadixdev.licenser' version '0.6.1' - id 'com.github.johnrengelman.shadow' version '7.0.0' - //id 'maven' - id 'maven-publish' id 'java' id 'eclipse' - id 'idea' + id 'maven-publish' + id 'org.cadixdev.licenser' version '0.6.1' + id 'com.github.johnrengelman.shadow' version '8.1.1' + id 'com.github.ben-manes.versions' version '0.49.0' + id 'net.minecraftforge.gradleutils' version '2.+' } -apply plugin: 'net.minecraftforge.gradleutils' + +group = 'net.minecraftforge' +version = gradleutils.tagOffsetVersion +println "Version: $version" repositories { mavenCentral() + maven gradleutils.forgeMaven } -group = 'net.minecraftforge' -archivesBaseName = 'installer' -java.toolchain.languageVersion = JavaLanguageVersion.of(8) - license { - header project.file('LICENSE-header.txt') - include 'net/minecraftforge/installer/**/*.java' - newLine false + header = file('LICENSE-header.txt') + newLine = false } -version = gradleutils.getTagOffsetBranchVersion(null, 'master', 'HEAD', '2.0') -println('Installer Version: ' + version) - -ext { - SPEC_VERSION = gradleutils.gitInfo.tag - MAIN_CLASS = 'net.minecraftforge.installer.SimpleInstaller' - MANIFEST = manifest{ - attributes('Main-Class': MAIN_CLASS) - attributes([ - 'Specification-Title': 'Installer', - 'Specification-Vendor': 'Forge Development LLC', - 'Specification-Version': SPEC_VERSION, - 'Implementation-Title': 'SimpleInstaller', - 'Implementation-Version': project.version, - 'Implementation-Vendor': 'Forge Development LLC' - ] as LinkedHashMap, 'net/minecraftforge/installer/') +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) } -} - -dependencies { - implementation 'net.sf.jopt-simple:jopt-simple:5.0.4' - implementation 'com.google.code.gson:gson:2.8.7' - testImplementation(platform('org.junit:junit-bom:5.7.2')) - testImplementation('org.junit.jupiter:junit-jupiter') + withSourcesJar() } test { useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - } -} - -compileJava { - options.encoding = 'UTF-8' } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - manifest.from(MANIFEST) +dependencies { + implementation(libs.jopt.simple) + implementation(libs.gson) + testImplementation(libs.junit.api) + testRuntimeOnly(libs.bundles.junit.runtime) } -shadowJar { - classifier 'fatjar' - manifest.from(MANIFEST) +tasks.named('jar', Jar).configure { + manifest { + attributes('Main-Class': 'net.minecraftforge.installer.SimpleInstaller') + attributes([ + 'Specification-Title': 'Installer', + 'Specification-Vendor': 'Forge Development LLC', + 'Specification-Version': gradleutils.gitInfo.tag, + 'Implementation-Title': 'SimpleInstaller', + 'Implementation-Vendor': 'Forge Development LLC', + 'Implementation-Version': project.version + ] as LinkedHashMap, 'net/minecraftforge/installer/') + } } -task pgShrinkJar(type: proguard.gradle.ProGuardTask, dependsOn: shadowJar) { - ext { - inputJar = shadowJar.archiveFile.get().asFile - outDir = file("${buildDir}/proguard") - obfuscatedJar = "${outDir}/${jar.archiveBaseName}.jar" - config = 'proguard.pro' - } - inputs.file inputJar - inputs.file config - - outDir.mkdirs() - - injars inputJar - outjars obfuscatedJar - - // Automatically handle the Java version of this build. - if (System.getProperty('java.version').startsWith('1.')) { - // Before Java 9, the runtime classes were packaged in a single jar file. - libraryjars "${System.getProperty('java.home')}/lib/rt.jar" - } else { - // As of Java 9, the runtime classes are packaged in modular jmod files. - libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class' - libraryjars "${System.getProperty('java.home')}/jmods/java.desktop.jmod", jarfilter: '!**.jar', filter: '!module-info.class' - libraryjars "${System.getProperty('java.home')}/jmods/java.logging.jmod", jarfilter: '!**.jar', filter: '!module-info.class' - libraryjars "${System.getProperty('java.home')}/jmods/jdk.unsupported.jmod", jarfilter: '!**.jar', filter: '!module-info.class' - } - configuration config +tasks.named('shadowJar', ShadowJar).configure { + archiveClassifier = 'fatjar' + minimize() } -task shrinkJar(type: Jar, dependsOn: pgShrinkJar) { - classifier = 'shrunk' - from zipTree(pgShrinkJar.obfuscatedJar) - manifest.from(MANIFEST) +compileJava { + options.encoding = 'UTF-8' } artifacts { - //archives shadowJar - archives sourcesJar - archives shrinkJar + archives shadowJar } -jar { - manifest.from(MANIFEST) -} +publishing { + publications.register('mavenJava', MavenPublication) { + from components.java -task testJar(type: Jar, dependsOn: shrinkJar) { - from zipTree(shrinkJar.archiveFile.get().asFile) - from sourceSets.test.output - classifier 'test' - manifest.from(MANIFEST) -} + artifactId = 'installer' -publishing { - publications { - mavenJava(MavenPublication) { - artifact sourcesJar - artifact shrinkJar - artifact jar - pom { - name = project.archivesBaseName - packaging = 'jar' - description = 'Minecraft Forge Installer' - url = 'https://github.com/MinecraftForge/Installer' - - scm { - url = 'https://github.com/MinecraftForge/Installer' - connection = 'scm:git:git://github.com/MinecraftForge/Installer.git' - developerConnection = 'scm:git:git@github.com:MinecraftForge/Installer.git' - } - - issueManagement { - system = 'github' - url = 'https://github.com/MinecraftForge/Installer/issues' - } - - developers { - developer { - id = 'cpw' - name = 'cpw' - } - developer { - id = 'LexManos' - name = 'Lex Manos' - } - } + pom { + name = 'Installer' + description = 'Minecraft Forge Installer' + url = 'https://github.com/MinecraftForge/MergeTool' + + PomUtils.setGitHubDetails(pom, 'Installer') + + license PomUtils.Licenses.LGPLv2_1 + + developers { + developer PomUtils.Developers.LexManos } } } + repositories { - maven { - if (System.env.MAVEN_USER) { - url 'https://maven.minecraftforge.net/' - authentication { - basic(BasicAuthentication) - } - credentials { - username = System.env.MAVEN_USER ?: 'not' - password = System.env.MAVEN_PASSWORD ?: 'set' - } - } else { - url 'file://' + rootProject.file('repo').getAbsolutePath() - } - } + maven gradleutils.publishingForgeMaven } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 05679dc..3fa8f86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 744e882..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,99 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MSYS* | MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/graphic.xcf b/graphic.xcf deleted file mode 100644 index 87a27d0..0000000 Binary files a/graphic.xcf and /dev/null differ diff --git a/settings.gradle b/settings.gradle index e09458c..716ef1c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,31 @@ -rootProject.name = 'installer' +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} + +dependencyResolutionManagement { + versionCatalogs { + libs { + library('gson', 'com.google.code.gson:gson:2.10.1') + library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3') + library('proguard', 'com.guardsquare:proguard-base:7.4.0') + + version('junit', '5.10.1') + library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') + library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') + library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.10.1') + bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher']) + } + } +} + +rootProject.name = 'Installer' diff --git a/src/main/java/net/minecraftforge/installer/DownloadUtils.java b/src/main/java/net/minecraftforge/installer/DownloadUtils.java index 09c0ece..4fcf71e 100644 --- a/src/main/java/net/minecraftforge/installer/DownloadUtils.java +++ b/src/main/java/net/minecraftforge/installer/DownloadUtils.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer; @@ -34,6 +20,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; import net.minecraftforge.installer.actions.ProgressCallback; @@ -295,6 +282,20 @@ public static List getIps(String host) { return null; } + public static boolean checkCertificate(String host) { + try { + HttpURLConnection con = (HttpURLConnection)new URL(host).openConnection(); + con.setRequestMethod("HEAD"); + con.connect(); + return true; + } catch (SSLException e) { + System.out.println("Error checking " + host + ": " + e.getMessage()); + return false; // Something screwed up with the SSL connection, most likely missing root certs. + } catch (IOException e) { + return true; // Something else went wrong, assume the server is down or something, and let it error later down the line. + } + } + public static boolean downloadFileEtag(File target, String url) { try { URLConnection connection = getConnection(url); diff --git a/src/main/java/net/minecraftforge/installer/FixSSL.java b/src/main/java/net/minecraftforge/installer/FixSSL.java deleted file mode 100644 index a54fec8..0000000 --- a/src/main/java/net/minecraftforge/installer/FixSSL.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraftforge.installer; - -import net.minecraftforge.installer.actions.ProgressCallback; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; - - -/** - * Ripped out of forge - modified to work for installer - * - * This class fixes older Java SSL setups which don't contain the correct root certificates to trust Let's Encrypt - * https endpoints. - * - * It uses a secondary JKS keystore: lekeystore.jks, which contains the two root certificate keys as documented here: - * https://letsencrypt.org/certificates/ - * - * To create the keystore, the following commands were run: - *
- *     keytool -import -alias letsencryptisrgx1 -file isrgrootx1.pem -keystore lekeystore.jks -storetype jks -storepass supersecretpassword -v
- *     keytool -import -alias identrustx3 -file identrustx3.pem -keystore lekeystore.jks -storetype jks -storepass supersecretpassword -v
- * 
- * - * The PEM files were obtained from the above URL. - */ -class FixSSL { - - private static boolean hasJavaForDownload(ProgressCallback callback) - { - String javaVersion = System.getProperty("java.version"); - callback.message("Found java version " + javaVersion); - if (javaVersion != null && javaVersion.startsWith("1.8.0_")) { - try { - if (Integer.parseInt(javaVersion.substring("1.8.0_".length())) < 101) - return false; - } catch (NumberFormatException e) { - e.printStackTrace(); - callback.message("Could not parse java version!"); - } - } - return true; - } - - static void fixup(ProgressCallback callback) { - if (hasJavaForDownload(callback)) return; - try { - final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); - Path ksPath = Paths.get(System.getProperty("java.home"),"lib", "security", "cacerts"); - keyStore.load(Files.newInputStream(ksPath), "changeit".toCharArray()); - final Map jdkTrustStore = Collections.list(keyStore.aliases()).stream().collect(Collectors.toMap(a -> a, (String alias) -> { - try { - return keyStore.getCertificate(alias); - } catch (KeyStoreException e) { - throw new UncheckedKeyStoreException(e); - } - })); - - final KeyStore leKS = KeyStore.getInstance(KeyStore.getDefaultType()); - final InputStream leKSFile = FixSSL.class.getResourceAsStream("/lekeystore.jks"); - leKS.load(leKSFile, "supersecretpassword".toCharArray()); - final Map leTrustStore = Collections.list(leKS.aliases()).stream().collect(Collectors.toMap(a -> a, (String alias) -> { - try { - return leKS.getCertificate(alias); - } catch (KeyStoreException e) { - throw new UncheckedKeyStoreException(e); - } - })); - - final KeyStore mergedTrustStore = KeyStore.getInstance(KeyStore.getDefaultType()); - mergedTrustStore.load(null, new char[0]); - for (Map.Entry entry : jdkTrustStore.entrySet()) { - mergedTrustStore.setCertificateEntry(entry.getKey(), entry.getValue()); - } - for (Map.Entry entry : leTrustStore.entrySet()) { - mergedTrustStore.setCertificateEntry(entry.getKey(), entry.getValue()); - } - - final TrustManagerFactory instance = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - instance.init(mergedTrustStore); - final SSLContext tls = SSLContext.getInstance("TLS"); - tls.init(null, instance.getTrustManagers(), null); - HttpsURLConnection.setDefaultSSLSocketFactory(tls.getSocketFactory()); - callback.message("Added Lets Encrypt root certificates as additional trust"); - } catch (UncheckedKeyStoreException | KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException | KeyManagementException e) { - callback.message("Failed to load lets encrypt certificate. Expect problems", ProgressCallback.MessagePriority.HIGH); - e.printStackTrace(); - } - } - - @SuppressWarnings("serial") - private static class UncheckedKeyStoreException extends RuntimeException { - public UncheckedKeyStoreException(Throwable cause) { - super(cause); - } - } -} diff --git a/src/main/java/net/minecraftforge/installer/HashFunction.java b/src/main/java/net/minecraftforge/installer/HashFunction.java index 3fee7ac..b8f3ab2 100644 --- a/src/main/java/net/minecraftforge/installer/HashFunction.java +++ b/src/main/java/net/minecraftforge/installer/HashFunction.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer; diff --git a/src/main/java/net/minecraftforge/installer/InstallerPanel.java b/src/main/java/net/minecraftforge/installer/InstallerPanel.java index 47ab12e..c6af81d 100644 --- a/src/main/java/net/minecraftforge/installer/InstallerPanel.java +++ b/src/main/java/net/minecraftforge/installer/InstallerPanel.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer; @@ -90,6 +76,7 @@ public class InstallerPanel extends JPanel { private final InstallV1 profile; private final File installer; + private final String badCerts; private class FileSelectAction extends AbstractAction { @@ -157,10 +144,11 @@ private BufferedImage getImage(String path, String default_) } } - public InstallerPanel(File targetDir, InstallV1 profile, File installer) + public InstallerPanel(File targetDir, InstallV1 profile, File installer, String badCerts) { this.profile = profile; this.installer = installer; + this.badCerts = badCerts; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); BufferedImage image = getImage(profile.getLogo(), null); @@ -428,7 +416,13 @@ public void run(ProgressCallback monitor) } catch (ActionCanceledException e) { JOptionPane.showMessageDialog(null, "Installation Canceled", "Forge Installer", JOptionPane.WARNING_MESSAGE); } catch (Exception e) { - JOptionPane.showMessageDialog(null, "There was an exception running task: " + e.toString(), "Error", JOptionPane.ERROR_MESSAGE); + String message = "There was an exception running task: " + e.toString(); + if (badCerts != null && !badCerts.isEmpty()) { + message += "
" + + "The following addresse did not have valid certificates: " + badCerts + "
" + + "This typically happens with an outdated java install. Try updating your java install from https://adoptium.net/"; + } + JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } finally { prog.dispose(); diff --git a/src/main/java/net/minecraftforge/installer/ProgressFrame.java b/src/main/java/net/minecraftforge/installer/ProgressFrame.java index f2cbad4..683ed31 100644 --- a/src/main/java/net/minecraftforge/installer/ProgressFrame.java +++ b/src/main/java/net/minecraftforge/installer/ProgressFrame.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer; diff --git a/src/main/java/net/minecraftforge/installer/SimpleInstaller.java b/src/main/java/net/minecraftforge/installer/SimpleInstaller.java index 09ad490..24e9b13 100644 --- a/src/main/java/net/minecraftforge/installer/SimpleInstaller.java +++ b/src/main/java/net/minecraftforge/installer/SimpleInstaller.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer; import java.io.BufferedOutputStream; @@ -102,6 +88,7 @@ public static void main(String[] args) throws IOException, URISyntaxException mirror = optionSet.valueOf(mirrorOption); } + String badCerts = ""; if (optionSet.has(offlineOption)) { DownloadUtils.OFFLINE_MODE = true; @@ -119,7 +106,17 @@ public static void main(String[] args) throws IOException, URISyntaxException }) { monitor.message("Host: " + host + " [" + DownloadUtils.getIps(host).stream().collect(Collectors.joining(", ")) + "]"); } - FixSSL.fixup(monitor); + + for (String host : new String[] { + "https://files.minecraftforge.net/", + "https://launchermeta.mojang.com/" + }) { + if (DownloadUtils.checkCertificate(host)) + continue; + if (!badCerts.isEmpty()) + badCerts += ", "; + badCerts += host; + } } Actions action = null; @@ -136,6 +133,12 @@ public static void main(String[] args) throws IOException, URISyntaxException { try { + if (!badCerts.isEmpty()) + { + monitor.message("Failed to validate certificates for " + badCerts + " this typically means you have an outdated java."); + monitor.message("If instalation fails try updating your java!"); + return; + } SimpleInstaller.headless = true; monitor.message("Target Directory: " + target); InstallV1 install = Util.loadInstallProfile(); @@ -158,7 +161,7 @@ public static void main(String[] args) throws IOException, URISyntaxException } } else - launchGui(monitor, installer); + launchGui(monitor, installer, badCerts); } public static File getMCDir() @@ -173,7 +176,7 @@ else if (osType.contains("mac")) return new File(userHomeDir, mcDir); } - private static void launchGui(ProgressCallback monitor, File installer) + private static void launchGui(ProgressCallback monitor, File installer, String badCerts) { try { @@ -185,7 +188,7 @@ private static void launchGui(ProgressCallback monitor, File installer) try { InstallV1 profile = Util.loadInstallProfile(); - InstallerPanel panel = new InstallerPanel(getMCDir(), profile, installer); + InstallerPanel panel = new InstallerPanel(getMCDir(), profile, installer, badCerts); panel.run(monitor); } catch (Throwable e) { JOptionPane.showMessageDialog(null,"Something went wrong while installing.
Check log for more details:
" + e.toString(), "Error", JOptionPane.ERROR_MESSAGE); diff --git a/src/main/java/net/minecraftforge/installer/actions/Action.java b/src/main/java/net/minecraftforge/installer/actions/Action.java index 953d15e..5fc1f05 100644 --- a/src/main/java/net/minecraftforge/installer/actions/Action.java +++ b/src/main/java/net/minecraftforge/installer/actions/Action.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; diff --git a/src/main/java/net/minecraftforge/installer/actions/ActionCanceledException.java b/src/main/java/net/minecraftforge/installer/actions/ActionCanceledException.java index b100c5c..f654f72 100644 --- a/src/main/java/net/minecraftforge/installer/actions/ActionCanceledException.java +++ b/src/main/java/net/minecraftforge/installer/actions/ActionCanceledException.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; diff --git a/src/main/java/net/minecraftforge/installer/actions/Actions.java b/src/main/java/net/minecraftforge/installer/actions/Actions.java index a6318bf..c6ae59f 100644 --- a/src/main/java/net/minecraftforge/installer/actions/Actions.java +++ b/src/main/java/net/minecraftforge/installer/actions/Actions.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; diff --git a/src/main/java/net/minecraftforge/installer/actions/ClientInstall.java b/src/main/java/net/minecraftforge/installer/actions/ClientInstall.java index 5ca7c93..9399f4a 100644 --- a/src/main/java/net/minecraftforge/installer/actions/ClientInstall.java +++ b/src/main/java/net/minecraftforge/installer/actions/ClientInstall.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; @@ -65,7 +51,7 @@ public boolean run(File target, Predicate optionals, File installer) thr json.getParentFile().mkdirs(); Files.copy(stream, json.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { - error(" Failed to extract"); + error(" Failed to extract launcher profile json " + e.getMessage()); e.printStackTrace(); return false; } diff --git a/src/main/java/net/minecraftforge/installer/actions/ExtractAction.java b/src/main/java/net/minecraftforge/installer/actions/ExtractAction.java index de689c9..08dbf20 100644 --- a/src/main/java/net/minecraftforge/installer/actions/ExtractAction.java +++ b/src/main/java/net/minecraftforge/installer/actions/ExtractAction.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; diff --git a/src/main/java/net/minecraftforge/installer/actions/PostProcessors.java b/src/main/java/net/minecraftforge/installer/actions/PostProcessors.java index 8604438..8cfc60a 100644 --- a/src/main/java/net/minecraftforge/installer/actions/PostProcessors.java +++ b/src/main/java/net/minecraftforge/installer/actions/PostProcessors.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; @@ -36,6 +22,7 @@ import java.util.jar.JarFile; import java.util.stream.Collectors; +import javax.net.ssl.SSLException; import javax.swing.JOptionPane; import net.minecraftforge.installer.DownloadUtils; @@ -226,18 +213,10 @@ public boolean process(File librariesDir, File minecraft, File root, File instal main.invoke(null, (Object)args.toArray(new String[args.size()])); } catch (InvocationTargetException ite) { Throwable e = ite.getCause(); - e.printStackTrace(); - if (e.getMessage() == null) - error("Failed to run processor: " + e.getClass().getName() + "\nSee log for more details."); - else - error("Failed to run processor: " + e.getClass().getName() + ":" + e.getMessage() + "\nSee log for more details."); + handleError(e); return false; } catch (Throwable e) { - e.printStackTrace(); - if (e.getMessage() == null) - error("Failed to run processor: " + e.getClass().getName() + "\nSee log for more details."); - else - error("Failed to run processor: " + e.getClass().getName() + ":" + e.getMessage() + "\nSee log for more details."); + handleError(e); return false; } finally { // Set back to the previous classloader @@ -276,6 +255,25 @@ public boolean process(File librariesDir, File minecraft, File root, File instal } } + private void handleError(Throwable e) { + e.printStackTrace(); + StringBuilder buf = new StringBuilder(); + buf.append("Failed to run processor: ").append(e.getClass().getName()); + if (e.getMessage() != null) + buf.append(':').append(e.getMessage()); + if (e instanceof SSLException) { + buf.append("\nThis is a SSL Exception, this might be caused by you having an outdated java install.") + .append("\nTry updating your java before trying again."); + } + buf.append("\nSee log for more details"); + error(buf.toString()); + if (e.getMessage() == null) + error("Failed to run processor: " + e.getClass().getName() + "\nSee log for more details."); + else + error("Failed to run processor: " + e.getClass().getName() + ":" + e.getMessage() + "\nSee log for more details."); + + } + private void error(String message) { if (!SimpleInstaller.headless) JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); diff --git a/src/main/java/net/minecraftforge/installer/actions/ProgressCallback.java b/src/main/java/net/minecraftforge/installer/actions/ProgressCallback.java index aec235a..bae591e 100644 --- a/src/main/java/net/minecraftforge/installer/actions/ProgressCallback.java +++ b/src/main/java/net/minecraftforge/installer/actions/ProgressCallback.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; diff --git a/src/main/java/net/minecraftforge/installer/actions/ServerInstall.java b/src/main/java/net/minecraftforge/installer/actions/ServerInstall.java index 60ec9b4..8a8cb3b 100644 --- a/src/main/java/net/minecraftforge/installer/actions/ServerInstall.java +++ b/src/main/java/net/minecraftforge/installer/actions/ServerInstall.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.actions; diff --git a/src/main/java/net/minecraftforge/installer/json/Artifact.java b/src/main/java/net/minecraftforge/installer/json/Artifact.java index 4691889..e2d8b0b 100644 --- a/src/main/java/net/minecraftforge/installer/json/Artifact.java +++ b/src/main/java/net/minecraftforge/installer/json/Artifact.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/Install.java b/src/main/java/net/minecraftforge/installer/json/Install.java index 1bc17c4..5c41df2 100644 --- a/src/main/java/net/minecraftforge/installer/json/Install.java +++ b/src/main/java/net/minecraftforge/installer/json/Install.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/InstallV1.java b/src/main/java/net/minecraftforge/installer/json/InstallV1.java index d532d4a..2bdd7c4 100644 --- a/src/main/java/net/minecraftforge/installer/json/InstallV1.java +++ b/src/main/java/net/minecraftforge/installer/json/InstallV1.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/Manifest.java b/src/main/java/net/minecraftforge/installer/json/Manifest.java index afdeb4a..0b95fa5 100644 --- a/src/main/java/net/minecraftforge/installer/json/Manifest.java +++ b/src/main/java/net/minecraftforge/installer/json/Manifest.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/Mirror.java b/src/main/java/net/minecraftforge/installer/json/Mirror.java index 8e5a08a..d9d308d 100644 --- a/src/main/java/net/minecraftforge/installer/json/Mirror.java +++ b/src/main/java/net/minecraftforge/installer/json/Mirror.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/OptionalLibrary.java b/src/main/java/net/minecraftforge/installer/json/OptionalLibrary.java index 8e53e4a..1582508 100644 --- a/src/main/java/net/minecraftforge/installer/json/OptionalLibrary.java +++ b/src/main/java/net/minecraftforge/installer/json/OptionalLibrary.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/Spec.java b/src/main/java/net/minecraftforge/installer/json/Spec.java index 643a3cd..7442546 100644 --- a/src/main/java/net/minecraftforge/installer/json/Spec.java +++ b/src/main/java/net/minecraftforge/installer/json/Spec.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/Util.java b/src/main/java/net/minecraftforge/installer/json/Util.java index e8fe507..fec59fe 100644 --- a/src/main/java/net/minecraftforge/installer/json/Util.java +++ b/src/main/java/net/minecraftforge/installer/json/Util.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/java/net/minecraftforge/installer/json/Version.java b/src/main/java/net/minecraftforge/installer/json/Version.java index 9c50c76..61d81e4 100644 --- a/src/main/java/net/minecraftforge/installer/json/Version.java +++ b/src/main/java/net/minecraftforge/installer/json/Version.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.json; diff --git a/src/main/resources/lekeystore.jks b/src/main/resources/lekeystore.jks deleted file mode 100644 index 12749d7..0000000 Binary files a/src/main/resources/lekeystore.jks and /dev/null differ diff --git a/src/test/java/net/minecraftforge/installer/test/TestTokens.java b/src/test/java/net/minecraftforge/installer/test/TestTokens.java index 991dfad..36b121a 100644 --- a/src/test/java/net/minecraftforge/installer/test/TestTokens.java +++ b/src/test/java/net/minecraftforge/installer/test/TestTokens.java @@ -1,20 +1,6 @@ /* - * Installer - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.installer.test;