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