Creating all-in-one-zip in a multi project build

Hi,
I see there are multiple discussions on this topic in the forum. But none of the solutions worked for me. Hence posting this.

I have a project structure like this:

rootProject
– subProject
   - childProject1
   - childProject2
   - childProject3

settings.gradle at root project has this:

rootProject.name = 'cssTheme'
// alphabetical order
include \
 'allcss:project1',
 'allcss:project2',
 'allcss:project3'

my top level build.gradle has this:

evaluationDependsOnChildren();

def publishGroup = project.baseGroup
evaluationDependsOnChildren();
def cssTheme = file("./allcss/css_files.zip")
project.configurePublishingPublications project, {
   publishCustomTheme(MavenPublication) {
       groupId publishGroup
       setArtifactId 'cssTheme'
       artifact cssTheme 
   }
}

task themesZipFileTask(type:Zip) {
 dependsOn subprojects*.build
 from('./allcss/project1/project1.css')
 from('./allcss/project2/project2.css')
 from('./allcss/project3/project3.css')
 from ('./common/common.css')
    destinationDir(file('./allcss'))
    archiveName ("css_files.zip")
}
build.finalizedBy tasks.themesZipFileTask

project.configureArtifactoryPublications project,
    'publishCustomTheme'

I am using gradle 1.12.

I have following questions:

  1. Is it possible to create a zip file with all the subprojects built artifacts at the root project level? I see that the zip task is called only at config phase, not at execution. Is this expected behavior?

  2. if (1) is not possible, what is the best way to aggregate all the subprojects artifacts into one file?

  3. If (1) is possible, then, what am I missing in the code? I have noticed that only “common.css” (Which is a static file) goes into the zip. None of the other css files are there.

As a start, you should probably update Gradle.
1.12 is almost 10 years old, many many things changed since then.

Besides that, if you split your code into multiple artifacts, you should usually just publish all of them as separate artifacts with proper dependencies.

If you really want to use artifacts produced from other projects, you need to follow this: Sharing outputs between projects