如何在配置阶段使用来自邻近子项目的类 [英] How to use classes from a neighbouring subproject during configuration phase

查看:425
本文介绍了如何在配置阶段使用来自邻近子项目的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编译一个子项目,然后在构建另一个子项目时在类路径上创建这些类。 (一个自定义的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:

Cannot use project dependencies in a script classpath definition.

解决方案

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.

这篇关于如何在配置阶段使用来自邻近子项目的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