[英]Maven multimodule mojo not executing
I need to install a custom plugin (mojo) first and then execute the goal.我需要先安装一个自定义插件(mojo)然后执行目标。 I would want this to happen in one go but as of now using below code i am getting build errors.我希望这发生在一个 go 但截至现在使用下面的代码时,我遇到了构建错误。 Not sure if i'm going right in below code so that i can install plugin first and then code inside mojo would get executed.不确定我是否要在下面的代码中正确执行,以便我可以先安装插件,然后 mojo 中的代码将被执行。
ParentProject:父项目:
<groupId>com.io</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Parent</name>
<description>ThisisParent</description>
<packaging>pom</packaging>
<modules>
<module>Child1Plugin</module>
<module>ChildFramework</module>
</modules>
Child1Plugin-pom.xml Child1Plugin-pom.xml
<parent>
<groupId>com.io</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Child1Plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Child</name>
<description>ThisisChild</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>com.parent.module</groupId>
<artifactId>ChildFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>mydata</goal>
</goals>
</execution>
</executions>
<configuration>
<scope>test</scope>
</configuration>
</plugin>
</plugins>
</build>
</project>
ChildFramework-pom.xml ChildFramework-pom.xml
<parent>
<groupId>com.io</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>ChildFramework</artifactId>
<packaging>maven-plugin</packaging>
<name>Childtwo</name>
<description>Thisischildtwo</description>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>com.io</groupId>
<artifactId>ChildFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>mydata</goal>
</goals>
</execution>
</executions>
<configuration>
<scope>test</scope>
</configuration>
</plugin>
</plugins>
</build>
The below mojo is inside src/main/java folder of ChildFramework module.下面的 mojo 位于 ChildFramework 模块的 src/main/java 文件夹中。
@Mojo(name = "mydata", defaultPhase = LifecyclePhase.COMPILE)
public class Feat extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
System.out.println("%%%%%%%%%%%%%%%%%%%%%% MyMOJO");
}
ChildFramework can't use itself as a plugin (because that's a circular dependency). ChildFramework 不能将自己用作插件(因为这是循环依赖)。 I think the changes you need are these:我认为您需要的更改是:
<packaging>
to jar
and change the <artifactId>
of the plugin to Child1Plugin
ChildFramework:将<packaging>
更改为jar
并将插件的<artifactId>
更改为Child1Plugin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.