我正在使用pom.xml
的这一部分执行一个sh文件,该文件将触发我的回归测试。
此部分调用sh文件。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>Regression_Test</id>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${basedir}/../../qascripting/Vdopia_Automation/exe/hudson_tc_execute.sh</executable>
</configuration>
</plugin>
当我执行命令mvn clean package
时 - 它只是构建代码,没有触发sh,当我使用命令mvn clean
验证时---它执行sh
但是没有构建代码。现在我想要一个应该首先构建代码然后执行sh。
整个pom.xml:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vdopia</groupId>
<artifactId>hudson</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<url>http://maven.apache.org</url>
<properties>
<gson.version>2.2.4</gson.version>
<guava.version>18.0</guava.version>
<junit.version>4.10</junit.version>
<netty.version>4.0.25.Final</netty.version>
<wurfl.version>1.5.1</wurfl.version>
<slf4j.version>1.7.7</slf4j.version>
<redis.version>2.4.2</redis.version>
<logger.version>0.3.1</logger.version>
<org.apache.commons.pool.version>1.6</org.apache.commons.pool.version>
<execplugin.version>1.3.2</execplugin.version>
<commons.codec.version>1.9</commons.codec.version>
<geoip.version>1.2.14</geoip.version>
<org.json.version>20140107</org.json.version>
<jacoco.version>0.7.2.201409121644</jacoco.version>
<spymemcached.version>2.11.5</spymemcached.version>
<aspectjweaver.version>1.8.0</aspectjweaver.version>
<aspectjrt.version>1.8.0</aspectjrt.version>
<apacheasynchttpclient.version>4.1</apacheasynchttpclient.version>
<shadedjar.version>2.3</shadedjar.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!--plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version> <executions> <execution> <goals> <goal>prepare-agent</goal>
</goals> </execution> <execution> <id>report</id> <phase>prepare-package</phase>
<goals> <goal>report</goal> </goals> </execution> </executions> </plugin -->
<!-- To download and link source code in eclipse -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${execplugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${shadedjar.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.vdopia.rtb.netty.Server.HudsonMain</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- REGRESSION TEST -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>Regression_Test</id>
<phase>verify</phase>
<!-- <phase>generate-test-sources</phase> -->
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${basedir}/../../qascripting/Vdopia_Automation/exe/hudson_tc_execute.sh</executable>
</configuration>
</plugin>
<!-- END -->
</plugins>
</build>
<profiles>
<profile>
<id>code-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<modules>
<module>utils</module>
<module>rtb</module>
<module>adResponse</module>
<module>DAL</module>
<module>cache</module>
<module>redis</module>
<module>extRequestProcessor</module>
<module>netty</module>
<module>ResponseGenerator</module>
<module>RequestHandler</module>
<module>Filter</module>
<module>fluentData</module>
<module>vast</module>
<module>externalcache</module>
<module>templates</module>
<module>statistics</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
答案 0 :(得分:0)
maven生命周期控制着订单。所以你把sh命令放入验证阶段就可以了。请记住,如果您在早期阶段遇到故障,那么maven会停止而不是前进到下一阶段。这是阶段执行的顺序: https://maven.apache.org/ref/3.3.3/maven-core/lifecycles.html
我把一个最小的pom放在一起就可以了。 这是我的pom
<modelVersion>4.0.0</modelVersion>
<groupId>com.simuquest.qp</groupId>
<artifactId>example1</artifactId>
<version>1.0.13333</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>Regression_Test</id>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<workingDirectory>${basedir}\target</workingDirectory>
<arguments>
<argument>-cp</argument>
<argument>${basedir}\target\example1-1.0.13333.jar</argument>
<argument>example1.NewMain</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
这是我做“mvn install”时的输出
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
--- maven-jar-plugin:2.3.2:jar (default-jar) @ example1 ---
Building jar: C:\Users\Administrator\Documents\NetBeansProjects\example1\target\example1-1.0.13333.jar
--- exec-maven-plugin:1.2.1:exec (Regression_Test) @ example1 ---
hello
--- maven-install-plugin:2.3.1:install (default-install) @ example1 ---
Installing C:\Users\Administrator\Documents\NetBeansProjects\example1\target\example1-1.0.13333.jar to C:\Users\Administrator\.m2\repository\com\simuquest\qp\example1\1.0.13333\example1-1.0.13333.jar
Installing C:\Users\Administrator\Documents\NetBeansProjects\example1\pom.xml to C:\Users\Administrator\.m2\repository\com\simuquest\qp\example1\1.0.13333\example1-1.0.13333.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
因此,您现在可以比较工作和不工作的pom文件。你可以进行二元搜索,找出你的pom的哪些部分让你感到悲伤。为什么不首先删除所有这些插件。请记住,您只需要无错误地构建,以便完成各个阶段并达到验证阶段。