You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alexander Hars <do...@inventivio.com> on 2006/08/09 16:24:58 UTC

Compiler plugin: trying to set compileSourceRoots

Hi,

I am trying to specify multiple source locations for the compiler-plugin 
(goal: test-compile). How do I accomplish that?

I have tried to set the compileSourceRoots in the configuration of the 
compiler plugin:
<configuration>
  <compileSourceRoots>src/test/main;src/test2/main</compileSourceRoots>
</configuration>

But I always get an error:
  Cannot override read-only parameter: compileSourceRoots

Is there a different way by which I can set the property
  project.testCompileSourceRoots
separately?

Thanks,

 Alexander

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


RE: Compiler plugin: trying to set compileSourceRoots

Posted by Denis Cabasson <de...@insee.fr>.

Ian Springer wrote:
> 
> | -----Original Message-----
> | From: Denis Cabasson [mailto:denis.cabasson@insee.fr] 
> | Sent: Wednesday, August 09, 2006 11:07 AM
> | To: users@maven.apache.org
> | Subject: Re: Compiler plugin: trying to set compileSourceRoots
> | 
> | Alexander Hars wrote:
> | > 
> | > Hi,
> | > 
> | > I am trying to specify multiple source locations for the 
> | compiler-plugin 
> | > (goal: test-compile). How do I accomplish that?
> | > 
> | > I have tried to set the compileSourceRoots in the 
> | configuration of the 
> | > compiler plugin:
> | > <configuration>
> | >   
> | <compileSourceRoots>src/test/main;src/test2/main</compileSourceRoots>
> | > </configuration>
> | > 
> | > But I always get an error:
> | >   Cannot override read-only parameter: compileSourceRoots
> | > 
> | > Is there a different way by which I can set the property
> | >   project.testCompileSourceRoots
> | > separately?
> | > 
> | > Thanks,
> | > 
> | >  Alexander
> | > 
> | 
> | You can't do that in the compiler plugin.
> | You have to do you own custom maven plugin if you want to add 
> | sources to the
> | compile phase.
> | 
> | Sample mojo (kudos to emmanuel Venisse):
> | public class AddSourcesDirectoryMojo
> |     extends AbstractMojo
> | {
> |     /**
> |      * @parameter
> |      */
> |     private List sources;
> |     
> |     /**
> |      * @parameter expression="${project}"
> |      *
> |      * @required
> |      */
> |     private MavenProject project;
> | 
> |     public void execute()
> |         throws MojoExecutionException
> |     {
> |         if ( project != null && sources != null )
> |         {
> |             for ( Iterator i = sources.iterator(); i.hasNext(); )
> |             {
> |                 String sourceDirectory = (String) i.next();
> |                 project.addCompileSourceRoot( sourceDirectory );
> |             }
> |         }
> |     }
> | }
> | 
> | Denis.
> | -- 
> 
> 
> Or you can use the build-helper plugin -
> http://mojo.codehaus.org/build-helper-maven-plugin/howto.html
> 
> -Ian
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

I didn't know of a plugin doing this! Seems nice enough and should do
exactly the job.

Of course, an existing plugin is always prefered to a home made one.

Denis.

-- 
View this message in context: http://www.nabble.com/Compiler-plugin%3A-trying-to-set-compileSourceRoots-tf2079114.html#a5728267
Sent from the Maven - Users forum at Nabble.com.


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


Re: Compiler plugin: trying to set compileSourceRoots

Posted by Denis Cabasson <de...@insee.fr>.

Alexander Hars wrote:
> 
> Hi,
> 
> I am trying to specify multiple source locations for the compiler-plugin 
> (goal: test-compile). How do I accomplish that?
> 
> I have tried to set the compileSourceRoots in the configuration of the 
> compiler plugin:
> <configuration>
>   <compileSourceRoots>src/test/main;src/test2/main</compileSourceRoots>
> </configuration>
> 
> But I always get an error:
>   Cannot override read-only parameter: compileSourceRoots
> 
> Is there a different way by which I can set the property
>   project.testCompileSourceRoots
> separately?
> 
> Thanks,
> 
>  Alexander
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

You can't do that in the compiler plugin.
You have to do you own custom maven plugin if you want to add sources to the
compile phase.

Sample mojo (kudos to emmanuel Venisse):
public class AddSourcesDirectoryMojo
    extends AbstractMojo
{
    /**
     * @parameter
     */
    private List sources;
    
    /**
     * @parameter expression="${project}"
     *
     * @required
     */
    private MavenProject project;

    public void execute()
        throws MojoExecutionException
    {
        if ( project != null && sources != null )
        {
            for ( Iterator i = sources.iterator(); i.hasNext(); )
            {
                String sourceDirectory = (String) i.next();
                project.addCompileSourceRoot( sourceDirectory );
            }
        }
    }
}

Denis.
-- 
View this message in context: http://www.nabble.com/Compiler-plugin%3A-trying-to-set-compileSourceRoots-tf2079114.html#a5727585
Sent from the Maven - Users forum at Nabble.com.


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