2

I have added a couple of new plugins to a maven pom.xml file.

I have not been able to figure out why exec-maven-plugin and maven-resources-plugin they aren't running when I issue the command: mvn install. The other maven plugins do execute as expected.

When I run mvn exec:exec, exec-maven-plugin does indeed get run.

I have tried using a number of different phases, to no avail.

What am I doing wrong here, and what should I try?


Here is the relevant section of my maven file

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <id>build-spa-bower</id>
                <phase>validate</phase>
                <configuration>
                    <executable>bower</executable>
                    <arguments>install</arguments>
                    <workingDirectory>src/main/spa</workingDirectory>
                </configuration>
            </execution>
            <execution>
                <id>build-spa-grunt</id>
                <phase>validate</phase>
                <configuration>
                    <executable>bower</executable>
                    <arguments>install</arguments>
                    <workingDirectory>src/main/spa</workingDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
                <id>resource-spa</id>
                <phase>compile</phase>
                <configuration>
                    <outputDirectory>${project.groupId}/${project.artifactId}/spa</outputDirectory>
                    <resources>
                        <directory>src/main/spa/dist</directory>
                        <filtering>false</filtering>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <!-- ... -->
</plugins>

EDIT:

found answer for exec plugin, but not yet for resources plugin.

The exec plugin requires a goal in order to trigger

adding <goals><goal>exec</goal></goals> to each <execution> did the trick for me.

bguiz
  • 27,371
  • 47
  • 154
  • 243

3 Answers3

2

If you put your configuration in an <execution/> you need to specify which goals need to run in this execution.

For plugins that are linked to a phase by default, you can also specify the configuration outside the <executions/> and that configuration will be used during the default phases of that plugin.

GeertPt
  • 16,398
  • 2
  • 37
  • 61
  • Ha, came up with the answer at the same time! +1 and check to you. Yes, specifying the goals did the trick. Am a newbie at maven, pardon the beginner question! (My own solution here: http://stackoverflow.com/a/22393391/194982 ) – bguiz Mar 13 '14 at 23:49
  • ... and if you could, I would appreciate it if you could answer a follow up question I have on exec-maven-plugin: http://stackoverflow.com/questions/22393785/exec-maven-plugin-says-cannot-run-specified-program-even-though-it-is-on-the-pa – bguiz Mar 14 '14 at 00:23
0

Found answers:

The exec plugin requires a goal in order to trigger.

Add <goals><goal>exec</goal></goals> to each <execution>.

The resources plugin problem was fixed similarly.

Add <goals><goal>copy-resources</goal></goals> to each <execution>.

These did the trick for me.

bguiz
  • 27,371
  • 47
  • 154
  • 243
0

Also

<phase>prepare-package</phase>

is compulsory.

Jack
  • 193
  • 11