How to resolve custom configurations with project dependencies in a multi-project build?

(Eldarg) #1
configurations { pluginConf }

dependencies { pluginConf project(':my-plugin') }

byteBuddy { 
    transformation {
        classPath = configurations.pluginConf 

(ByteBuddy loads the plugin using the specified class path).

Running ./gradlew clean my-app:build results in an error. The plugin could not be resolved.
Running ./gradlew clean build works. (probably because my-plugin is built before my-app).

How could that be fixed? Thanks in advance.

(Chris Doré) #2

What type of project is my-plugin? For example, is it a java project that applies the java plugin?
Is it possible you could provide a fully working example that reproduces the issue?

(Eldarg) #3

Yes, it is a java project. my-plugin must be built first. When also using a non-custom configuration, for example implementation, it works (so it is actually an execution dependency, and the plugin is built first). But with my custom configuration, this doesn’t happen automatically. Any ideas? @st_oehme
Thanks in advance.

(Chris Doré) #4

I took a look at the bytebuddy plugin source and here’s the issue; The plugin adds a doLast to all AbstractCompile tasks. However, the plugin does not manipulate the task’s inputs or dependencies in any way. Therefore, those compile tasks do not know that your custom configuration is a dependency and Gradle cannot infer the dependency on the subproject. The implementation configuration works because the compile tasks are definitely configured correctly to identify the subproject task dependencies.
Ideally the bytebuddy plugin should be fixed.
Quick workaround:

tasks.withType(AbstractCompile).all { dependsOn configurations.pluginConf }

(Eldarg) #5

Thanks a lot! The workaround works.
I will open an issue on the ByteBuddy Github-Repository.