Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Version Catalog specify library build type

I'm refactoring a multi module project with version catalogs and I have to add a dependency that is currently like this:

implementation com.mygroup:my-artifact:1.0.0:debug@aar

Since version catalogs doesn't allow to specify the aar type, a workaround would be to specify it directly in the gradle file like this:

implementation(libs.myDependency) { artifact { type = 'aar' } }

This works, but there's an extra complexity: I need to also specify the build type, in the example from above is debug, I cannot find a way to add it.

What I've tried is:

TOML

[libraries]
myDependency = { module = "com.mygroup:my-artifact", version = "1.0.0:debug" }

Gradle

implementation(libs.myDependency) { artifact { type = 'aar' } }

For some reason this doesn't work, how can I also specify the build type?

like image 772
xatok Avatar asked Dec 07 '25 02:12

xatok


1 Answers

Found a way to do this! Need to add the classifier into the artifact.

So for the given regular declaration:

build.gradle

dependencies {
    implementation com.mygroup:my-artifact:1.0.0:debug@aar
}

The version catalogs way would be:

TOML

[libraries]
myDependency = { module = "com.mygroup:my-artifact", version = "1.0.0" }

build.gradle

dependencies {
    implementation(libs.myDependency) {
        artifact {
            classifier = 'debug'
            type = 'aar'
        }
    }

}
like image 83
xatok Avatar answered Dec 09 '25 20:12

xatok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!