Get your own customer support community
 

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());
}
}
 
indifferent I’m understanding - it's just a typo from my point of view, but would be confusing to a newbie
Inappropriate?
1 person has this problem

The company marked this problem solved.


User_default_medium