This commit is contained in:
huangyuhui 2017-02-19 16:30:27 +08:00
parent fa5ff14ff1
commit 445367532a
18 changed files with 86 additions and 151 deletions

View File

@ -3,28 +3,24 @@ jdk:
- oraclejdk8
branches:
only:
- master
- master
before_deploy:
- git config --global user.email ${GITHUB_EMAIL}
- git config --global user.name ${GITHUB_NAME}
- git tag ${TRAVIS_BUILD_NUMBER}
- git push -q ${REPO} --tags
- git config --global user.email ${GITHUB_EMAIL}
- git config --global user.name ${GITHUB_NAME}
- git tag ${TRAVIS_BUILD_NUMBER}
- git push -q ${REPO} --tags
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: T3u0BqnXQ1MYMNdNdT+SNGYWGyPivrZMKnUIbWPZQGs001kq18BpC5WLabhH4+EfZ1P9j1hRHLUHsEP7QDjPeNPEtWFLNq51z+vPKx18eb6d0yUHHCWHGknP8NXWF7+buaQKZeJ05AzwkegnADumUOm+mqY249KSnlt0gFRaTWIAXUY8KOZP32Rq+pCE1yS7GsO7se27HtQw31qB9TEyEQYMU00pY/THqV4wHvO+9QHyFiv9MtbuTX+e4PEdA/xQpPv8qMX9BegppzX+Vz9Lughe77XWWJuOTqlcwqbj6M2Dao1KIlE4fzBN0zgdIApmATDzVdx7vthZdIFip2eRODlw9YKz0lX+gj8cuDw5uUZ4JTw5P5mkH9X0EDTv3h2nQw2A0qkYy3MGFhsSIwLJBeDkKQrUa/pylsPaYNwQUCegM3Sj/2wdN2IcllDUs7p5OOf4yhGRUUYR1JTocsZ3XcyzVlOsBXO2RJs9E6DqY9KUiEZG4NlQEo0DpYQrHR15r2Qhv8WmmxPaqBOO6wv21IpLsmf1t54PHIoBeVUI2qvjKuOBWX6XrljFL5iIYhIAmgjigggUmetJRNp1qbJQYBk6tSpsosMDnXEFHxtJXnomcpiZj0pbGGjWFREHxIDBqh0uLPk+NyD5RnI2+nVladEXoSdWnQCfQ4dYZy73bdI=
file:
- HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
secure: KxGIpE83MsgSdWNwCyqgIKJevZgLAef3hpBEVZjqZ09mA3JjQzWCbVFEfWpv8yRqe8ue7YF0aH7YoWuqOiE9q93Qsvv3GRtVcnZqZiGZbCZer1ShtqcjSseMvsw66dtHNcdK6onHna+OrCh2TQjxE2tKMf3CPCP9K2RI6dYOTyYUWmiOmiYQfcd2MEGSRXdnCGi8nf5oBZOYfHforRH3QYJXA7AxI+I9xaEWimFKs1c73sE1pypIGw5rlc+tiKuG8f5QoMeEOy+D30Qe3Vlre13RTi73r6GVt1ZoRpAwlNLEgjD393V1mxGd9wYNBMRKIZ/dfvIAN4m/jltVpgSyuCiUj3sjNs39HV8Jk0ki6RoSoAsjIyWHWfag946sk5wuBjnIZajlQhpGoc94ml8ujxOqP0npQT8azm3CwkAmBx0cxQ09Td9WPREk9BL4bWZrp5t50PsB9SZHPV2ET98QQH6+ArldONYWDTNZMJ2Lc0s6rFZoInq2px1srbR7Cxq2rNsVRp15UFvQp5xueONXz68/wFet6Gbm2ob8TGKm1bQOh5MRO/fq+fkrIIjoD6ztlRaO3xtePXlyEbnJmyxXOdA+Rd9WFXsT9gzjKtlxQjdHZNnI0YiEjR2qvHIWguAQtuV4pydWi8VtlBQ2gT37CpF4ApfC6jTfMsEwqZZ29YM=
file: HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar
- HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
- HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}-MacOSApp.zip
on:
repo: huanghongxun/HMCL
tags: false
skip_cleanup: true
install: echo "skip 'gradle assemble' step"
script: gradle build --continue --info --stacktrace
script: "./gradlew clean build --stacktrace"
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/caches/"

