From 474ef40d5907f4f2047cb1463f2e50d028850c60 Mon Sep 17 00:00:00 2001 From: Prototik Date: Tue, 9 Jun 2015 11:01:23 +0700 Subject: [PATCH] Make bundle for publishing --- build.gradle | 24 ++++++++- .../groovy/kcauldron/InstallBundle.groovy | 50 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 buildSrc/src/main/groovy/kcauldron/InstallBundle.groovy diff --git a/build.gradle b/build.gradle index 3c272f1..747859b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ import groovy.json.JsonSlurper import kcauldron.CreateChangelog +import kcauldron.InstallBundle buildscript { repositories { @@ -126,10 +127,26 @@ task packageChangelog(type: CreateChangelog) { version = project.version } -task signJars(type: Sign, dependsOn: [packageUniversal, packageInstaller]) { +task installBundle(type: InstallBundle, dependsOn: packageInstaller) { + installer packageInstaller.archivePath +} + +task packageBundle(type: Zip, dependsOn: installBundle) { + onlyIf { project.hasProperty('officialBuild') } + classifier = 'bundle' + from packageInstaller + from packageUniversal + from fileTree(installBundle.installLocation, { + include 'libraries/**' + include 'minecraft_server.*.jar' + }) +} + +task signJars(type: Sign, dependsOn: [packageUniversal, packageInstaller, packageChangelog, packageBundle]) { sign packageInstaller sign packageUniversal sign packageChangelog + sign packageBundle } task preparePublication(dependsOn: signJars) {} @@ -139,10 +156,12 @@ def getSignatureFiles = { def signedServer = allFiles.find { it.name.contains('-server') } def signedInstaller = allFiles.find { it.name.contains('-installer') } def signedChangelog = allFiles.find { it.name.contains('-changelog') } + def signedBundle = allFiles.find { it.name.contains('-bundle') } return [ [archive: signedServer, classifier: 'server', extension: 'jar.asc'], [archive: signedInstaller, classifier: 'installer', extension: 'jar.asc'], - [archive: signedChangelog, classifier: 'changelog', extension: 'txt.asc'] + [archive: signedChangelog, classifier: 'changelog', extension: 'txt.asc'], + [archive: signedBundle, classifier: 'bundle', extension: 'jar.asc'] ] } @@ -169,6 +188,7 @@ publishing { artifact packageUniversal artifact packageInstaller artifact packageChangelog + artifact packageBundle } } } diff --git a/buildSrc/src/main/groovy/kcauldron/InstallBundle.groovy b/buildSrc/src/main/groovy/kcauldron/InstallBundle.groovy new file mode 100644 index 0000000..9a65cf5 --- /dev/null +++ b/buildSrc/src/main/groovy/kcauldron/InstallBundle.groovy @@ -0,0 +1,50 @@ +package kcauldron + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.incremental.IncrementalTaskInputs + +class InstallBundle extends DefaultTask { + @InputFile + def File installer + + @OutputDirectory + def File getInstallLocation() { + new File(project.buildDir, 'bundle') + } + + @TaskAction + def install() { + installLocation.deleteDir() + installLocation.mkdirs() + for (int i = 0; i < 3; i++) { + def result = project.javaexec { + workingDir installLocation + classpath installer + main 'net.minecraftforge.installer.SimpleInstaller' + args '--installServer' + standardOutput new NopOutputStream() + errorOutput new NopOutputStream() + } + if (result.exitValue == 0) return + } + throw new GradleException("Failed to install bundle into ${installLocation}") + } + + private static final class NopOutputStream extends OutputStream { + @Override + void write(byte[] b, int off, int len) throws IOException { + } + + @Override + void write(byte[] b) throws IOException { + } + + @Override + void write(int b) throws IOException { + } + } +}