Search code examples
mavengroovygradlezippkg-file

Build distZip/Pkg using gradle


> Below is the project folder structure that i am working with:
>     [root]
>       -build.gradle 
>       [project1]
>          -build.gradle

Project1 have many main classes. The individual tasks in the build.gradle of Project1 create jar files on task execution with a different jarname using different main-class.

Suppose i need invoke a task within the build.gradle of project1 from build.gradle of root and build a distZip from there. How do I do?

Things i Have tried so far:

  1. I have created a subtask within build.gradle of project1 which does invoke the jar file building task but it does not execute distZip.
  2. I have tried invoking distZip, it does build a zip folder but uses the default main class, not the specific one for different tasks.

Other question is there anyway to build .pkg instead of a zip?


Solution

  • The solution that did work for me is

    1) Created an external project with build.gradle that has dependency on the project1, project that needs to be built before the .zip is created.

    2)Created a zip task on /root/build

    3) Created a task within the project1 to copy all the required files to /root/build folder.

    4) Created dependency on assemble of the project on this copy task.