You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kallin Nagelberg <ka...@gmail.com> on 2007/12/20 05:17:51 UTC

generated sources convention

I'm working on adapting some source generation code into the maven
lifecycle. I've written a plugin that is generating the sources (albeit at
random places) and bound it to the generate sources phase.
I've read in a couple places that the standard location is
target/generated-sources/<plugin-id>. However, the compiler plugin doesn't
check this directory. I could always just ensure these directories are
explicitly added for compilation, but I wanted to check if there was any
convention (besides generating into src/main/java) that would allow the
compilation to occur automatically.

Thanks

RE: generated sources convention

Posted by William Ferguson <Wi...@yarris.com>.
Kallin,

You need to tell Maven that the location of your generated source should
be included as part of the build. Ie

	/**
	 * @parameter default-value="${project}"
	 * @required
	 * @readonly
	 */
	private MavenProject project;

	/**
	 * @parameter
default-value="${project.build.directory}/generated-sources/myPluginId"
	 * @required
	 * @readonly
	 */
	private File sourceDirectoryPath;

	...

	project.addCompileSourceRoot(sourceDirectoryPath);

Have a read of "Better builds with Maven" page 148.

William 

> -----Original Message-----
> From: Kallin Nagelberg [mailto:kallin.nagelberg@gmail.com] 
> Sent: Thursday, 20 December 2007 2:18 PM
> To: users@maven.apache.org
> Subject: [***POSSIBLE SPAM***] - generated sources convention 
> - Sender is forged (SPF Fail)
> 
> I'm working on adapting some source generation code into the 
> maven lifecycle. I've written a plugin that is generating the 
> sources (albeit at random places) and bound it to the 
> generate sources phase.
> I've read in a couple places that the standard location is 
> target/generated-sources/<plugin-id>. However, the compiler 
> plugin doesn't check this directory. I could always just 
> ensure these directories are explicitly added for 
> compilation, but I wanted to check if there was any 
> convention (besides generating into src/main/java) that would 
> allow the compilation to occur automatically.
> 
> Thanks
> 

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


Re: generated sources convention

Posted by nicolas de loof <ni...@apache.org>.
I'm working on such a mojo API extension (or anything else) to fix this
issue with the eclipse plugin. @see my post on dev@maven.apache.org

Nico.

2007/12/20, Milos Kleint <mk...@gmail.com>:
>
> at least the netbeans ide plugin will not run any phases when opening a
> project. it relies solely on the convention. Ideally the plugin
> description
> would include a marker on mojo parameters that make a generated source
> root
> directory. That way one can check the actual location without running the
> build.
>
> Milos
>
> On Dec 20, 2007 3:14 PM, nicolas de loof <ni...@apache.org> wrote:
>
> > The eclipse plugin (not sure other IDE-plugins do same) will run a
> > pre-build
> > (generate-resources phase) to let all code-generator declare
> > compileSourceRoots. This also aplies to maven-helper-plugin.
> >
> > Based on this you MAY use whatever generate folder you like. The
> > "convention" is to use
> > target/generated-sources/generator-name, as it was required with maven1
> > IDE
> > plugins to detect generated source folders.
> >
> > Nico.
> >
> > 2007/12/20, Milos Kleint <mk...@gmail.com>:
> > >
> > > The convention is useful for the IDE integration that can check that
> > > target/generated-sources subfolders and add them to source path
> without
> > > actually requiring to build the project.
> > >
> > > Milos
> > >
> > > On Dec 20, 2007 2:43 PM, Kallin Nagelberg <ka...@gmail.com>
> > > wrote:
> > >
> > > > Thanks guys. I've already got it working with the build helper
> plugin,
> > > but
> > > > was hoping there was some convention i could use to avoid it.
> > Hopefully
> > > > the
> > > > maven guys move to add one eventually.
> > > >
> > > > On Dec 20, 2007 8:15 AM, Rémy Sanlaville <re...@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > Use the *build* *helper* *plugin* to add additional source paths
> > > > > http://mojo.codehaus.org/*build*-*helper*-maven-*plugin*/<
> > > > > http://mojo.codehaus.org/build-helper-maven-plugin/>
> > > > > cf.
> > > > >
> > > > >
> > > >
> > >
> >
> http://www.nabble.com/Second-source-directory-for-generated-code-to6446457s177.html#a6446995
> > > > >
> > > > >
> > > > > Rémy
> > > > >
> > > >
> > >
> >
>

Re: generated sources convention

Posted by Milos Kleint <mk...@gmail.com>.
at least the netbeans ide plugin will not run any phases when opening a
project. it relies solely on the convention. Ideally the plugin description
would include a marker on mojo parameters that make a generated source root
directory. That way one can check the actual location without running the
build.

Milos

On Dec 20, 2007 3:14 PM, nicolas de loof <ni...@apache.org> wrote:

