When installing the project into (local) maven repository, I would like to replace all properties placeholders with their current actual values, is this somehow possible?
All in all I'm trying to create a customizable project version in maven, in order to resolve some problems with the transitive dependencies.
Here is my minimized pom.xml:
<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>com.foo</groupId>
<artifactId>T</artifactId>
<version>${custom.version}</version>
<properties>
<custom.version>TEST</custom.version>
</properties>
<build>
<resources>
<resource>
<directory>${basedir}</directory>
<includes>
<include>pom.xml</include>
</includes>
<filtering>true</filtering>
<targetPath>${basedir}</targetPath>
</resource>
</resources>
</build>
After "mvn clean install" I would like to have in the local maven repository here "~/.m2/repository/com/foo/T/TEST/T-Test.pom" following contents:
<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>com.foo</groupId>
<artifactId>T</artifactId>
<version>TEST</version>
<properties>
<custom.version>TEST</custom.version>
</properties>
<build>
<resources>
<resource>
<directory>doesn't matter</directory>
<includes>
<include>pom.xml</include>
</includes>
<filtering>true</filtering>
<targetPath>doesn't matter</targetPath>
</resource>
</resources>
</build>
So the ${custom.version} placeholder should be replaced by it's current value "TEST", before installing the project into maven repository.
But all I get - is an empty file, even in the current project directory, probably because the file is locked and maven can't override it.
Is there any possibility to install/deploy the pom file with resolved property values?
<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>com.foo</groupId>
<artifactId>T</artifactId>
<packaging>jar</packaging>
<version>${custom.version}</version>
<properties>
<custom.version>TEST2</custom.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>./</directory>
<filtering>true</filtering>
</resource>
</resources>
<outputDirectory>target</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<pomFile>target/pom.xml</pomFile>
</configuration>
</plugin>
</plugins>
</build>
Produces in "~/.m2/repository/com/foo/T/TEST/T-Test.pom" what I want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With