这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions maven-modules/maven-version-number/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Relevant Articles:

78 changes: 78 additions & 0 deletions maven-modules/maven-version-number/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>maven-version-number</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>com.baeldung</groupId>
<artifactId>maven-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<!--
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
</plugin>
</plugins>
</build>
-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>generate-version-file</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo file="${project.build.directory}/output/version.txt">
Version: ${project.version}
</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<properties>
<maven-antrun-plugin.version>3.0.0</maven-antrun-plugin.version>
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Version: ${project.version}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.baeldung.dependency.ordering;

class OutputVersionNumberUnitTest {

/*
@Test
void whenUsingResourcesPlugin_ThenGenerateVersionFile() {
File versionFile = new File("target/classes/version.txt");
assertTrue(versionFile.exists(), "Version file (Maven Resources Plugin) should exist in target/classes.");
}

@Test
void whenUsingAntrunPlugin_ThenGenerateVersionFile() {
File versionFile = new File("target/output/version.txt");
assertTrue(versionFile.exists(), "Version file should exist in target/generated.");
}
*/

}