Gradle: How do I publish a zip from a non-java project and consume it in a java project?

build, gradle

Solution

Not exactly sure what you're after, but here's a quick-and-dirty way to get access to the FileCollection of the `:my-non-java-project:doZip` task outputs:

project(":my-non-java-project").tasks.getByName("doZip").outputs.files

Note that the `archives` configuration is added by the Java plugin, not the Base plugin. But you can still define a custom configuration in `my-non-java-project` and add the artifact to it with the code in your OP:

//in my-non-java-project/build.gradle
configurations {
    archives
}
artifacts {
    archives doZip
}

Then you can access the task outputs via the configuration, like so (again, quick-and-dirty):

//in some-java-project/build.gradle
project(":my-non-java-project").configurations.archives.artifacts.files

Note that you can expand the content of your zip file using `zipTree`.

If you need to actually publish the zip produced by `my-non-java-project`, you can read about that here.

Problem

I have a multi-project setup. I created a non-java project whose artifact is a zip file that I will unzip in another project. So the idea is as below ``` my-non-java-project build.gradle ------------ apply plugin: 'base' task doZip(type:Zip) { ... } task build(dependsOn: doZip) << { } artifacts { archives doZip } some-java-project build.gradle ------------ apply plugin: 'war' configurations { includeContent // This is a custom configuration } dependency { includeContent project(':my-non-java-project') } task expandContent(type:Copy) { // Here is where I would like get hold of the all the files // belonging to the 'includeContent' configuration // But this is always turning out to be empty. Not sure how do I publish // non-java content to the local repository (as understood by groovy) } ``` So, my question is, how do I publish the artifacts of a non-java project to the internal repository of groovy such that I can pick it up at another java-based project?

Original source