Java 为什么这个maven配置文件没有运行?
我在我的Java 为什么这个maven配置文件没有运行?,java,maven,maven-surefire-plugin,Java,Maven,Maven Surefire Plugin,我在我的pom.xml中有这个maven概要文件qa。它没有运行。它应该在/root/target/classes复制env.properties文件,但它没有 <profile> <id>qa</id> <build> <plugins> <plugin>
pom.xml
中有这个maven概要文件qa
。它没有运行。它应该在/root/target/classes
复制env.properties
文件,但它没有
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<copy file="src/main/resources/qa.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
配置(已弃用,改用目标)来自插件
因此,它不能像第一个示例那样在插件中使用。请发布用于启动构建的命令。您到底在做什么?
src/main/Resources
下的资源将自动放入target/classes
(或${project.build.outputDirectory}
中的任何内容)。不清楚…@Seelenvirtuose你理解得对,这就是它的作用。@Henry添加了我用来构建的命令,如果我用maven-antrun-plugin
替换maven-failsafe-plugin
和tasks
替换target
的maven-failsafe-plugin
?同样,当我替换、保存pom并运行mvn verify-Pqa-Dwebdriver.driver=chrome-e
时,它给出了在中查找org.apache.maven.plugins:maven antrun plugin:jar:2.19.1失败的错误http://jcenter.bintray.com 缓存在本地存储库中,在经过central的更新间隔或强制更新之前,不会重新尝试解析
您需要声明这两个插件。Failsafe和Antrun,每个都有自己的配置。maven-Antrun-plugin的有效版本是:maven Failsafe plugin的有效版本是:使用mavenant run plugin
更新pom后,在生命周期中找不到目标集成测试
和验证
,这是一个错误。我只是想在任何事情发生之前复制属性文件,有没有其他方法可以复制它并继续使用相同的pom?
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}" includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/qa.properties" tofile="${project.build.outputDirectory}/env.properties"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<?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>com.demo.automation</groupId>
<artifactId>serenity-automation-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Serenity Cucumber and WebDriver</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.0.18</serenity.version>
<serenity.cucumber.version>1.6.6</serenity.cucumber.version>
<webdriver.driver>firefox</webdriver.driver>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<profiles>
<profile>
<id>qa</id>
<target>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/qa.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</target>
</profile>
<profile>
<id>stage</id>
<target>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/stage.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</target>
</profile>
<profile>
<id>prod</id>
<target>
<delete>
<fileset dir="${project.build.outputDirectory}"
includes="*.properties" />
</delete>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/prod.properties"
tofile="${project.build.outputDirectory}/env.properties" />
</target>
</profile>
</profiles>
</configuration>
<!-- <goals> <goal>run</goal> </goals> -->
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>