问题描述
我想编译一个子项目,然后在构建另一个子项目时在类路径上创建这些类。 (一个自定义的tass会使用第一个创建的类)。
目前我在尝试:
<$ p
$ b $
...有以下结果:
的东西。 (这里是一个多项目构建)
您需要使 MyOtherProject
成为一个完整的独立版本,您可以安装到某个存储库,然后依据它的坐标或在配置阶段或构建过程中触发该单独构建,然后根据其结果。
buildSrc
项目中。这是一个包含在您的根项目中的完整多项目构建,它由Gradle自动构建并添加到主构建脚本的类路径中,并且适用于您不希望在其他构建中使用的插件和自定义任务,因此不要让他们成为一个单独的版本。 I want to compile one subproject, then have those classes on the classpath while building the other subproject. (A custom tass would use classes created by the first one).
Currently I'm trying:
buildscript {
dependencies {
classpath project(':MyOtherProject')
}
}
... with the following result:
You cannot build something to be used to build the something. (something being the multi-project build here)
You either need to make the MyOtherProject
a complete separate build, that you either install to some repository and then depend on it per coordinates or trigger that separate build during configuration phase or your build, then depending on its outcomes.
The other alternative is, that you put it into buildSrc
project. This is a full multi-project build contained in your root project that is built and added to the classpath of the main build scripts automatically by Gradle and is meant for Plugins and Custom tasks that you do not want to use in other builds also and thus do not make them a separate build.
这篇关于如何在配置阶段使用来自邻近子项目的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!