Hi,
I am using Gradle 8.2.1 and Java 17.
One of our project’s modules needs to rewrite a jar’s META-INF/MANIFEST.MF
so that the rest of the project can use the modified jar artifact. However, the rest of the project refuses to compile against this module, and I strongly suspect it’s because the project is looking to compile against source files - which simply do not exist in this case.
The jar in question is kotlinx-coroutines-core-jvm
, and we also need dependency substitution to work for the sake of any transitive dependencies:
configurations.configureEach {
resolutionStrategy {
dependencySubstitution {
substitute module('org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm') using project(':libs:kotlin-coroutines')
}
}
}
This therefore demands that project(':libs:kotlin-coroutines')
provides the jar artifact instead of classes+resources.
Now it was my understanding that
project(':name')
was shorthand for
project(path: ':name', configuration: 'default')
And so I added this to libs/kotlin-coroutines/build.gradle
:
configurations {
'default' {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
}
}
}
However, projects that use
dependencies {
implementation project(':libs:kotlin-coroutines')
}
are still failing to compile, although
dependencies {
implementation project(path: ':libs:kotlin-coroutines', configuration: 'default')
}
does appear to work.
I’d be happy with this approach if it weren’t for the dependency substitution requirement Can anyone suggest a way to persuade project(':libs:kotlin-coroutines')
to Do The Right Thing please?
Thanks,
Chris
P.S. This also seems to work:
dependencies {
implementation(project(':libs:kotlin-coroutines')) {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
}
}
}
but is still incompatible with dependency substitution.