简体   繁体   English

如何在此pom.xml文件中执行3次执行?

[英]How do I get the 3 executions in this pom.xml file to execute?

I'm totally lost as to how to get these 3 executions to execute when I perform a mvn clean install . 我完全不知道如何在执行mvn clean install全新mvn clean install时如何执行这3个执行。 I know they're inside the PluginManagement section, and I feel like that is part of the issue. 我知道它们在PluginManagement部分中,我觉得那是问题的一部分。 Thanks 谢谢

<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>

    <parent>
        <groupId>jhu.rahLeague</groupId>
        <artifactId>rahLeague</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <groupId>jhu.rahLeagueImpl</groupId>
    <artifactId>rahLeagueImpl</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>rahLeagueImpl</name>


    <profiles>
        <profile>
            <id>testing</id>
            <activation>
                <property>
                    <name>!skipTests</name>
                </property>
            </activation>


            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>hibernate3-maven-plugin</artifactId>
                            <version>${hibernate3-maven-plugin.version}</version>
                            <extensions>true</extensions>
                            <dependencies>
                                <dependency>
                                    <groupId>org.hibernate</groupId>
                                    <artifactId>hibernate-entitymanager</artifactId>
                                    <version>${hibernate3.version}</version>
                                </dependency>
                            </dependencies>
                            <executions>
                                <execution>
                                    <id>drop-db-before-test</id>
                                    <phase>process-test-classes</phase>
                                    <goals>
                                        <goal>execute</goal>
                                    </goals>
                                    <configuration>
                                        <autocommit>true</autocommit>
                                        <fileset>
                                            <basedir>${basedir}/src</basedir>
                                            <includes>
                                                <include>main/resources/ddl/*drop*.ddl</include>
                                            </includes>
                                        </fileset>
                                        <onError>continue</onError>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>create-db-before-test</id>
                                    <phase>process-test-classes</phase>
                                    <goals>
                                        <goal>execute</goal>
                                    </goals>
                                    <configuration>
                                        <autocommit>true</autocommit>
                                        <fileset>
                                            <basedir>${basedir}/src</basedir>
                                            <includes>
                                                <include>main/resources/ddl/*create*.ddl</include>
                                            </includes>
                                        </fileset>
                                        <print>true</print>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>populate-db-before-test</id>
                                    <phase>process-test-classes</phase>
                                    <goals>
                                        <goal>execute</goal>
                                    </goals>
                                    <configuration>
                                        <autocommit>true</autocommit>
                                        <fileset>
                                            <basedir>${basedir}/src</basedir>
                                            <includes>
                                                <include>test/resources/ddl/**/*populate*.ddl</include>
                                            </includes>
                                        </fileset>
                                    </configuration>
                                </execution>
                                <!-- <execution>
                                    <id>drop-db-after-test</id>
                                    <phase>test</phase>
                                    <goals>
                                        <goal>execute</goal>
                                    </goals>
                                    <configuration>
                                        <autocommit>true</autocommit>
                                        <fileset>
                                            <basedir>${basedir}/src</basedir>
                                            <includes>
                                                <include>main/resources/ddl/**/*drop*.ddl</include>
                                            </includes>
                                        </fileset>
                                    </configuration>
                                </execution> -->
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>sql-maven-plugin</artifactId>
                            <version>${sql-maven-plugin.version}</version>

                            <dependencies>
                                <dependency>
                                    <groupId>com.h2database</groupId>
                                    <artifactId>h2</artifactId>
                                    <version>${h2db.version}</version>
                                </dependency>
                            </dependencies>

                            <configuration>
                                <username>${jdbc.user}</username>
                                <password>${jdbc.password}</password>
                                <driver>${jdbc.driver}</driver>
                                <url>${jdbc.url}</url>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>

                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.1</version>
                        <configuration>
                            <source>1.7</source>
                            <target>1.7</target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>


    <dependencies>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.6.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.6.Final</version>
        </dependency>
        <!-- <dependency> <groupId>org.hibernate.common</groupId> <artifactId>hibernate-commons-annotations</artifactId> 
            <version>4.0.4.Final</version> </dependency> -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.173</version>
        </dependency>
        <!-- <dependency>
            <groupId>org.apache.cocoon</groupId>
            <artifactId>cocoon-databases-hsqldb-client</artifactId>
            <version>1.0.0</version>
        </dependency> -->


    </dependencies>
</project>

You need to also reference the plugin in the plugins section of the profile (currently you only have the maven-compiler-plugin referenced there) and not just in the pluginManagement section. 您还需要在配置文件的plugins部分中引用该插件(当前,您仅在其中引用了maven-compiler-plugin ),而不仅仅是在pluginManagement部分中。

So your pom would be: 因此,您的pom将是:

...
<profiles>
    <profile>
        <id>testing</id>
        <activation>
            <property>
                <name>!skipTests</name>
            </property>
        </activation>

        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>hibernate3-maven-plugin</artifactId>
                        <!-- excluded the configuration to keep this as short as possible -->
                        ...
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <!-- etc -->
                    </plugin>
                </plugins>
            </pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    ...
                </plugin>
                <!-- add hibernate3-maven-plugin here. Don't need to   -->
                <!-- define a version or configuration as that has     -->
                <!-- already been done in the pluginManagement section -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>hibernate3-maven-plugin</artifactId>
                </plugin>
                <!-- am presuming you would also want the sql-maven-plugin to run -->
                <!-- so you would need to add it here as well                     -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sql-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<dependencies>
    ...

The standard plugins section of a POM (and profile) defines what plugins should be executed during the build (and how based on their configuration). POM(和配置文件)的标准plugins部分定义了在构建过程中应执行哪些插件(以及如何基于其配置)。

The pluginManagement section also contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one (it can be used to configure the current pom as well). pluginManagement部分还以几乎相同的方式包含plugin元素,除了不为该特定项目构建配置plugin信息外,它旨在配置从该项目继承的项目构建(也可用于配置当前pom )。 However, this only configures plugin s that are actually referenced within the plugins element in the children (or the current pom - this is what was missing in your case). 但是,这仅配置plugin属于内实际引用小号plugins的儿童元素(或当前POM -这是在你的情况下丢失)。 The children have every right to override pluginManagement definitions. 子级有权覆盖pluginManagement定义。

So generally you would use the pluginManagement section to define standard configuration of a plugin, and then activate it in child poms (and override any configuration as required) by referencing the plugin in the standard plugins section of the pom. 因此,通常,您将使用pluginManagement部分来定义插件的标准配置,然后通过在pom的标准plugins部分中引用插件来在子poms中激活它(并根据需要覆盖任何配置)。

Maven's documentation on the POM can be found here: http://maven.apache.org/pom.html (can explain it much better than me) 可以在以下位置找到有关POM的Maven文档: http : //maven.apache.org/pom.html (可以比我解释得更好)

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

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