2015-06-09 04:01:23 +00:00
|
|
|
package kcauldron
|
|
|
|
|
|
|
|
import org.gradle.api.DefaultTask
|
|
|
|
import org.gradle.api.GradleException
|
2015-06-16 16:30:52 +00:00
|
|
|
import org.gradle.api.file.ConfigurableFileCollection
|
|
|
|
import org.gradle.api.tasks.*
|
2015-06-09 04:01:23 +00:00
|
|
|
|
|
|
|
class InstallBundle extends DefaultTask {
|
|
|
|
@InputFile
|
2015-06-16 16:30:52 +00:00
|
|
|
def File serverJar
|
|
|
|
|
|
|
|
@InputFiles
|
|
|
|
def ConfigurableFileCollection bootstrapClasspath
|
|
|
|
|
|
|
|
@Input
|
|
|
|
def String bootstrapMain
|
|
|
|
|
|
|
|
InstallBundle() {
|
|
|
|
bootstrapClasspath = project.files()
|
|
|
|
}
|
|
|
|
|
|
|
|
def bootstrapClasspath(Object... args) {
|
|
|
|
bootstrapClasspath.from args
|
|
|
|
}
|
2015-06-09 04:01:23 +00:00
|
|
|
|
|
|
|
@OutputDirectory
|
|
|
|
def File getInstallLocation() {
|
|
|
|
new File(project.buildDir, 'bundle')
|
|
|
|
}
|
|
|
|
|
|
|
|
@TaskAction
|
|
|
|
def install() {
|
|
|
|
installLocation.deleteDir()
|
|
|
|
installLocation.mkdirs()
|
2015-06-16 16:30:52 +00:00
|
|
|
new File(installLocation, "README.txt").withWriter {
|
2017-07-23 02:57:21 +00:00
|
|
|
def String jarPath = 'libraries' << File.separator << (project.group as String).replace('.', File.separator) << File.separator << project.name << File.separator << project.version << File.separator << project.name << '-' << project.version << '.jar'
|
2015-06-16 16:30:52 +00:00
|
|
|
|
|
|
|
it << '''KCauldron installation guide
|
|
|
|
|
|
|
|
# Understanding this bundle
|
|
|
|
You're reading this guide because you're using deprecated installation method
|
|
|
|
If you want use easier & safer method please read about KBootstrap at https://prok.pw/KBootstrap
|
|
|
|
|
|
|
|
# Installation and usage
|
|
|
|
1. Unpack this zip into server directory
|
|
|
|
2. Use following line to start the server:
|
|
|
|
java -jar '''
|
|
|
|
it << jarPath
|
|
|
|
it << '''
|
2015-06-30 16:02:34 +00:00
|
|
|
... or
|
|
|
|
java -jar KCauldron.jar
|
2015-06-16 16:30:52 +00:00
|
|
|
3. That's end, enjoy
|
|
|
|
|
|
|
|
# Why I should use KBootstrap?
|
|
|
|
1. Easiest server installation
|
|
|
|
2. Built-in libraries management
|
|
|
|
3. Update & run server in one line
|
|
|
|
4. Ability to not read this boring guide
|
|
|
|
5. What else?
|
|
|
|
If you are not yet convinced and want to use bundles instead KBootstrap... Meh, this is your choice.
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
def cp = bootstrapClasspath
|
2015-06-09 04:01:23 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2015-06-16 16:30:52 +00:00
|
|
|
def result = project.javaexec { it ->
|
2015-06-09 04:01:23 +00:00
|
|
|
workingDir installLocation
|
2015-06-16 16:30:52 +00:00
|
|
|
classpath cp
|
|
|
|
main bootstrapMain
|
|
|
|
args '--serverDir', installLocation.canonicalPath,
|
2017-07-23 02:57:21 +00:00
|
|
|
'--installServer', serverJar.canonicalFile,
|
|
|
|
'--binDir', 'libraries'
|
2015-06-09 04:01:23 +00:00
|
|
|
}
|
|
|
|
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 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|