views:

200

answers:

1

I have a Maven POM file with a plugin that runs on the test phase. What command line arguments do I have to pass mvn in order to execute just that plugin rather than all of the plugins for that phase? I am also trying to execute a specific ant-run plugin, that looks like the following:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <dependencies>
          <dependency>
            <groupId>com.googlecode.jslint4java</groupId>
            <artifactId>jslint4java-ant</artifactId>
            <version>1.3.3</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>jslint</id>
            <phase>test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <ant antfile="${basedir}/jslint.xml">
                  <property name="root" location="${basedir}" />
                  <target name="jslint" />
                </ant>
              </tasks>
            </configuration>
          </execution>
        </executions>
    </plugin>

Thanks.

A: 

Specify the fully-qualified goal in the form of:

mvn groupID:artifactID:version:goal

For example:

mvn sample.plugin:maven-hello-plugin:1.0-SNAPSHOT:sayhi

EDIT: I'm modifying my answer to cover the update of the initial question and a comment from the OP.

I won't cover all the details but, it the particular case of the antrun plugin, you could just run:

mvn antrun:run

But now that you've updated the question, I understand that things are a bit more complicated than what I thought initially and I don't think that this will actually work. I mean, invoking mvn antrun:run won't fail but it won't pick up the configuration of the execution bound to the test phase.

The only (ugly) solution I can think of would be to add another maven-antrun-plugin configuration in a specific profile, something like this:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.3</version>
    <dependencies>
      <dependency>
        <groupId>com.googlecode.jslint4java</groupId>
        <artifactId>jslint4java-ant</artifactId>
        <version>1.3.3</version>
      </dependency>
    </dependencies>
    <configuration>
      <tasks>
        <ant antfile="${basedir}/jslint.xml">
          <property name="root" location="${basedir}" />
          <target name="jslint" />
        </ant>
      </tasks>
    </configuration>
  </plugin>

And to use this profile when calling antrun:run:

mvn antrun:run -Pmyprofile-for-antrun
Pascal Thivent
thanks Pascal, any hints on the commands for executing the specific ant run plugin?
Simon Kenyon Shepard
Thanks Pascal, I had a feeling that it might have to involve a profile hack in order to work. Damn. Hopefully soon the JSLint Plugin will get a dedicated Mojo for it. I think one is currently in the works.
Simon Kenyon Shepard