Skip to content

Commit 09a53c5

Browse files
feat(spring-multimodule-example): add multi-module structure with example modules A and B
1 parent 5f4339f commit 09a53c5

File tree

13 files changed

+515
-0
lines changed

13 files changed

+515
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: spring-multimodule-example CI Build
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- "spring-multimodule-example/**"
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
13+
jobs:
14+
15+
integration-tests:
16+
name: Run Unit & Integration Tests
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: spring-multimodule-example
21+
strategy:
22+
matrix:
23+
distribution: [ 'temurin' ]
24+
java: [ '21' ]
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up JDK ${{ matrix.java }}
31+
uses: actions/[email protected]
32+
with:
33+
java-version: ${{ matrix.java }}
34+
distribution: ${{ matrix.distribution }}
35+
cache: 'maven'
36+
- name: Build and analyze
37+
run: ./mvnw clean verify

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<module>spring-keycloak-example</module>
1818
<module>spring-jasper-example</module>
1919
<module>spring-oracle-example</module>
20+
<module>spring-multimodule-example</module>
2021
</modules>
2122

2223
</project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionType=only-script
2+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# spring-multimodule-sample
2+
3+
This project demonstrates a basic and simple configuration for a Spring application with a multi-module Maven structure.
4+
5+
## Structure
6+
7+
- `module-a-example`: Example module A with its own code and dependencies.
8+
- `module-b-example`: Example module B with its own code and dependencies.
9+
10+
Each module is managed independently but can share code and dependencies through the parent `pom.xml`.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>sample.multimodule</groupId>
8+
<artifactId>sample.multimodule</artifactId>
9+
<version>1.0.0</version>
10+
</parent>
11+
12+
<artifactId>sample.multimodule.a</artifactId>
13+
<packaging>jar</packaging>
14+
15+
<dependencies>
16+
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-test</artifactId>
20+
<scope>test</scope>
21+
<version>${spring.boot.version}</version>
22+
</dependency>
23+
24+
</dependencies>
25+
26+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package sample.multimodule.a;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
Test test = new Test();
7+
test.print("Hello world from Module A");
8+
}
9+
10+
public static class Test {
11+
12+
public void print(String text){
13+
System.out.println(text);
14+
}
15+
16+
}
17+
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package sample.multimodule.a;
2+
3+
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
7+
8+
public class MainTest {
9+
10+
@Test
11+
@DisplayName("Should print text without throwing any exception")
12+
void shouldPrintTextWithoutErrors() {
13+
Main.Test test = new Main.Test();
14+
assertDoesNotThrow(() -> test.print("Hello world from Module A"));
15+
}
16+
17+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>sample.multimodule</groupId>
9+
<artifactId>sample.multimodule</artifactId>
10+
<version>1.0.0</version>
11+
</parent>
12+
13+
<artifactId>sample.multimodule.b</artifactId>
14+
<packaging>jar</packaging>
15+
16+
<properties>
17+
<java.version>21</java.version>
18+
<spring.boot.version>3.5.6</spring.boot.version>
19+
</properties>
20+
21+
<dependencies>
22+
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-test</artifactId>
26+
<scope>test</scope>
27+
<version>${spring.boot.version}</version>
28+
</dependency>
29+
30+
</dependencies>
31+
32+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package sample.multimodule.b;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
Test test = new Test();
7+
test.print("Hello world from Module B");
8+
}
9+
10+
public static class Test {
11+
12+
public void print(String text){
13+
System.out.println(text);
14+
}
15+
16+
}
17+
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
application:
2+
name: module-b

0 commit comments

Comments
 (0)