Skip to content

Commit 0d82bc1

Browse files
authored
Bael 7456 (#18419)
* BAEL-7456: Output the Version Number to a Text File using Maven * BAEL-7456: Output the Version Number to a Text File using Maven
1 parent 10c3bf3 commit 0d82bc1

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Relevant Articles:
2+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
<groupId>org.example</groupId>
7+
<artifactId>maven-version-number</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>maven-modules</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.junit.jupiter</groupId>
19+
<artifactId>junit-jupiter-api</artifactId>
20+
<version>${junit-jupiter.version}</version>
21+
<scope>test</scope>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.junit.jupiter</groupId>
25+
<artifactId>junit-jupiter-engine</artifactId>
26+
<version>${junit-jupiter.version}</version>
27+
<scope>test</scope>
28+
</dependency>
29+
</dependencies>
30+
31+
<!--
32+
<build>
33+
<resources>
34+
<resource>
35+
<directory>src/main/resources</directory>
36+
<filtering>true</filtering>
37+
</resource>
38+
</resources>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-resources-plugin</artifactId>
43+
<version>${maven-resources-plugin.version}</version>
44+
</plugin>
45+
</plugins>
46+
</build>
47+
-->
48+
<build>
49+
<plugins>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-antrun-plugin</artifactId>
53+
<version>${maven-antrun-plugin.version}</version>
54+
<executions>
55+
<execution>
56+
<id>generate-version-file</id>
57+
<phase>generate-resources</phase>
58+
<goals>
59+
<goal>run</goal>
60+
</goals>
61+
<configuration>
62+
<target>
63+
<echo file="${project.build.directory}/output/version.txt">
64+
Version: ${project.version}
65+
</echo>
66+
</target>
67+
</configuration>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
74+
<properties>
75+
<maven-antrun-plugin.version>3.0.0</maven-antrun-plugin.version>
76+
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
77+
</properties>
78+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Version: ${project.version}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.baeldung.dependency.ordering;
2+
3+
class OutputVersionNumberUnitTest {
4+
5+
/*
6+
@Test
7+
void whenUsingResourcesPlugin_ThenGenerateVersionFile() {
8+
File versionFile = new File("target/classes/version.txt");
9+
assertTrue(versionFile.exists(), "Version file (Maven Resources Plugin) should exist in target/classes.");
10+
}
11+
12+
@Test
13+
void whenUsingAntrunPlugin_ThenGenerateVersionFile() {
14+
File versionFile = new File("target/output/version.txt");
15+
assertTrue(versionFile.exists(), "Version file should exist in target/generated.");
16+
}
17+
*/
18+
19+
}

0 commit comments

Comments
 (0)