为什么我的Maven插件不会在构建生命周期中运行? [英] Why isn't my Maven plugin run in the build lifecycle?

查看:96
本文介绍了为什么我的Maven插件不会在构建生命周期中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下pom部分为我的maven生命周期添加一个目标。我定义了一个新插件并使用阶段和执行信息对其进行了配置。

I have tried to add a goal to my maven lifecycle with the following pom part. I defined a new plugin and configured it with phase and execute information.

<build>
    <pluginManagement>
        <plugins>                   
            <plugin>
                <groupId>org.apache.openjpa</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <version>2.2.0</version>
                <configuration>
                <includes>**/entity/*.class</includes>
               <addDefaultConstructor>true</addDefaultConstructor>
               <connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
                        <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                        <sqlFile>${project.build.directory}/database.sql</sqlFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>sql</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>sql</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>enhancer</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>enhance</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.openjpa</groupId>
                            <artifactId>openjpa</artifactId>

                            <version>2.1.1</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

然后我用 mvn:install 运行maven但插件没有运行?

Then I run maven with mvn:install But the plugin is not run?

推荐答案

确保插件存在依赖关系并且插件位于 build / plugin 不是 build / pluginmanagement / plugin

Make sure that there is a dependency on the plugin and that the plugin is in build/plugin not build/pluginmanagement/plugin.

尝试用这样的东西:

<dependencies>
    <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa</artifactId>
        <version>2.1.1</version>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>                   
            <plugin>
                <groupId>org.apache.openjpa</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <version>2.2.0</version>
                <configuration>
                    <includes>**/entity/*.class</includes>
                    <addDefaultConstructor>true</addDefaultConstructor>
                    <connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                    <sqlFile>${project.build.directory}/database.sql</sqlFile>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>sql</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>sql</goal>
                    </goals>
                </execution>
                <execution>
                    <id>enhancer</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这篇关于为什么我的Maven插件不会在构建生命周期中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