View File

@ -15,25 +15,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
buildscript {
repositories {
mavenCentral();
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
}
import java.util.jar.JarFile
import java.util.jar.Pack200
import java.util.zip.GZIPOutputStream
import java.security.MessageDigest
plugins {
//id "edu.sc.seis.macAppBundle" version "2.1.6"
//id "me.tatarka.retrolambda" version "3.5.0"
id "me.tatarka.retrolambda" version "3.5.0"
id 'edu.sc.seis.launch4j' version '2.3.0'
}
apply plugin: 'me.tatarka.retrolambda'
import java.util.jar.JarOutputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
@ -61,7 +52,7 @@ version = mavenVersion
String mavenArtifactId = name
task generateSources(type: Copy) {
task generateSources(type: Sync) {
from 'src/main/java'
into "$buildDir/generated-src"
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
@ -71,19 +62,6 @@ task generateSources(type: Copy) {
compileJava.setSource "$buildDir/generated-src"
compileJava.dependsOn generateSources
/*task macAppCompressed(type: Zip, dependsOn: createApp) {
archiveName "HMCL-$mavenVersion-MacOSApp.zip"
include '**'
destinationDir file("$buildDir/libs/")
from "$buildDir/macApp"
}
macAppBundle {
mainClassName = mainClass
icon = "src/main/icon.icns"
javaProperties.put("apple.laf.useScreenMenuBar", "true")
}*/
configurations {
coreCompile.extendsFrom compile
coreRuntime.extendsFrom runtime
@ -124,7 +102,7 @@ launch4j {
icon = new File(project.buildDir, '../icon.ico').absolutePath
version = mavenVersion
downloadUrl = 'http://java.com/download'
copyright = "Copyright(c) 2013-2015 huangyuhui."
copyright = "Copyright(c) 2013-2017 huangyuhui."
jar = new File(project.buildDir, 'libs/' + mavenGroupId + '-' + mavenVersion + '.jar').absolutePath
outfile = mavenGroupId + '-' + mavenVersion + '.exe'
@ -137,6 +115,51 @@ processResources {
}
}
task makeExecutable(dependsOn: jar) << {
ext {
jar.classifier = ''
makeExecutableinjar = jar.archivePath
jar.classifier = ''
makeExecutableoutjar = jar.archivePath
jar.classifier = ''
}
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".exe")
def fos = new FileOutputStream(loc)
def is = new FileInputStream(new File(project.buildDir, '../HMCLauncher.exe'))
int read
def bytes = new byte[8192]
while((read = is.read(bytes)) != -1)
fos.write(bytes, 0, read);
is.close()
is = new FileInputStream(makeExecutableinjar)
while((read = is.read(bytes)) != -1)
fos.write(bytes, 0, read);
is.close()
fos.close()
}
task makePackGZ(dependsOn: jar) << {
ext {
jar.classifier = ''
makeExecutableinjar = jar.archivePath
jar.classifier = ''
makeExecutableoutjar = jar.archivePath
jar.classifier = ''
}
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".pack.gz")
def os = new GZIPOutputStream(new FileOutputStream(loc))
Pack200.newPacker().pack new JarFile(makeExecutableinjar), os
os.close()
def messageDigest = MessageDigest.getInstance("SHA1")
loc.eachByte 1024 * 1024, { byte[] buf, int bytesRead ->
messageDigest.update(buf, 0, bytesRead);
}
def sha1Hex = new BigInteger(1, messageDigest.digest()).toString(16).padLeft(40, '0')
def fileEx = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".pack.gz.sha1")
if (!fileEx.exists()) fileEx.createNewFile()
fileEx.append sha1Hex
}
build.dependsOn makeExecutable
build.dependsOn makePackGZ
//build.dependsOn macAppCompressed
build.dependsOn makePackGZ

View File

@ -141,7 +141,7 @@ public final class Main implements Runnable {
Thread.setDefaultUncaughtExceptionHandler(new CrashReporter(true));
try {
File file = new File("hmcl.log");
File file = new File("hmcl.log").getAbsoluteFile();
if (!file.exists() && !file.createNewFile())
LOGGER.log(Level.WARNING, "Failed to create log file {0}", file);
Configuration.DEFAULT.appenders.add(new ConsoleAppender("File", new DefaultLayout(), true, new FileOutputStream(file), true));

View File

@ -44,7 +44,7 @@ public final class Settings {
public static final String DEFAULT_PROFILE = "Default";
public static final String HOME_PROFILE = "Home";
public static final File SETTINGS_FILE = new File("hmcl.json");
public static final File SETTINGS_FILE = new File("hmcl.json").getAbsoluteFile();
private static final Config SETTINGS;
public static final UpdateChecker UPDATE_CHECKER = new UpdateChecker(HMCLApi.HMCL_VERSION, "hmcl");

View File

@ -988,7 +988,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
}// </editor-fold>//GEN-END:initComponents
private void btnIncludeMinecraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIncludeMinecraftActionPerformed
JSystemFileChooser fc = new JSystemFileChooser(new File("."));
JSystemFileChooser fc = new JSystemFileChooser(new File("").getAbsoluteFile());
fc.setFileSelectionMode(JSystemFileChooser.DIRECTORIES_ONLY);
if (fc.showOpenDialog(this) == JSystemFileChooser.APPROVE_OPTION) {
File newGameDir = fc.getSelectedFile();

View File

@ -121,13 +121,13 @@ public class ModpackWizard extends WizardBranchController {
s.setDownloadType(Settings.getInstance().getDownloadType());
engine.putTextFile(C.GSON.toJson(s), "hmcl.json");
engine.putFile(modpack, "modpack.zip");
File bg = new File("bg");
File bg = new File("bg").getAbsoluteFile();
if (bg.isDirectory())
engine.putDirectory(bg);
bg = new File("background.png");
bg = new File("background.png").getAbsoluteFile();
if (bg.isFile())
engine.putFile(bg, "background.png");
bg = new File("background.jpg");
bg = new File("background.jpg").getAbsoluteFile();
if (bg.isFile())
engine.putFile(bg, "background.jpg");
for (URL u : Utils.getURL())

View File

@ -67,7 +67,7 @@ public class HMCLMinecraftService extends IMinecraftService {
if (!checkingModpack) {
checkingModpack = true;
if (version().getVersionCount() == 0) {
File modpack = new File("modpack.zip");
File modpack = new File("modpack.zip").getAbsoluteFile();
if (modpack.exists())
SwingUtilities.invokeLater(() -> {
if (TaskWindow.factory().execute(ModpackManager.install(MainFrame.INSTANCE, modpack, this, null)))

View File

@ -109,7 +109,7 @@ public class AppDataUpgrader extends IUpgrader {
if (map.containsKey("packsha1"))
hash = map.get("packsha1");
if (TaskWindow.factory().append(new AppDataUpgraderTask(map.get("pack"), version.version, hash)).execute()) {
new ProcessBuilder(new String[] { IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(version.version).getAbsolutePath() }).directory(new File(".")).start();
new ProcessBuilder(new String[] { IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(version.version).getAbsolutePath() }).directory(new File("").getAbsoluteFile()).start();
System.exit(0);
}
} catch (IOException ex) {

View File

@ -50,7 +50,7 @@ public class NewFileUpgrader extends IUpgrader {
File newf = new File(FileUtils.getName(str));
if (TaskWindow.factory().append(new FileDownloadTask(str, newf)).execute()) {
try {
new ProcessBuilder(new String[] { newf.getCanonicalPath(), "--removeOldLauncher", IOUtils.getRealPath() }).directory(new File(".")).start();
new ProcessBuilder(new String[] { newf.getCanonicalPath(), "--removeOldLauncher", IOUtils.getRealPath() }).directory(new File("").getAbsoluteFile()).start();
} catch (IOException ex) {
HMCLog.err("Failed to start new app", ex);
}

View File

@ -16,18 +16,10 @@
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
buildscript {
repositories {
mavenCentral();
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
plugins {
id "me.tatarka.retrolambda" version "3.5.0"
}
apply plugin: 'me.tatarka.retrolambda'
if (System.getenv("BUILD_NUMBER") != null)
version = System.getenv("BUILD_NUMBER")

View File

@ -37,7 +37,7 @@ import org.jackhuang.hmcl.api.func.Consumer;
*/
public class PluginManager {
private static final File PLUGINS_FILE = new File("plugins/");
private static final File PLUGINS_FILE = new File("plugins").getAbsoluteFile();
private static final ArrayList<IPlugin> PLUGINS = new ArrayList<>();
public static void getPlugin(Class<?> cls) {

View File

@ -16,18 +16,10 @@
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
buildscript {
repositories {
mavenCentral();
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
plugins {
id "me.tatarka.retrolambda" version "3.5.0"
}
apply plugin: 'me.tatarka.retrolambda'
if (System.getenv("BUILD_NUMBER") != null)
version = System.getenv("BUILD_NUMBER")

View File

@ -56,7 +56,7 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
@Override
public Task downloadForge(String installId, InstallerVersion v) {
File filepath = new File("forge-installer.jar");
File filepath = new File("forge-installer.jar").getAbsoluteFile();
if (v.installer == null)
return null;
else
@ -67,7 +67,7 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
@Override
public Task downloadOptiFine(String installId, InstallerVersion v) {
File filepath = new File("optifine-installer.jar");
File filepath = new File("optifine-installer.jar").getAbsoluteFile();
if (v.installer == null)
return null;
OptiFineDownloadFormatter task = new OptiFineDownloadFormatter(v.installer);
@ -80,7 +80,7 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
public Task downloadLiteLoader(String installId, InstallerVersion v) {
if (!(v instanceof LiteLoaderInstallerVersion))
throw new Error("Download lite loader but the version is not ll's.");
File filepath = new File("liteloader-universal.jar");
File filepath = new File("liteloader-universal.jar").getAbsoluteFile();
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
return task.with(new LiteLoaderInstaller(service, installId, (LiteLoaderInstallerVersion) v).registerPreviousResult(task))
.with(new DeleteFileTask(filepath));

View File

@ -16,18 +16,10 @@
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
buildscript {
repositories {
mavenCentral();
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
plugins {
id "me.tatarka.retrolambda" version "3.5.0"
}
apply plugin: 'me.tatarka.retrolambda'
if (System.getenv("BUILD_NUMBER") != null)
version = System.getenv("BUILD_NUMBER")

View File

@ -15,25 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
import java.util.jar.JarFile
import java.util.jar.Pack200
import java.util.zip.GZIPOutputStream
import java.security.MessageDigest
repositories {
mavenCentral();
}
buildscript {
repositories {
mavenCentral();
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
}
apply plugin: 'java'
apply plugin: 'maven'
@ -60,50 +46,4 @@ task createFolders(description: 'Creates the source folders if they do not exist
srcDir.mkdirs()
}
}
}
task makeExecutable(dependsOn: jar) << {
ext {
jar.classifier = ''
makeExecutableinjar = jar.archivePath
jar.classifier = ''
makeExecutableoutjar = jar.archivePath
jar.classifier = ''
}
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".exe")
def fos = new FileOutputStream(loc)
def is = new FileInputStream(new File(project.buildDir, '../HMCLauncher.exe'))
int read
def bytes = new byte[8192]
while((read = is.read(bytes)) != -1)
fos.write(bytes, 0, read);
is.close()
is = new FileInputStream(makeExecutableinjar)
while((read = is.read(bytes)) != -1)
fos.write(bytes, 0, read);
is.close()
fos.close()
}
task makePackGZ(dependsOn: jar) << {
ext {
jar.classifier = ''
makeExecutableinjar = jar.archivePath
jar.classifier = ''
makeExecutableoutjar = jar.archivePath
jar.classifier = ''
}
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".pack.gz")
def os = new GZIPOutputStream(new FileOutputStream(loc))
Pack200.newPacker().pack new JarFile(makeExecutableinjar), os
os.close()
def messageDigest = MessageDigest.getInstance("SHA1")
loc.eachByte 1024 * 1024, { byte[] buf, int bytesRead ->
messageDigest.update(buf, 0, bytesRead);
}
def sha1Hex = new BigInteger(1, messageDigest.digest()).toString(16).padLeft(40, '0')
def fileEx = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".pack.gz.sha1")
if (!fileEx.exists()) fileEx.createNewFile()
fileEx.append sha1Hex
}

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-bin.zip

2
gradlew vendored
View File

@ -7,7 +7,7 @@
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=1080 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1080"
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

2
gradlew.bat vendored
View File

@ -9,7 +9,7 @@
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=1080 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1080
set DEFAULT_JVM_OPTS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=1080 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1080"
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.