是否可以在主要Groovy项目中使用Gradle buildSrc编译的类? [英] Is it possible to use classes compiled by Gradle buildSrc in main Groovy project?

查看:111
本文介绍了是否可以在主要Groovy项目中使用Gradle buildSrc编译的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在主要PROJECT类中使用buildSrc/build.gradle编译的类时,它们在运行时不会解析.

Classes compiled by buildSrc/build.gradle are not resolved at runtime when they are used in main PROJECT classes.

My Groovy project structure looks like this:
-PROJECT
    -buildSrc/
        -build.gradle
        -/src/main/groovy
            - com.company.global.test.report
    -src/test/groovy
    -build.gradle

是否可以在顶级PROJECT/build.gradle中添加一些内容,以允许其编译的类使用buildSrc/build.gradle编译的类?

Is there something I can add to the top-level PROJECT/build.gradle to allow the classes compiled by it to use the classes compiled by buildSrc/build.gradle?

推荐答案

buildSrc是它自己的 build (不是项目),在主版本之前执行.其唯一目的是使某些类(插件,任务,常规类)可用于主版本的构建脚本.因此,您可以将其称为元构建".

buildSrc is its own build (not project) that gets executed before the main build. Its sole purpose is to make some classes (plugins, tasks, regular classes) available to the build scripts of the main build. Hence you could call it a "meta-build".

从技术上讲,可以将buildSrc的已编译类添加到主版本中项目的编译或运行时类路径中,但是我不建议这样做.很有可能实现目标的更好方法(但我不知道这些是什么).

Technically, it would be possible to add the compiled classes of buildSrc to the compile or runtime class path of a project in the main build, but I don't recommend to do it. There is very likely a better way to achieve your goals (but I don't know what those are).

这篇关于是否可以在主要Groovy项目中使用Gradle buildSrc编译的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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