繁体   English   中英

java maven exec-maven-plugin没有在mvn clean install上执行

[英]java maven exec-maven-plugin not executing on mvn clean install

后续问题的后续: Maven在测试阶段之前运行类:exec-maven-plugin exec:java不执行类

我在jenkins盒子上运行jUnit4测试,用maven构建。 我需要在构建的测试阶段之前运行特定的main方法java程序。 目的是在测试运行之前恢复测试数据库。

如果我运行了这个exec分配给的确切阶段,我的类按预期执行; 但是当我运行整个构建时,我的类不会执行:

具体来说,它运行:
mvn -X exec:java generate-test-resources

但不运行:
mvn -X -e install
- 要么 -
mvn -X -e clean install

pom.xml:我的pom.xml文件包括:

<pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>            
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <id>build-test-environment</id>
                    <phase>generate-test-resources</phase>          
                    <goals>
                        <goal>java</goal>           
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>main.java._tools.BuildTestEnvironment</mainClass>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

生命周期默认:我还没有看到maven的生命周期。 日志将其报告为:

[DEBUG] Lifecycle default -> [
    validate,
    initialize,
    generate-sources,
    process-sources,
    generate-resources,
    process-resources,
    compile,
    process-classes,
    generate-test-sources,
    process-test-sources,
    generate-test-resources,
    process-test-resources,
    test-compile,
    process-test-classes,
    test,
    prepare-package,
    package,
    pre-integration-test,
    integration-test,
    post-integration-test,
    verify,
    install,
    deploy
]

使用<pluginManagement>下定义的插件,您实际上在告诉maven在调用插件时将在整个项目中使用哪个插件版本。 我通常希望<pluginManagement>标记出现在父pom中。

要调用插件 - 只需输入<plugins/>元素即可。 它可能会也可能不会从a继承

因此,要使用该插件,您只需要通过put来调用插件

<plugins>
        <plugin>            
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <id>build-test-environment</id>
                    <phase>generate-test-resources</phase>          
                    <goals>
                        <goal>java</goal>           
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>main.java._tools.BuildTestEnvironment</mainClass>
            </configuration>
        </plugin>
    ...AnyOtherPlugin
    <plugins>

没有任何<pluginManagement>标记

Ashish接着说: <pluginManagement>正在杀死它。

我认为我需要<pluginManagement>因为Eclipse和m2e存在问题。 原来m2e的人有一个解决方案(一个非常复杂的解决方案)。

看到:

如何解决Spring Data Maven Builds的“生命周期配置未涵盖的插件执行”

- 和 -

http://wiki.eclipse.org/M2E_plugin_execution_not_covered

祝你好运,如果遇到这个!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM