2

My POM file has plugins that build the front end builds. However, when we run mvn clean install it runs the front end grunt/npm exec twice. How do I avoid multiple executions?

All help is appreciated. Since the grunt build takes time, removing the duplicate runs will shorten the build time.

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.4.0</version>
        <executions>
            <execution>
                <id>exec-npm-install</id>
                <phase>generate-sources</phase>
                <configuration>
                    <executable>npm</executable>
                    <arguments>
                        <argument>install</argument>
                    </arguments>
                    <workingDirectory>src/main/raw_ui</workingDirectory>
                </configuration>
                <goals>
                    <goal>exec</goal>
                </goals>
            </execution>
            <execution>
                <id>exec-bower-install</id>
                <phase>generate-sources</phase>
                <configuration>
                    <executable>bower</executable>
                    <arguments>
                        <argument>install</argument>
                    </arguments>
                    <workingDirectory>src/main/raw_ui</workingDirectory>
                </configuration>
                <goals>
                    <goal>exec</goal>
                </goals>
            </execution>
            <execution>
                <id>exec-grunt</id>
                <phase>generate-sources</phase>
                <configuration>
                    <executable>grunt</executable>
                    <arguments>
                        <argument>build</argument>
                        <argument>-f</argument>
                    </arguments>
                    <workingDirectory>src/main/raw_ui</workingDirectory>
                </configuration>
                <goals>
                    <goal>exec</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107

1 Answers1

2

I don't really know why this solves the problem, but after changing the phase from 'generate-sources' to 'process-classes' did the thing, it now runs only once.

I've found here: Maven plugin executes multiple times during build that certain goals can execute certain lifecycles, that's why I tried changing the phase to run node scripts.

Community
  • 1
  • 1