【问题标题】:gradle: why there is no jar task for all sourceSetsgradle:为什么所有 sourceSets 都没有 jar 任务
【发布时间】:2017-06-28 21:32:47
【问题描述】:

添加了sourceSet web,但没有对应的任务:

apply plugin: 'java'
sourceSets {
    web
}

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.
webClasses - Assembles web classes.

我期待以下任务

webJar

Gradle assemble and build:不构建web sourceSet。

【问题讨论】:

标签: gradle build source-sets


【解决方案1】:

每个 sourceSet 没有一个 jar 任务,因为在大多数项目中这个 jar 不是必需的。例如,java 项目带有两个 sourceSet(main 和 test)。不需要测试 sourceSet 的 jar,因为您可以在没有它的情况下运行测试。

如果您需要一个 jar 来存放其他 sourceSet,您可以轻松创建一个:

task myJar(type:Jar){
    from sourceSets.mySourceSet.output  
}

【讨论】:

  • 应该来自sourceSets.mySourceSet.output吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-23
相关资源
最近更新 更多