I want to make testing for different folders in a maven project and I need to change the maven's project.build.testSourceDirectory
property.
I'm using a maven profile for this problem.
My profile looks like this:
<profiles>
<profile>
<id>sahi_UI_testing</id>
<activation>
<property>
<name>sahiTesting</name>
<value>true</value>
</property>
</activation>
<properties>
<maven.test.skip>false</maven.test.skip>
<project.build.testSourceDirectory>src/test/java/org/package1/package2/sahi</project.build.testSourceDirectory>
</properties>
</profile>
</profiles>
The project.build.testSourceDirectory
isn't changed, only remains the default /home/username/workspace/projectName/core/src/test/java
(I've tested this with maven-antrun-plugin
and gives that path).
I have multiple pom.xml in the projects, so in the path I have the ../core/.. folder (this is the project's core pom.xml).
The maven-antrun-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>******** Displaying value of property ********</echo>
<echo>${project.build.testSourceDirectory}</echo>
<echo>${maven.test.skip}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Executing mvn help:active-profiles -f core/pom.xml -Dtest=JavaClientTest -o -e test -DsahiTesting=true
with <maven.test.skip>true</maven.test.skip>
in maven-antrun-plugin
this gives me:
[INFO] Executing tasks
[echo] ** Displaying value of property **
[echo] /home/username/workspace/projectName/core/src/test/java
[echo] true
and with <maven.test.skip>false</maven.test.skip>
in maven-antrun-plugin
this gives me:
[INFO] Executing tasks
[echo] ** Displaying value of property **
[echo] /home/username/workspace/projectName/core/src/test/java
[echo] false
So, we can see that the another variable was changed.
I know that the profile was activated because I used maven-help-plugin
to identify this.
The maven-help-plugin
gives me this result:
The following profiles are active:
- sahi_UI_testing (source: pom)
I've tried without maven's profile to change the project.build.testSourceDirectory
property only in the <build>
tag.
...
<build>
<testSourceDirectory>src/test/java/org/package/package2/sahi</testSourceDirectory>
...
</build>
There the property was changed (but I need to assign more than one value to that property).
I've tried the maven-surefire-plugin
and doesn't work too.
The question is that why the project.build.testSourceDirectory
isn't changed when using the profile?