File tree Expand file tree Collapse file tree
java/com/baeldung/maven_caching
test/java/com/baeldung/maven_caching
src/main/java/com/baeldung/maven_caching
src/main/java/com/baeldung/maven_caching Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ FROM maven:alpine as build
2+ ENV HOME=/usr/app
3+ RUN mkdir -p $HOME
4+ WORKDIR $HOME
5+
6+ ADD pom.xml $HOME
7+ ADD core/pom.xml $HOME/core/pom.xml
8+ ADD application/pom.xml $HOME/application/pom.xml
9+
10+ RUN mvn -pl core verify --fail-never
11+ ADD core $HOME/core
12+ RUN mvn -pl core install
13+ RUN mvn -pl application verify --fail-never
14+ ADD application $HOME/application
15+ RUN mvn -pl core,application package
16+
17+ FROM openjdk:8-jdk-alpine
18+
19+ COPY --from=build /usr/app/application/target/application-0.0.1-SNAPSHOT.jar /app/runner.jar
20+
21+ ENTRYPOINT java -jar /app/runner.jar
Original file line number Diff line number Diff line change 1+ FROM maven:alpine as build
2+ ENV HOME=/usr/app
3+ RUN mkdir -p $HOME
4+ WORKDIR $HOME
5+
6+ ADD . $HOME
7+ RUN --mount=type=cache,target=/root/.m2 mvn -f $HOME/pom.xml clean package
8+
9+ FROM openjdk:8-jdk-alpine
10+
11+ COPY --from=build /usr/app/application/target/application-0.0.1-SNAPSHOT.jar /app/runner.jar
12+
13+ ENTRYPOINT java -jar /app/runner.jar
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <parent >
6+ <artifactId >maven-caching</artifactId >
7+ <groupId >com.baeldung</groupId >
8+ <version >0.0.1-SNAPSHOT</version >
9+ </parent >
10+ <modelVersion >4.0.0</modelVersion >
11+
12+ <artifactId >application</artifactId >
13+ <dependencies >
14+ <dependency >
15+ <groupId >com.baeldung</groupId >
16+ <artifactId >core</artifactId >
17+ <version >0.0.1-SNAPSHOT</version >
18+ </dependency >
19+ </dependencies >
20+
21+ <properties >
22+ <maven .compiler.source>8</maven .compiler.source>
23+ <maven .compiler.target>8</maven .compiler.target>
24+ </properties >
25+
26+ <build >
27+ <plugins >
28+ <plugin >
29+ <groupId >org.springframework.boot</groupId >
30+ <artifactId >spring-boot-maven-plugin</artifactId >
31+ <configuration >
32+ </configuration >
33+ </plugin >
34+ </plugins >
35+ </build >
36+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .maven_caching ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
5+
6+ @ SpringBootApplication
7+ public class MavenCachingApplication {
8+
9+ public static void main (String [] args ) {
10+ SpringApplication .run (MavenCachingApplication .class , args );
11+ CoreClass cc = new CoreClass ();
12+ System .out .println (cc .method ());
13+ }
14+
15+ }
Original file line number Diff line number Diff line change 1+
Original file line number Diff line number Diff line change 1+ package com .baeldung .maven_caching ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import org .springframework .boot .test .context .SpringBootTest ;
5+
6+ @ SpringBootTest
7+ class MavenCachingApplicationTests {
8+
9+ @ Test
10+ void contextLoads () {
11+ }
12+
13+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <parent >
6+ <artifactId >maven-caching</artifactId >
7+ <groupId >com.baeldung</groupId >
8+ <version >0.0.1-SNAPSHOT</version >
9+ </parent >
10+ <modelVersion >4.0.0</modelVersion >
11+
12+ <artifactId >core</artifactId >
13+
14+ <properties >
15+ <maven .compiler.source>8</maven .compiler.source>
16+ <maven .compiler.target>8</maven .compiler.target>
17+ </properties >
18+
19+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .maven_caching ;
2+
3+ public class CoreClass {
4+
5+ public String method (){
6+ return "Hello from core module!!" ;
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
4+ <modelVersion >4.0.0</modelVersion >
5+ <packaging >pom</packaging >
6+ <modules >
7+ <module >application</module >
8+ <module >core</module >
9+ </modules >
10+ <parent >
11+ <groupId >org.springframework.boot</groupId >
12+ <artifactId >spring-boot-starter-parent</artifactId >
13+ <version >2.6.3</version >
14+ <relativePath /> <!-- lookup parent from repository -->
15+ </parent >
16+ <groupId >com.baeldung</groupId >
17+ <artifactId >maven-caching</artifactId >
18+ <version >0.0.1-SNAPSHOT</version >
19+ <name >maven-caching</name >
20+ <description >maven-caching</description >
21+ <properties >
22+ <java .version>1.8</java .version>
23+ </properties >
24+
25+ <dependencies >
26+ <dependency >
27+ <groupId >org.springframework.boot</groupId >
28+ <artifactId >spring-boot-starter-web</artifactId >
29+ </dependency >
30+
31+ <dependency >
32+ <groupId >org.springframework.boot</groupId >
33+ <artifactId >spring-boot-starter-test</artifactId >
34+ <scope >test</scope >
35+ </dependency >
36+ </dependencies >
37+
38+ </project >
Original file line number Diff line number Diff line change 1+ FROM maven:alpine as build
2+ ENV HOME=/usr/app
3+ RUN mkdir -p $HOME
4+ WORKDIR $HOME
5+ ADD pom.xml $HOME
6+ RUN mvn verify --fail-never
7+
8+ ADD . $HOME
9+ RUN mvn package
10+
11+ FROM openjdk:8-jdk-alpine
12+
13+ COPY --from=build /usr/app/target/maven-caching-1.0-SNAPSHOT-jar-with-dependencies.jar /app/runner.jar
14+
15+ ENTRYPOINT java -jar /app/runner.jar
You can’t perform that action at this time.
0 commit comments