我需要修改 gradle 为distTar任务生成的启动脚本。我似乎能够设置 unixStartScriptGenerator.template如下所示,但是当我从 tar 解压缩脚本时,我的更改不存在。
这是我的完整内容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 …Run Code Online (Sandbox Code Playgroud) java software-distribution gradle build.gradle gradle-plugin
我将 Gradle 与应用程序插件一起使用。
我正在尝试调整startScripts任务。我觉得调优不需要太多改动,所以我想改一下标准任务:
如果可能的话,我更喜欢了解任务中的哪些变量要更改,而不是从头开始重写任务。我的问题是如何做到这一点。查看文档,我看到仅用于applicationName, classpath, defaultJvmOpts, exitEnvironmentVar, mainClassName, optsEnvironmentVar, 的访问器outputDir,这些对我来说都无关紧要。您能指导我查看描述如何执行此操作的文档吗?