> The eclipse plugin (not sure other IDE-plugins do same) will run a
> pre-build
> (generate-resources phase) to let all code-generator declare
> compileSourceRoots. This also aplies to maven-helper-plugin.
>
> Based on this you MAY use whatever generate folder you like. The
> "convention" is to use
> target/generated-sources/generator-name, as it was required with maven1
> IDE
> plugins to detect generated source folders.
>
> Nico.
>
> 2007/12/20, Milos Kleint <mk...@gmail.com>:
> >
> > The convention is useful for the IDE integration that can check that
> > target/generated-sources subfolders and add them to source path without
> > actually requiring to build the project.
> >
> > Milos
> >
> > On Dec 20, 2007 2:43 PM, Kallin Nagelberg <ka...@gmail.com>
> > wrote:
> >
> > > Thanks guys. I've already got it working with the build helper plugin,
> > but
> > > was hoping there was some convention i could use to avoid it.
> Hopefully
> > > the
> > > maven guys move to add one eventually.
> > >
> > > On Dec 20, 2007 8:15 AM, Rémy Sanlaville <re...@gmail.com>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > Use the *build* *helper* *plugin* to add additional source paths
> > > > http://mojo.codehaus.org/*build*-*helper*-maven-*plugin*/<
> > > > http://mojo.codehaus.org/build-helper-maven-plugin/>
> > > > cf.
> > > >
> > > >
> > >
> >
> http://www.nabble.com/Second-source-directory-for-generated-code-to6446457s177.html#a6446995
> > > >
> > > >
> > > > Rémy
> > > >
> > >
> >
>

Re: generated sources convention

Posted by nicolas de loof <ni...@apache.org>.
The eclipse plugin (not sure other IDE-plugins do same) will run a pre-build
(generate-resources phase) to let all code-generator declare
compileSourceRoots. This also aplies to maven-helper-plugin.

Based on this you MAY use whatever generate folder you like. The
"convention" is to use
target/generated-sources/generator-name, as it was required with maven1 IDE
plugins to detect generated source folders.

Nico.

2007/12/20, Milos Kleint <mk...@gmail.com>:
>
> The convention is useful for the IDE integration that can check that
> target/generated-sources subfolders and add them to source path without
> actually requiring to build the project.
>
> Milos
>
> On Dec 20, 2007 2:43 PM, Kallin Nagelberg <ka...@gmail.com>
> wrote:
>
> > Thanks guys. I've already got it working with the build helper plugin,
> but
> > was hoping there was some convention i could use to avoid it. Hopefully
> > the
> > maven guys move to add one eventually.
> >
> > On Dec 20, 2007 8:15 AM, Rémy Sanlaville <re...@gmail.com>
> > wrote:
> >
> > > Hi,
> > >
> > > Use the *build* *helper* *plugin* to add additional source paths
> > > http://mojo.codehaus.org/*build*-*helper*-maven-*plugin*/<
> > > http://mojo.codehaus.org/build-helper-maven-plugin/>
> > > cf.
> > >
> > >
> >
> http://www.nabble.com/Second-source-directory-for-generated-code-to6446457s177.html#a6446995
> > >
> > >
> > > Rémy
> > >
> >
>

Re: generated sources convention

Posted by Milos Kleint <mk...@gmail.com>.
The convention is useful for the IDE integration that can check that
target/generated-sources subfolders and add them to source path without
actually requiring to build the project.

Milos

On Dec 20, 2007 2:43 PM, Kallin Nagelberg <ka...@gmail.com>
wrote:

> Thanks guys. I've already got it working with the build helper plugin, but
> was hoping there was some convention i could use to avoid it. Hopefully
> the
> maven guys move to add one eventually.
>
> On Dec 20, 2007 8:15 AM, Rémy Sanlaville <re...@gmail.com>
> wrote:
>
> > Hi,
> >
> > Use the *build* *helper* *plugin* to add additional source paths
> > http://mojo.codehaus.org/*build*-*helper*-maven-*plugin*/<
> > http://mojo.codehaus.org/build-helper-maven-plugin/>
> > cf.
> >
> >
> http://www.nabble.com/Second-source-directory-for-generated-code-to6446457s177.html#a6446995
> >
> >
> > Rémy
> >
>

Re: generated sources convention

Posted by Kallin Nagelberg <ka...@gmail.com>.
Thanks guys. I've already got it working with the build helper plugin, but
was hoping there was some convention i could use to avoid it. Hopefully the
maven guys move to add one eventually.

On Dec 20, 2007 8:15 AM, Rémy Sanlaville <re...@gmail.com> wrote:

> Hi,
>
> Use the *build* *helper* *plugin* to add additional source paths
> http://mojo.codehaus.org/*build*-*helper*-maven-*plugin*/<
> http://mojo.codehaus.org/build-helper-maven-plugin/>
> cf.
>
> http://www.nabble.com/Second-source-directory-for-generated-code-to6446457s177.html#a6446995
>
>
> Rémy
>

Re: generated sources convention

Posted by Rémy Sanlaville <re...@gmail.com>.
Hi,

Use the *build* *helper* *plugin* to add additional source paths
http://mojo.codehaus.org/*build*-*helper*-maven-*plugin*/<http://mojo.codehaus.org/build-helper-maven-plugin/>
cf.
http://www.nabble.com/Second-source-directory-for-generated-code-to6446457s177.html#a6446995


Rémy