Template for Multi-Project Gradle Workspaces to implement the best practice in PPDG eDocs.
Executing gradlew projects
will list the sub-projects in this Multi-Product Gradle workspace.
If you have local nexus running on
localhost:8081
, you can build locally by usinggradlew -Dlocal
.
> Task :projects
Projects:
------------------------------------------------------------
Root project 'sample-services' - Sample Multi-Project Build
------------------------------------------------------------
Root project 'sample-services' - Sample Multi-Project Build
+--- Project ':common' - Project Common Module
| +--- Project ':common:common-batch' - Common Batch
| +--- Project ':common:common-core' - Common Core
| +--- Project ':common:common-host-integration' - Common Host Integration
| +--- Project ':common:common-mapper' - Common Mapper
| \--- Project ':common:common-template' - Common Template
+--- Project ':module1' - Project Module 1
| +--- Project ':module1:module1-batch' - Module 1 Batch
| +--- Project ':module1:module1-core' - Module 1 Core
| +--- Project ':module1:module1-host-integration' - Module 1 Host Integration
| +--- Project ':module1:module1-mapper-mobile' - Module 1 Mapper
| +--- Project ':module1:module1-mapper-web' - Module 1 Mapper
| \--- Project ':module1:module1-template' - Module 1 Template
+--- Project ':module2' - Project Module 2
| +--- Project ':module2:module2-batch' - Module 2 Batch
| +--- Project ':module2:module2-core' - Module 2 Core
| +--- Project ':module2:module2-host-integration' - Module 2 Host Integration
| +--- Project ':module2:module2-mapper-mobile' - Module 2 Mapper
| +--- Project ':module2:module2-mapper-web' - Module 2 Mapper
| \--- Project ':module2:module2-template' - Module 2 Template
\--- Project ':module3-api' - Project Module 3 with Spring Boot API sub-module
+--- Project ':module3-api:module3-api-api' - Module 3 API (a Spring Boot Application)
+--- Project ':module3-api:module3-api-core' - Module 3 Core
\--- Project ':module3-api:module3-api-host-integration' - Module 3 Host Integration
To see a list of the tasks of a project, run gradlew <project-path>:tasks
-
Fork this project
-
Open
settings.gradle
and modifyrootProject.name
to your project name. -
Open
gradle.properties
and modify the relevant properties accordingly such as the project version or project group for publishing to Nexus. -
Rename the
module1
andmodule2
directories accordingly along with themodule1.gradle
andmodule2.gradle
to your desired artifact name with prefix. Ensure that the sub-module directories and gradle files are also renamed, i.e.module1-core
andmodule1-core.gradle
, etc.For example:
abc-casa
,abc-casa.gradle
,abc-casa-batch
,abc-casa-core
,abc-casa-host-integration
,abc-casa-mapper
andabc-casa-template
formodule1
abc-fund-transfer
,abc-fund-transfer.gradle
,abc-fund-transfer-batch
,abc-fund-transfer-core
,abc-fund-transfer-host-integration
,abc-fund-transfer-mapper
andabc-fund-transfer-template
formodule2
- and so on...
NOTE: The prefix must be consistent across your project.
-
Modify the dependencies of the modules in the
.gradle
files. Cross-module dependency can be defined by following https://docs.gradle.org/current/userguide/declaring_dependencies_between_subprojects.html#sec:project_jar_dependencies Gradle sub-project dependency guidelines. -
If necessary, create more module directories by replicating
module1
ormodule2
and renaming them accordingly.