distTarタスク用にgradleが生成する開始スクリプトを変更する必要があります。私はseem to be able to set unixStartScriptGenerator.templateを以下に示しますが、tarからスクリプトをアンパックすると、私の変更はそこにはありません。distStarがbuild.gradleでカスタムテンプレートファイルを使用するように、createStartScriptsタスクでunixStartScriptGenerator.templateを変更するにはどうすればよいですか?
これは私のbuild.gradle
いっぱい:
apply plugin: 'java'
apply plugin: 'war'
// to use the main method in Main, which uses Jetty
apply plugin: 'application'
mainClassName = 'com.example.Main'
project.version = '2017.0.0.0'
repositories {
mavenLocal()
mavenCentral()
}
task createStartScripts(type: CreateStartScripts) {
// based on https://github.com/gradle/gradle/tree/v3.5.0/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins
def tplName = 'unixStartScriptTemplate.txt'
// this succeeds. I tried negating it to ensure that it runs, and it failed, so it's running.
assert project.file(tplName).exists();
unixStartScriptGenerator.template = project.file(tplName).newReader() as TextResource
// windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt')
}
dependencies {
// mostly elided
compile 'org.apache.logging.log4j:log4j-api:2.8.+'
compile 'org.apache.logging.log4j:log4j-core:2.8.+'
compile 'de.bwaldvogel:log4j-systemd-journal-appender:2.2.2'
testCompile "junit:junit:4.12"
}
task wrapper(type: Wrapper) {
gradleVersion = '3.5'
}
それは問題でなければならないこと
ないが、私のテンプレート、unixStartScriptTemplate.txtは、主にthe original unixStartScript.txtと同じですが、いくつかの余分なコメントやJAVACMD乗り換えを持ちます。
このテンプレートを設定するより良い方法がある場合は、教えてください。
をあなたはかなり見、既存のものをフックする必要があり、一方、新しいタスクを追加します。この方法します。https:// gist.github.com/Opalo/88be0c6c1c03061581efab84bec9f96c – Opal
@Opal、それが動作します!答えにする? –
素晴らしい!どうぞ! – Opal