【发布时间】:2017-04-30 10:51:25
【问题描述】:
我是 Gradle 新手,遇到了一个问题(使用 Gradle 2.14)
我的项目有 3 个子项目:程序集、sprinBootProject、E2E
组装模块负责压缩 Spring Boot 应用程序的 jar 以及属性文件。
E2E 模块是一个“端到端”测试模块,用于测试 Spring Boot 应用程序。
我在 assembly/build.gradle 中使用分发插件,如下所示:
apply plugin: 'distribution'
distributions {
main {
baseName "project-assembly"
contents{
from project(':springBootProject').fileTree(dir: 'build/libs', include: ['*.jar'])
from project(':springBootProject').fileTree(dir: 'build/resources/main', includes: ['*.properties', 'conf/*.properties'])
}
}
}
但我需要确保 springBootProject 将在程序集子项目之前进行评估,所以我像这样使用了 dependsOn:
distZip.dependsOn(':springBootProject:build')
当我添加这一行时,我看到 E2E 模块在 compileTestJava 任务中失败,所以这一行影响了 Spring Boot 应用程序的生成方式(我认为)
E2E/build.gradle:
dependencies {
testCompile project(":springBootProject")
}
所以我的问题是我做得对吗?为什么当我添加dependsOn行时,E2E模块会受到影响,我如何强制Gradle在组装模块之前评估spring boot应用程序?
【问题讨论】:
标签: java gradle spring-boot