2 changed files with 72 additions and 2 deletions
@ -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 { |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue