I have a custom configuration:
configurations {
unnamedJavaModule {
canBeResolved true
}
}
Gradle version: 5.6
This configuration is used to add a dependency to a subproject like so:
unnamedJavaModule (project(':unnamed.module'))
The problem is at compilation, the kotlin compiler complains that some package defined inside the module does not exist.
I tried to fix it by adding the configuration the compileKotlin
classpath, but that didn’t work.
compileKotlin {
doFirst {
classpath += configurations.unnamedJavaModule
}
}
Unresolved reference: packagename
Where packagename
is the name of the package it is not finding. This is annoying because the package exists in the subproject. It is not complaining that the package is in an unnamed module, it is just not finding it. Changing the dependency to use implementation
configuration, seems to fix this, but I don’t want to use the existing implementation
configuration
implementation (project(':unnamed.module')) // This works
How do I fix this so that the custom configuration is resolved properly?
This sounds similar to this question, but they are actually not the same because that one is dealing with a plugin-specific problem.