java - Gradle - A lot of modules -


i have java project (simplified) looks this: (they not named this, example)

core (project 1)   core.java   utils:     util.java     anotherutil.java  modules (project 2)       amodule.java   b     bmodule.java   c     cmodule.java   ...   z     zmodule.java 

i made build.gradle builds core project, works fine.

my question: there way make 26 different jars 26 different "modules", without creating 26 different build scripts?

when building program don't want run 26 different build scripts every time. fine running 2 scrips, 1 core , on modules. modules depend on core , core softdepends (depends without needing it, has functions when there) on modules.

all modules should have own jar looks this:

a.jar:   (package)     amodule.java b.jar:   b (package)     bmodule.java etc... 

gradle supports customising multi-project builds, ideal way.

all module represented separate jar should separated projects.

but in case still want have scenario in want extract different components/modules contents/source file projects , possible!

with minor tweak, can create customised task create jar archive meeting conditions.

ps: creating logical modules of project not @ recommended. use sub-projects instead , configure using gradle multi-project builds


not recommended :: generating multiple jars source folder (project)

one of easiest way achieve create custom task

for module a

task ajar(type: jar) {       from(sourcesets.main.output) {           include "a/**"      }   } 

for module b

task bjar(type: jar) {       from(sourcesets.main.output) {           include "b/**"      }   } 

and on.

now specify dependency on tasks

jar.dependson(ajar,bjar) 

they can execute gradle jar required jars


Comments

Popular posts from this blog

Combining PHP Registration and Login into one class with multiple functions in one PHP file -

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -