Gradle: How to publish a zip from a project without Java and use it in a java project?

I have a multi-project setup. I created a non-java project whose artifact is a zip file that I will unzip to another project. So the idea 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 can I post artifacts of a non-java project to the groovy internal repository so that I can pick it up in another Java based project?

+6
source share
1 answer

Not quite sure what you need, but here's a quick and dirty way to access FileCollection :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 an artifact to it with code in the OP:

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

Then you can access the task exits through the configuration, for example (again, quickly and dirty):

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

Please note that you can expand the contents of your zip file using zipTree .

If you need to publish a zip created by my-non-java-project , you can read about it here .

+7
source

Source: https://habr.com/ru/post/952684/


All Articles