Large multi-module project


(Alex Sko) #1

I have a multi-module Maven project with a Vaadin-based web application:

common
core
license
mainapp
model
launcher
......
connectors
    connector-msp
    connector-jira
    ........... (many others)
connectors-editors
    msp-editor
    jira-editor
    ...........(many others)

the Maven root file included “connectors” and “connectors-editors” modules (pom.xml files), which in turn included all the subprojects.

my understanding is I have to make the FLAT projects list in settings.gradle (list all “connectors” and their “editors” in the common settings.gradle):

include “common”, “connectors:connector-msp”, “connectors:connector-jira”, … “launcher”, “mainapp”, “test-utilities”,

“webshared”, “webui”

but then I can’t build “connectors” or “connectors-editors” separately from the rest of the application. is this right?

another thing is that I declare many common dependencies on “connectors” pom.xml - they are the same for all subprojects in “connectors”. similar in “connectors-editors”. where do these shared dependencies go with Gradle?


(Anders Brolien) #2

You can use a subprojects block in a build.gradle in the connectors dir to configure common behavior for all connectors.

subprojects {
  apply plugin: 'java'
dependencies {
   compile group1:name1:version1
}

If you want to dynamically include all dirs under the root you can put the following in settings.gradle in the root directory. This will make include statements for all sub dirs containg a file ending with .gradle. Code is originally from: http://gradle.1045684.n5.nabble.com/Nested-multi-projects-and-caveats-td4480779.html

def path = [] as LinkedList

rootDir.traverse(

type: groovy.io.FileType.FILES,

nameFilter: ~/.+.gradle/,

maxDepth: 3,

preDir: { path << it.name },

postDir: { path.removeLast() }) { if (path) include path.join(":") }

You can issue a build at any level in the structure, build at root level will build everything. Build at connector level will build only connectors, and possible modified project dependencies.


(Alex Sko) #3

declaring common dependencies in “connectors/build.gradle” and “connectors-editors/build.gradle” helped. thank you!

I’ll try including all possible build.gradle files, not sure yet if this is a good idea for my build…