我有一个多模块maven项目,我想让我的所有子模块maven-compiler-plugin在root中使用pom.xml.我应该在哪里maven-compiler-plugin申报(在根目录中pom.xml):在<plugins>部分或<pluginManagement>部分?问题也与此有关maven-release-plugin.
我需要使用Maven antrun插件将Hibernate字节码检测添加到我的一个Java类中,以便启用单个字段的延迟加载.但是,我无法在构建周期中获取插件.
如何在编译之后但在mvn package构建期间打包之前指示Maven执行antrun插件?
当前的pom.xml(片段):
<pluginManagement>
<plugins>
...
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<inherited>false</inherited>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<target>
<echo message="Running instrumentation task"/>
<taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
<classpath>
<path refid="maven.dependency.classpath" />
<path refid="maven.plugin.classpath" />
</classpath>
</taskdef>
<instrument verbose="true">
<fileset dir="target/classes">
<include name="**/UploadedFile.class" />
</fileset>
</instrument>
</target>
</configuration>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)
我在这个问题上看到的所有文档都显示插件被配置为在"进程类"阶段运行.但是,从Maven 文档来看,"进程类"阶段似乎不是构建周期的一部分package.我可以自己运行插件mvn antrun:run …