You can develop a Mojo that will do the trick but you will have to configure it in you pom (at least define it so that it will be invoked) so I don't see the added value compared to the build-helper-plugin
Regards Jeff MAURY On Wed, Nov 30, 2011 at 7:53 PM, Andrew Eisenberg < andrew.eisenb...@gmail.com> wrote: > Thanks, Jeff and Stephen for your answers. I know about the > build-helper-maven-plugin, but this adds about 20 lines of > configuration to the pom and I was hoping to avoid that. Also, > forcing users to specify a parent pom is not feasible since users will > likely have their own parent poms to use. > > My goal is to simplify the configuration of the pom so that with just > about 3-4 lines of configuration, all the functionality happens > automatically. Are you suggesting that this is not possible? > > ps- Apologies for not responding sooner, but somehow these messages > have been ending up in my spam folder. > > On Sat, Nov 26, 2011 at 9:59 AM, Jeff MAURY <jeffma...@jeffmaury.com> > wrote: > > If you need to add source folders, there is an existing Maven plugin to > do > > it: the build-helper-maven-plugin. Check the doc at > > http://mojo.codehaus.org/build-helper-maven-plugin > > > > Regards > > Jeff MAURY > > > > On Sat, Nov 26, 2011 at 1:58 AM, Stephen Connolly < > > stephen.alan.conno...@gmail.com> wrote: > > > >> 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 > >> > > >> > > >> > > > > > > > > -- > > "Legacy code" often differs from its suggested alternative by actually > > working and scaling. > > - Bjarne Stroustrup > > > > http://www.jeffmaury.com > > http://riadiscuss.jeffmaury.com > > http://www.twitter.com/jeffmaury > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > -- "Legacy code" often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury