我有一个生成zip文件的项目和另一个消耗后者的项目。它一定是以某种类似的方式工作的,但是,我还不能做到这一点。我也不知道依赖关系是如何通过包含的构建连接在一起的。
我是这么试的:
- 压缩生产项目/设置。gradle:*
rootProject.name = 'zip-producing-project'
- zip生成项目/构建. gradle:*
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
task createZip(type: Zip) {
from 'src/main/resources'
include '*'
archiveName 'zip-producing-project.zip'
}
artifacts {
archives file('build/distributions/zip-producing-project.zip') // not sure "archives" is the right configuration
}
tasks.build.dependsOn "createZip"
- 压缩消耗项目/设置。gradle:*
rootProject.name = 'zip-consuming-project'
includeBuild '../zip-producing-project'
- zip使用项目/构建。gradle:*
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
dependencies {
archives 'org.example:zip-producing-project:1.0-SNAPSHOT@zip' // is that correct?
}
task unzip(type: Copy) {
configurations.archives.resolve().forEach {
if (it.name.endsWith(".zip")) {
from zipTree(it)
}
}
into "${project.buildDir}"
}
调用gradle clean build
得到:
FAILURE: Build failed with an exception.
* Where:
Build file 'zip-consuming-project\build.gradle' line: 14
* What went wrong:
A problem occurred evaluating root project 'zip-consuming-project'.
> Could not resolve all files for configuration ':archives'.
> Could not find zip-producing-project.zip (project :zip-producing-project)
我如何使它工作,即使zip-consuming-project
找到工件zip-producing-project.zip
?
1条答案
按热度按时间vkc1a9a21#
包含的内部版本(发布者):
包括构建(消费者)