刚接触一个项目,里面有一个配置文件,我以为是手动添加的,项目经理说是自动产生,然后我就研究怎么产生的。。。。。
后来发现是从项目某个文件copy到本地的
<span style="font-size:18px;"><profiles>
<span style="white-space:pre"> </span><!-- The following profile is activated for the mobile voter only -->
<profile>
<span style="white-space:pre"> </span><id>mobile.test.build</id>
<span style="white-space:pre"> </span><build>
<span style="white-space:pre"> </span><plugins>
<!-- the antrun plugin is used to implement the random choice of a properties file
and to copy it to the location required by the SAP Selenium2 framework -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>mvn-antrun-process-resources</id>
<phase>process-resources</phase>
<goals>
<span style="white-space:pre"> </span><goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<!-- import the ant-contrib tasks into ANT -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
<!-- copy the properties file into the temporary directory -->
<echo>Using device: "${sap.ui5.devicename}" for testing.</echo>
<mkdir dir="${env.USERPROFILE}/Automation/Test-Parameters/"/>
<copy file="${basedir}/src/test/settings/${sap.ui5.devicename}.properties" tofile="${env.USERPROFILE}/Automation/Test-Parameters/Environment.properties" overwrite="true"/>
</tasks>
</configuration>
<span style="white-space:pre"> </span></plugin>
</plugins>
</build>
</profile>
</profiles></span>
是从项目的src/test/settings文件夹下,拷贝一个properties文件到C:/Users/Automation/Test-Parameters,并重命名为Envrionment.properties.
刚开始运行 mvn build 或者 mvn install都不能生成文件。后来才发现这是 maven build 的时间和antrun 插件运行时间之间的问题。
Maven build 在 maven-antrun-plugin 运行之前就执行了,所以antrun没有起作用。
运行命令:mvn -Pmobile.test.build clean install 就OK啦。