0

I'm practicing Maven and I've hit a wall. I've installed the PlantUml plugin on IntelliJ and I'm trying to set it up so that it always generates a new image from the source file on compile time. I'm using this plugin to generate the image, and I've configured the pom.xml file as follows:

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

This works fine when I use a terminal command where I specify the goal:

mvn compile com.github.jeluard:plantuml-maven-plugin:generate

However, it doesn't work if I just write:

mvn compile

Which, as far as I know, should also work. I've tried setting the phase on compile but it didn't change anything. I've searched for hours now for a solution but I haven't found one. Does anyone know how I can force the plugin to generate a new image on compile time by configuring the pom?

Diado
  • 2,229
  • 3
  • 18
  • 21
NastoK
  • 33
  • 4

2 Answers2

1

You have put your configuration into pluginManagement. You needs to put it into plugins (outside pluginManagement).

The pluginManagement is just to override/specify configuration and version numbers.

Have a look at Maven: What is pluginManagement?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • What if it's still not running after moving to plugings? – dev4life Apr 20 '20 at 18:29
  • @dev4life It would be great if you ask a new question here on SO including your POM and which error you get. – J Fabian Meier Apr 20 '20 at 18:37
  • I might have to do that. I saw similar problems but tried the solutions and still didn't work for me. I was trying to avoid posting another "my plugin is not running" thread but I think I will have too. – dev4life Apr 20 '20 at 20:29
-1

your plugin and your execution is configure à the "generate-resources" phase and not at the compile phase like you want. See this link to more detail on phase.

change this:

<execution>
        <id>GeneratePlantUml</id>
        <phase>generate-resources</phase>
        <goals>
          <goal>generate</goal>
        </goals>

to this

<execution>
        <id>GeneratePlantUml</id>
        <phase>compile</phase>
        <goals>
          <goal>generate</goal>
        </goals>

It must works.