Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
maven pom-定义一个配置文件来定制插件配置_Maven_Plugins_Profile - Fatal编程技术网

maven pom-定义一个配置文件来定制插件配置

maven pom-定义一个配置文件来定制插件配置,maven,plugins,profile,Maven,Plugins,Profile,我在pom中有以下插件: <plugin> <groupId>com.github.klieber</groupId> <artifactId>phantomjs-maven-plugin</artifactId> <configuration> <version>${phantomjs.version}</version> <checkSys

我在pom中有以下插件:

  <plugin>
    <groupId>com.github.klieber</groupId>
    <artifactId>phantomjs-maven-plugin</artifactId>
    <configuration>
      <version>${phantomjs.version}</version>
      <checkSystemPath>false</checkSystemPath>          
      <skip>${skipTests}</skip>
    </configuration> 
    <executions>
      <execution>
        <goals>
          <goal>install</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

com.github.klieber
PhantomJSMaven插件
${phantomjs.version}
假的
${skipTests}
安装
我想定义一个新的配置文件来定制插件配置:

<profile>
  <id>enduserTest</id>

  <properties>
    <tomcat.version>8.0.39</tomcat.version>              
    <skipTests>true</skipTests>
  </properties>      

  <build>
    <defaultGoal>clean verify cargo:run</defaultGoal>
    <plugins>          

  <plugin>
    <groupId>com.github.klieber</groupId>
    <artifactId>phantomjs-maven-plugin</artifactId>
    <configuration>
      <version>${phantomjs.version}</version>
      <checkSystemPath>false</checkSystemPath>          
    </configuration> 
    <executions>
      <execution>
        <goals>
          <goal>install</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

终端用户测试
8.0.39              
真的
清洁验证货物:运行
com.github.klieber
PhantomJSMaven插件
${phantomjs.version}
假的
安装
其中唯一的区别是
${skipTests}
线路。 现在我想运行
mvn-PenduserTest
,但是配置没有被覆盖。
有什么建议吗?有更好的解决方案吗?这是正确的策略吗?

如果所需的行为是在运行概要文件时跳过测试,那么您的逻辑没有错误。为了验证我测试了这段代码,这是按预期工作的(它使用-PenduserTest跳过测试):


朱尼特
朱尼特
3.8.2
src
com.github.klieber
PhantomJSMaven插件
0.7
2.1.1
假的
${skipTests}
安装
maven编译器插件
3.3
终端用户测试
8.0.39              
真的
清洁验证货物:运行
com.github.klieber
PhantomJSMaven插件
0.7
0.7
假的
安装

如果我在概要文件内外定义这些插件,它就不起作用了。但是,如果我只在配置文件中定义这些插件,它就可以正常工作。surefire插件的工作原理与此非常相似,但我不必在新的配置文件中重新定义整个插件。我刚刚从POM属性中获取了原始插件定义的配置值,并在概要文件中添加了覆盖,就像您在这里看到的一样。
<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.2</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
             <plugin>
            <groupId>com.github.klieber</groupId>
            <artifactId>phantomjs-maven-plugin</artifactId>
            <version>0.7</version>
            <configuration>
              <version>2.1.1</version>
              <checkSystemPath>false</checkSystemPath>          
              <skip>${skipTests}</skip>
            </configuration> 
            <executions>
              <execution>
                <goals>
                  <goal>install</goal>
                </goals>
              </execution>
            </executions>
          </plugin>


            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source />
                    <target />
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
      <id>enduserTest</id>

      <properties>
        <tomcat.version>8.0.39</tomcat.version>              
        <skipTests>true</skipTests>
      </properties>      

      <build>
        <defaultGoal>clean verify cargo:run</defaultGoal>
        <plugins>          

      <plugin>
        <groupId>com.github.klieber</groupId>
        <artifactId>phantomjs-maven-plugin</artifactId>
        <version>0.7</version>
        <configuration>
          <version>0.7</version>
          <checkSystemPath>false</checkSystemPath>          
        </configuration> 
        <executions>
          <execution>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      </plugins>
      </build>
      </profile>
    </profiles>

</project>