为什么我的Maven插件在构建生命周期中运行? [英] Why isnt my Maven plugin run in the build lifecycle?
本文介绍了为什么我的Maven插件在构建生命周期中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图添加一个目标到我的maven生命周期与下面的pom部分。我定义了一个新的插件,并配置它与阶段和执行信息。
< 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>
< / goal>
< / execution>
< execute>
< id> enhancer< / id>
< phase> process-classes< / phase>
< goals>
< goal> enhance< / goal>
< / goal>
< / 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
解决方案
任何想法
<确保对插件有依赖性,并且插件位于
build / plugin
而不是 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>
< / goal>
< / execution>
< execution>
< id> enhancer< / id>
< phase> process-classes< / phase>
< goals>
< goal> enhancement< / goal>
< / goal>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>
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>
Then I run maven with mvn:install
But the plugin is not run?
Any Ideas?
解决方案
Make sure that there is a dependency on the plugin and that the plugin is in build/plugin
not build/pluginmanagement/plugin
.
Try with something like this:
<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屋!
查看全文