When building multiple archives with the java-library-distribution plugin, use the dist.name as a classifer

I would like to use the java-library-distribution plugin to build multiple archives like:

myService-2.0.6-SNAPSHOT-local.zip myService-2.0.6-SNAPSHOT-dev.zip myService-2.0.6-SNAPSHOT-itest.zip myService-2.0.6-SNAPSHOT-qa.zip myService-2.0.6-SNAPSHOT-prod.zip

If I do something like:

distributions {

local {

baseName = archivesBaseName + ‘-local’

}

itest {

baseName = archivesBaseName + ‘-itest’

} }

I get myService-dev-2.0.6-SNAPSHOT.zip and myservice-itest-2.0.6-SNAPSHOT.zip. I would like a DSL like:

distributions {

local {

baseName = archivesBaseName

classifier = ‘local’

}

itest {

baseName = archivesBaseName

classifier = ‘itest’

} }

Currently this isn’t exposed via the DSL, although I think it would be useful, as you suggested, to add a ‘classifier’ property to ‘Distribution’. Perhaps you would consider contributing this in a pull request?

In the mean time, you can get around this limitation by configuring the archive tasks themselves.

distributions.all { it.baseName = archivesBaseName }

tasks.withType(AbstractArchiveTask).matching { it.name.toLowerCase().contains(‘dist’) }.all {

def distName = it.name.substring(0, it.name.toLowerCase().indexOf(‘dist’))

it.classifier = distName ?: ‘main’

}