Skip to content

Commit e8f5b94

Browse files
committed
BAEL-6598: Guide to Maven Toolchains usage example
1 parent 59dc3b2 commit e8f5b94

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.baeldung</groupId>
8+
<artifactId>maven-modules</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>maven-toolchains</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>21</maven.compiler.source>
16+
<maven.compiler.target>21</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<protobuf.version>3.0.0</protobuf.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.google.protobuf</groupId>
24+
<artifactId>protobuf-java</artifactId>
25+
<version>3.19.4</version>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-toolchains-plugin</artifactId>
34+
<version>3.2.0</version>
35+
<executions>
36+
<execution>
37+
<goals>
38+
<goal>toolchain</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
<configuration>
43+
<toolchains>
44+
<jdk>
45+
<version>24</version>
46+
<vendor>liberica</vendor>
47+
</jdk>
48+
<protobuf>
49+
<version>${protobuf.version}</version>
50+
</protobuf>
51+
</toolchains>
52+
</configuration>
53+
</plugin>
54+
55+
<plugin>
56+
<groupId>org.xolstice.maven.plugins</groupId>
57+
<artifactId>protobuf-maven-plugin</artifactId>
58+
<version>0.6.1</version>
59+
<extensions>true</extensions>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>compile</goal>
64+
<goal>test-compile</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
syntax = "proto3";
2+
3+
option java_package = "com.baeldung";
4+
option java_multiple_files = true;
5+
option java_outer_classname = "AddressBookProtos";
6+
7+
message Address {
8+
string street_address = 1;
9+
string city = 2;
10+
string state = 3;
11+
string postal_code = 4;
12+
}
13+
14+
message Contact {
15+
string first_name = 1;
16+
string last_name = 2;
17+
string email = 3;
18+
string phone_number = 4;
19+
Address address = 5;
20+
}
21+
22+
message AddressBook {
23+
repeated Contact contacts = 1;
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<toolchains>
3+
<!-- JDK toolchains -->
4+
<toolchain>
5+
<type>jdk</type>
6+
<provides>
7+
<version>24</version>
8+
<vendor>liberica</vendor>
9+
</provides>
10+
<configuration>
11+
<jdkHome>/opt/liberica-24</jdkHome>
12+
</configuration>
13+
</toolchain>
14+
15+
<!-- Protocol Buffers toolchains -->
16+
<toolchain>
17+
<type>protobuf</type>
18+
<provides>
19+
<version>3.0.0</version>
20+
</provides>
21+
<configuration>
22+
<protocExecutable>/opt/protoc-3.0.0/bin/protoc</protocExecutable>
23+
</configuration>
24+
</toolchain>
25+
</toolchains>

maven-modules/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<module>multimodulemavenproject</module>
6161
<module>resume-from</module>
6262
<module>maven-multiple-repositories</module>
63+
<module>maven-toolchains</module>
6364
</modules>
6465

6566
<dependencyManagement>

0 commit comments

Comments
 (0)