17.4.2 A Simple Mojo -- missing @requiresProject false
In chapter 17.4.2 A Simple Java Mojo, the echo mojo will not run outside a project.
I did the mvn install using m2eclipse and the resultant default property for xxx was true so the echo mojo didn't work outside a project.
I changed the source as shown below so that the echo mojo will run outside a project:
-- the new line is:
* @requiresProject false
package org.sonatype.mavenbook.plugins;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* Echos an object string to the output screen.
*
* @goal echo
* @requiresProject false
*/
public class EchoMojo extends AbstractMojo {
/**
* Any Object to print out.
*
* @parameter expression="${echo.message}" default-value="Hello World..."
*/
private Object message;
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info(message.toString());
}
}
I did the mvn install using m2eclipse and the resultant default property for xxx was true so the echo mojo didn't work outside a project.
I changed the source as shown below so that the echo mojo will run outside a project:
-- the new line is:
* @requiresProject false
package org.sonatype.mavenbook.plugins;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* Echos an object string to the output screen.
*
* @goal echo
* @requiresProject false
*/
public class EchoMojo extends AbstractMojo {
/**
* Any Object to print out.
*
* @parameter expression="${echo.message}" default-value="Hello World..."
*/
private Object message;
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info(message.toString());
}
}
1
person has this problem
I have this problem, too!
Tell me when someone solves it.
The more people who report this problem, the more it gets noticed.
The more people who report this problem, the more it gets noticed.
The company marked this problem solved.
-
Inappropriate?Pat, thanks for reporting this, I've added this annotation to the ch17 EchoMojo example, and I've updated the online book.
I’m happy
The company says
this solves the problem
Loading Profile...



EMPLOYEE