Maven pom 插件未在构建时执行
Maven pom plugin not executing on build
我正在练习 Maven,但遇到了瓶颈。我已经在 IntelliJ 上安装了 PlantUml 插件,我正在尝试对其进行设置,以便它始终在编译时从源文件生成新图像。我正在使用 this 插件来生成图像,并且我已将 pom.xml 文件配置如下:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.jeluard</groupId>
<artifactId>plantuml-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>GeneratePlantUml</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/images</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<sourceFiles>
<directory>${basedir}/plantuml</directory>
<includes>
<include>TestGeneratorDiagram.puml</include>
</includes>
</sourceFiles>
<outputDirectory>${basedir}/images</outputDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>8031</version>
</dependency>
</dependencies>
</plugin>
<plugins>
</pluginManagement>
<build>
当我使用指定目标的终端命令时,这工作正常:
mvn compile com.github.jeluard:plantuml-maven-plugin:generate
但是,如果我只写它是行不通的:
mvn compile
据我所知,这也应该有效。我试过在编译时设置阶段,但它没有改变任何东西。我已经搜索了几个小时来寻找解决方案,但我还没有找到。有谁知道如何通过配置 pom 强制插件在编译时生成新图像?
你的插件和你的执行是在 "generate-resources" 阶段配置的,而不是像你想要的那样在编译阶段。
请参阅此 link 以了解有关阶段的更多详细信息。
改变这个:
<execution>
<id>GeneratePlantUml</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
至此
<execution>
<id>GeneratePlantUml</id>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
一定有用。
您已将配置放入 pluginManagement
。你需要把它放到plugins
(outside pluginManagement
).
插件管理只是override/specify配置和版本号。
看看Maven: What is pluginManagement?
我正在练习 Maven,但遇到了瓶颈。我已经在 IntelliJ 上安装了 PlantUml 插件,我正在尝试对其进行设置,以便它始终在编译时从源文件生成新图像。我正在使用 this 插件来生成图像,并且我已将 pom.xml 文件配置如下:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.jeluard</groupId>
<artifactId>plantuml-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>GeneratePlantUml</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/images</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<sourceFiles>
<directory>${basedir}/plantuml</directory>
<includes>
<include>TestGeneratorDiagram.puml</include>
</includes>
</sourceFiles>
<outputDirectory>${basedir}/images</outputDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>8031</version>
</dependency>
</dependencies>
</plugin>
<plugins>
</pluginManagement>
<build>
当我使用指定目标的终端命令时,这工作正常:
mvn compile com.github.jeluard:plantuml-maven-plugin:generate
但是,如果我只写它是行不通的:
mvn compile
据我所知,这也应该有效。我试过在编译时设置阶段,但它没有改变任何东西。我已经搜索了几个小时来寻找解决方案,但我还没有找到。有谁知道如何通过配置 pom 强制插件在编译时生成新图像?
你的插件和你的执行是在 "generate-resources" 阶段配置的,而不是像你想要的那样在编译阶段。 请参阅此 link 以了解有关阶段的更多详细信息。
改变这个:
<execution>
<id>GeneratePlantUml</id>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
至此
<execution>
<id>GeneratePlantUml</id>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
一定有用。
您已将配置放入 pluginManagement
。你需要把它放到plugins
(outside pluginManagement
).
插件管理只是override/specify配置和版本号。
看看Maven: What is pluginManagement?