My build creates a distribution file: CommonBase.zip
How can I configure my distribution to create (from the same project) an additional zip file as follows:
CommonBase.zip → contains: many directories including: dir1/doc and dir1/examples
From CommonBase.zip I want to create: All.zip that excludes: dir1/doc and dir1/examples
From CommonBase.zip I want to create: Support.zip that includes only: dir1/doc and dir1/examples
in build.gradle i have the following:
distributions {
main {
contents {
// Creates CommonBase.zip
include ‘/’
}
distZip.archiveName = “CommonBase.zip”
}
}
You could create re-usable copyspecs and then include them in the appropriate distribution:
def core = project.copySpec {
from( 'dist/core' )
into( 'core' )
}
def docs = project.copySpec {
from( 'dist/docs' )
into( 'docs' )
}
def examples = project.copySpec {
from( 'dist/examples' )
into( 'examples' )
}
distributions {
all { // Note; this does not create a distribution named "all", it configures all distributions.
contents {
into( '/' )
}
}
main {
distributionBaseName = 'CommonBase'
contents {
with( core )
with( docs )
with( examples )
}
}
All { // "all" is the name of a method in the DistributionContainer, so I used "All"
distributionBaseName = 'All'
contents {
with( core )
}
}
support {
distributionBaseName = 'Support'
contents {
with( docs )
with( examples )
}
}
}
Alternatively, you can use includes (or excludes to achieve the desired results):
distributions {
all { // Note; this does not create a distribution named "all", it configures all distributions.
contents {
into( '/' )
from( 'dist' )
}
}
main {
distributionBaseName = 'CommonBase'
}
All { // "all" is the name of a method in the DistributionContainer, so I used "All"
distributionBaseName = 'All'
contents {
include( 'core/**/*' )
}
}
support {
distributionBaseName = 'Support'
contents {
include( 'docs/**/*' )
include( 'examples/**/*' )
}
}
}
In both of these examples the results are the same: