has anyone figured out how to use includeBuild wit...
# community-support
j
has anyone figured out how to use includeBuild with shadow? in my case, my main build is including another build which provides a gradle plugin to be applied within the main build. but the plugin project uses gradleup shadow. the error looks like
Copy code
> Could not resolve all artifacts for configuration 'classpath'.
   > Failed to transform xxx-main.jar (project :plugin) to match attributes {artifactType=jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.internal.instrumented=instrumented-only, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for ProjectDependencyInstrumentingArtifactTransform: /home/xxx-main.jar.
         > java.io.FileNotFoundException: File system element for parameter 'source' does not exist: '/home/xxx-main.jar'
The plugin produces the shadow jar without the
main
classifier. so my thought was to do a custom dependency substitution like this
Copy code
variant(module("myplugin")) {
            attributes{
                attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.SHADOWED))
            }
        }
however, it seems the
objects
reference doesn't exist in settings.gradle. is there anyway to set an attribute in an included build dependency substitution?
j
Not sure if this helps in your case, but in this case "hiding" the normal variant behind a unknown attribute helped to pick the shadow variant in the included build (local consumption) case: https://github.com/autonomousapps/dependency-analysis-gradle-plugin/blob/main/shadowed/antlr/build.gradle.kts#L97-L108
Copy code
// Hide the un-shadowed variants in local consumption, by mangling their attributes
    runtimeElements.attributes {
      attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named("DO_NOT_USE"))
    }

    // Hide the un-shadowed variants in publishing
    javaComponent.withVariantsFromConfiguration(runtimeElements) { skip() }
(this is on the produce side though)
j
interesting, ill try that. thanks!
e
this feels like it might be secretly doing some internal stuff but
Copy code
serviceOf<ObjectFactory>()
does seem to return what
objects
would
v
Yes, but be aware that this is internal API!