I have this pom structure and I am trying to access property hub.p
, which is set in
build-helper-maven-plugin
, which is inside profile and stores port number . Port is assigned as I get on console
something like this Reserved port 59831 for hub.p
. I am unable to access this through resource filtering through another property hub.port
, which is defined in properties section
<project xmlns="http://maven.apache.org/POM/4.0.0"
...
<build>
....
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
<properties>
<hub.port>${hub.p}</hub.port>
</properties>
<dependencies>
...
</dependencies>
<profiles>
<profile>
<id>acceptanceTests</id>
<build>
...
<plugins>
....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>reserve-server-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>hub.p</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
....
</profile>
</profiles>
</project
in src/test/resources
, I have pom.properties
property file , which has this
hubPort=${hub.port}
And I am accessing property like this
Properties properties = new Properties();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream inputStream = loader.getResourceAsStream("pom.properties");
properties.load(inputStream);
String portForHub = properties.getProperty("hubPort");
System.out.println("hubport..."+portForHub);
But it prints
hubport...${hub.port}
I referred to this question ,but I am not able to access the property.