You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by fa...@mpsa.com on 2005/10/18 11:15:19 UTC

[m2] compileSourceRoots




Hi guys,

one of my dev teams uses the multiple source folder functionnality of
Eclipse (in a single project). That is, they have a project that looks
like:

MyProject
   + src_1
         + ...java packages and files...
   + src_2
         + ...java packages and files...

I've just seen that there's a "compileSourceRoots" property for the
compiler plugin, but it is read-only. How is it possible then to put the
source roots "src_1" and "src_2" in this property?

Thanks for your help!

Best Regards / Cordialement,
Fabrice BELLINGARD
DINQ/DSIN/INSI/EATE/IDVS/AIDV
(+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com


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


Re: [m2] compileSourceRoots

Posted by Jason van Zyl <ja...@maven.org>.
On Wed, 2005-10-19 at 08:11 +0800, Edwin Punzalan wrote:
> That is not possible... in pom.xml.
> 
> However, plugins that generate sources add their outputDirectory to 
> compileSourceRoots so that the compiler plugin will be able to compile 
> them along with project.build.sourceDirectory.
> 
> You might want to take a look at source generating plugins to see how 
> that works.

http://maven.apache.org/maven2/guides/mini/guide-generating-sources.html

-- 
jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org



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


Re: [m2] compileSourceRoots

Posted by Edwin Punzalan <ep...@exist.com>.
That is not possible... in pom.xml.

However, plugins that generate sources add their outputDirectory to 
compileSourceRoots so that the compiler plugin will be able to compile 
them along with project.build.sourceDirectory.

You might want to take a look at source generating plugins to see how 
that works.


fabrice.belingard@mpsa.com wrote:

>
>
>Hi guys,
>
>one of my dev teams uses the multiple source folder functionnality of
>Eclipse (in a single project). That is, they have a project that looks
>like:
>
>MyProject
>   + src_1
>         + ...java packages and files...
>   + src_2
>         + ...java packages and files...
>
>I've just seen that there's a "compileSourceRoots" property for the
>compiler plugin, but it is read-only. How is it possible then to put the
>source roots "src_1" and "src_2" in this property?
>
>Thanks for your help!
>
>Best Regards / Cordialement,
>Fabrice BELLINGARD
>DINQ/DSIN/INSI/EATE/IDVS/AIDV
>(+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org
>
>  
>

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


Re: [m2] compileSourceRoots

Posted by andrew <li...@pyroboy.com.au>.
Hi Fabrice,

You can access this property from within a plugin via the
org.apache.maven.project.MavenProject addCompileSourceRoot method.

I think the idea behind having compileSourceRoots as read-only is that
source generation should be done from within a plugin. That plugin
should then append any new source root to the project as required,
keeping the plugin self contained and not contaminating your POM.

That said, attached is a very simple example that will let you add a
source root in your POM [1].

Cheers,
...andrew

Listing 1:

package com.yourcompany.maven.plugin;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;

/**
 * @author <a href="mailto:you@yourcompany.com">You</a>
 * @version $Id$
 * @goal addCompileSourceRoot
 */
public class CompileSourceRootMojo
  extends AbstractMojo
{
  /**
   * The Maven project.
   *
   * @parameter expression="${project}"
   * @required
   * @readonly
   */
  private MavenProject project;

  /**
   * @parameter
   * @required
   */
  private String compileSourceRoot;

  public void execute()
    throws MojoExecutionException
  {
    project.addCompileSourceRoot(compileSourceRoot);
  }
}

fabrice.belingard@mpsa.com wrote:
> 
> 
> 
> Hi guys,
> 
> one of my dev teams uses the multiple source folder functionnality of
> Eclipse (in a single project). That is, they have a project that looks
> like:
> 
> MyProject
>    + src_1
>          + ...java packages and files...
>    + src_2
>          + ...java packages and files...
> 
> I've just seen that there's a "compileSourceRoots" property for the
> compiler plugin, but it is read-only. How is it possible then to put the
> source roots "src_1" and "src_2" in this property?
> 
> Thanks for your help!
> 
> Best Regards / Cordialement,
> Fabrice BELLINGARD
> DINQ/DSIN/INSI/EATE/IDVS/AIDV
> (+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 

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