【问题标题】:Multiple maven plugins to run a phase多个 Maven 插件来运行一个阶段
【发布时间】:2017-10-16 18:35:16
【问题描述】:

我正在做一个 maven smartbear soapui 项目。我有两个插件的依赖项。 `

<build>
    <plugins>
      <plugin>
        <groupId>com.smartbear.soapui</groupId>
        <artifactId>soapui-pro-maven-plugin</artifactId>
        <version>5.1.2</version>
        <executions>
          <execution>
            <id>pro</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <projectFile>${projectFile}</projectFile>
              <outputFolder>${basedir}/target/surefire-reports</outputFolder>
              <junitReport>true</junitReport>
              <exportAll>true</exportAll>
              <printReport>true</printReport>
              <testFailIgnore>true</testFailIgnore>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <soapuiProperties>
            <property>
              <name>soapui.logroot</name>
              <value>${project.build.directory}/surefire-reports/</value>
            </property>
            <property>
              <name>soapui.https.protocols</name>
              <value>TLSv1.2,SSLv3</value>
            </property>
          </soapuiProperties>
        </configuration>

        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
          </dependency>
          <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <version>0.9.9-RC1</version>
          </dependency>
          <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <version>0.9.9-RC1</version>
          </dependency>
          <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.19.1</version>
            <type>maven-plugin</type>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>com.github.redfish4ktc.soapui</groupId>
        <artifactId>maven-soapui-extension-plugin</artifactId>
        <version>4.6.4.2</version>
        <executions>
          <execution>
            <id>redfish</id>
            <phase>test</phase>
            <configuration>
              <testSuiteProperties>
                <properties>
                  <property>PropertyCode=${propertyCode}</property>
                  <property>Environment=${environment}</property>
                  <Gateway>Gateway=${gateway}</Gateway>
                </properties>
              </testSuiteProperties>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>`

我的测试需要有依赖插件redfish,因为它支持soapuiTestSuite属性配置。

现在,当我尝试运行此mvn install test 时,构建开始使用第一个插件运行并失败,因为它没有下载第二个插件,然后再次运行下载第二个但失败。在运行目标之前,我需要同时设置插件和整个配置。

我是 Maven 结构的新手。

【问题讨论】:

    标签: java maven plugins soapui ready-api


    【解决方案1】:
    1. 在第二个插件处添加执行。
    2. 例如,如果你想在soapui-pro-maven-plugin之前执行maven-soapui-extension-plugin,你可以添加这个执行:

          <executions>
                    <execution>
                        <id>soapui-tests</id>
                        <phase>verify</phase>
                        <goals>
                         <goal>test</goal>
                        </goals>
                </execution>
              </executions>
      
    3. 只需执行 'mvn install',因为您已将执行附加到默认 Maven 生命周期。

    按执行顺序查看默认 Maven 生命周期列表:验证、初始化、..部署 (docs here)。

    【讨论】:

    • 我的项目依赖于这两个插件。根据您的说法,只有一个插件会被执行对吗?
    • 否,将每个插件附加到一个阶段以掌握这些插件的执行顺序
    猜你喜欢
    • 2016-09-22
    • 2012-03-03
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多