首页 > 解决方案 > 如何将源代码文件添加为源文件中的构建依赖项和/或访问定义?

问题描述

我有:

plugins {
    id 'java'
    id 'net.bytebuddy.byte-buddy-gradle-plugin' version "$byteBuddyVersion"
}

byteBuddy {
    transformation {
        plugin = io.github.leoframework.testing.Logger.class
    }
}

Logger.java是项目的一部分,在 Byte Buddy 插件中。我需要在我的构建脚本中引用哪个文件/类来调用插件。编译后需要加载类文件Logger.java

标签: gradlepluginsbuild.gradlegradle-pluginbyte-buddy

解决方案


If it's part of the current project, it is not that trivial, unfortunately. Gradle is executed in its own JVM process that is run before the compilation what makes this somewhat a chicken and egg problem.

To overcome this, you'd need to compile the classes first, then define a subproject that depend on these classes dynamically and then execute the plugin from this subproject once the dependent classes are available.


推荐阅读