maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Newell <aar...@apadmi.com>
Subject Why does my mojo run twice with an @execute?
Date Wed, 29 Feb 2012 22:17:37 GMT
Hi, I have a mojo named 'forklifecycle' with the annotation

	@execute lifecycle="customlifecycle" phase="compile"

to fork a custom lifecycle which has a single other mojo in its compile
phase. When I run a project (mvn compile) with this plugin I get the
warning:

[WARNING] Removing: forklifecycle from forked lifecycle, to prevent
recursive invocation.

(in 2.0. In 3.x I get no warning, but it seems its still trying to run the
forklifecycle mojo twice).

I'm not sure why this the 'forklifecycle' goal is attempting to be run
twice, only to be removed to prevent recursion.

Could anyone tell me why the recursion is occurring?

--

My plugin project is:

pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>testgroup</groupId>
  <artifactId>some_plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>some_plugin Maven Mojo</name>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>2.0</version>
    </dependency>
  </dependencies>
</project>


My plugins:
/**
 * @goal forklifecycle
 * @execute lifecycle="customlifecycle" phase="compile"
 */
public class TestForkMojo extends AbstractMojo {
	public void execute() throws MojoExecutionException, MojoFailureException
{
		getLog().info("--> Fork cycle ran");
	}
}

/**
 * @goal test
 */
public class TestMojo extends AbstractMojo {
	public void execute() throws MojoExecutionException, MojoFailureException
{
		getLog().info("--> Test mojo ran.");
	}
}

My lifecycle:
<lifecycles>
  <lifecycle>
	<id>customlifecycle</id>
	<phases>
		<phase>
			<id>compile</id>
			<executions>
				<execution>
				  <goals>
				    <goal>test</goal>
				  </goals>     
				</execution>
			</executions>
		</phase>
	</phases>
  </lifecycle>
</lifecycles>


The project that runs this is:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>testgrouptwo</groupId>
  <artifactId>a_test</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>another_test</name>
  <build>
    <plugins>
      <plugin>
        <groupId>testgroup</groupId>
        <artifactId>some_plugin</artifactId>
        <version>1.0-SNAPSHOT</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>forklifecycle</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>












---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message