相关疑难解决方法(0)

如何在 createStartScripts 任务中更改 unixStartScriptGenerator.template 以便 distTar 使用我在 build.gradle 中的自定义模板文件?

我需要修改 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

5
推荐指数
1
解决办法
1201
查看次数

在应用程序插件中调整 Gradle startScripts

我将 Gradle 与应用程序插件一起使用。
我正在尝试调整startScripts任务。我觉得调优不需要太多改动,所以我想改一下标准任务:

  • 完整的发行版包括它自己的 JRE,所以我希望脚本引用该库而不是使用 JAVA_HOME
  • 如果可能,请删除 UNIX 启动脚本。我只需要 Windows 脚本。

如果可能的话,我更喜欢了解任务中的哪些变量要更改,而不是从头开始重写任务。我的问题是如何做到这一点。查看文档,我看到仅用于applicationName, classpath, defaultJvmOpts, exitEnvironmentVar, mainClassName, optsEnvironmentVar, 的访问器outputDir,这些对我来说都无关紧要。您能指导我查看描述如何执行此操作的文档吗?

java gradle

4
推荐指数
1
解决办法
1489
查看次数