either mandate a parent pom... they will have to reference your plugin in
their pom and the execution from the pluginmgmt will be pulled in, or
custom lifecycle (they will need to ref the plugin and set extensions to
true...

themselves the only two ways to skin the cat

- Stephen

---
Sent from my Android phone, so random spelling mistakes, random nonsense
words and other nonsense are a direct result of using swype to type on the
screen
On 25 Nov 2011 22:17, "Andrew Eisenberg" <andrew.eisenb...@gmail.com> wrote:

> Hi all,
>
> I am trying to create a maven plugin that transparently adds a new
> source folder to the project.  It is always the same folder and so
> there should be no configuration required from the user.  I've been
> going through
> http://www.sonatype.com/books/mvnref-book/reference/writing-plugins.html
> , but I can't find anything that solves my problem.
>
> I created a plugin project with the following mojo:
>
>
> /**
>  * @goal add-xxx-source
>  * @phase compile
>  * @execute phase="compile"
>  */
> public class AddGroovySourceFolders extends AbstractMojo {
>    /**
>     * @parameter expression="${project}"
>     * @required
>     * @readonly
>     */
>    private MavenProject project;
>
>    public void execute() throws MojoExecutionException,
> MojoFailureException {
>        getLog().info("Adding /src/main/xxx to the list of source folders");
>        this.project.addCompileSourceRoot(project.getBasedir() +
> "/src/main/xxx");
>    }
> }
>
> Now, the only way that I can get this mojo executing is by explicitly
> adding it in the executions section of the plugin dependency:
>
>                        <plugin>
>                                <groupId>org.codehaus.groovy</groupId>
>                                <artifactId>xxx-compiler</artifactId>
>                                <version>2.6.0-01-SNAPSHOT</version>
>                                <executions>
>                                        <execution>
>                                                <id>add-source</id>
>
>  <phase>generate-sources</phase>
>                                                <goals>
>
>  <goal>add-xxx-source</goal>
>                                                </goals>
>                                        </execution>
>                                </executions>
>                        </plugin>
>
> I would like it so that consumers of my plugin can leave out the
> extensions section and have the mojo executed automatically, like
> this:
>
>                        <plugin>
>                                <groupId>org.codehaus.groovy</groupId>
>                                <artifactId>xxx-compiler</artifactId>
>                                <version>2.6.0-01-SNAPSHOT</version>
>                        </plugin>
>
> Is this possible? And how can I do this?
>
> thanks for your help.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>

Reply via email to