【发布时间】:2019-07-28 11:13:57
【问题描述】:
我正在使用 Gradle 作为构建系统的 xtext 项目。我想在 Jenkins 中运行 gradlew war,但是由于某种原因它不可用。当我运行gradlew tasks 以查看所有可用选项时,它没有在此处列出。这些是可用的任务:
Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.
Help tasks
----------
buildEnvironment - ...
...
但是当我在我的机器上本地运行它时,可用的任务要多得多:
Build tasks
-----------
...
war - Generates a war archive with all the compiled classes, the web-app content and the libraries.
Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.
Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.
Help tasks
----------
...
IDE tasks
---------
...
Run tasks
---------
jettyRun - Starts an example Jetty server with your language
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.
所以war 任务显然就在那里,我可以毫无问题地运行它。为什么詹金斯当时看不到它。我没有修改任何 Gradle 文件。所有都包含使用项目创建的默认代码。如果需要,我可以附加任何 Gradle 文件,但我不知道可能需要哪一个。然而,这是主要的 build.gradle 文件(子目录中还有更多:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.xtext:xtext-gradle-plugin:2.0.4'
}
}
subprojects {
ext.xtextVersion = '2.17.0'
repositories {
jcenter()
}
apply plugin: 'java'
dependencies {
compile platform("org.eclipse.xtext:xtext-dev-bom:${xtextVersion}")
}
apply plugin: 'org.xtext.xtend'
apply from: "${rootDir}/gradle/source-layout.gradle"
apply plugin: 'eclipse'
group = 'ic.ac.uk.mydsl'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
configurations.all {
exclude group: 'asm'
}
}
【问题讨论】:
-
您确定在向导中配置了 Web 项目。如果是,war 插件将应用于 .web 项目,因此 war 将在任务中可用。所以你确定你已经承诺了一切吗? (例如,设置等级)
-
抱歉,我不知道什么是向导。但是,我在帖子中附加了我的 git repo 的图像。
-
这看起来不错。但我不知道为什么它不应该工作。我已经看到这样做了 100 次并且它总是有效的。 => 无法访问复制示例:不知道。 => 它是否适用于 hello world mydsl 示例?
-
我去试试
-
所以我创建了一个新项目并且没有修改任何内容,jenkins 上的“gradlew tasks”仍然返回相同的列表,没有“war”任务。