繁体   English   中英

Maven Pom插件未在构建中执行

[英]Maven pom plugin not executing on build

我正在练习Maven,但碰壁了。 我已经在IntelliJ上安装了PlantUml插件,并且试图对其进行设置,以使其始终在编译时从源文件生成新图像。 我正在使用插件生成图像,并且已按如下所示配置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强制插件在编译时生成新映像?

您已将配置放入pluginManagement 您需要将其放入plugins pluginManagement 之外 )。

pluginManagement仅用于覆盖/指定配置和版本号。

看看Maven:什么是pluginManagement?

您的插件和执行是在“ generate-resources”阶段配置的,而不是您想要的编译阶段。 有关此阶段的更多详细信息,请参见此链接

改变这个:

<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>

它必须工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM