You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Paul Benedict (JIRA)" <ji...@codehaus.org> on 2014/07/02 15:44:36 UTC

[jira] (MNG-1945) project.getBuild().setSourceDirectory() should modify the compile source roots automatically

     [ https://jira.codehaus.org/browse/MNG-1945?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated MNG-1945:
-------------------------------

    Fix Version/s:     (was: Issues to be reviewed for 3.x)

> project.getBuild().setSourceDirectory() should modify the compile source roots automatically
> --------------------------------------------------------------------------------------------
>
>                 Key: MNG-1945
>                 URL: https://jira.codehaus.org/browse/MNG-1945
>             Project: Maven
>          Issue Type: Improvement
>          Components: POM
>    Affects Versions: 2.0.1
>            Reporter: Vincent Massol
>            Assignee: Jason van Zyl
>
> Here's the code that I have in the clover plugin right now:
>     private void redirectSourceDirectories()
>     {
>         String oldSourceDirectory = this.project.getBuild().getSourceDirectory();
>         this.project.getBuild().setSourceDirectory( this.cloverOutputSourceDirectory );
>         
>         // Maven2 limitation: changing the source directory doesn't change the compile source roots
>         Iterator sourceRoots = this.project.getCompileSourceRoots().iterator();
>         for (int i = 0; sourceRoots.hasNext(); i++)
>         {
>             String sourceRoot = (String) this.project.getCompileSourceRoots().get( i );
>             if (sourceRoot.equals(oldSourceDirectory))
>             {
>                 this.project.getCompileSourceRoots().remove( i );
>                 // Note: Ideally we should add the new compile source root at the same place as the
>                 // one we're removing but there's no API for this...
>                 this.project.addCompileSourceRoot( this.project.getBuild().getSourceDirectory() );
>             }
>         }
>     }
> I believe this could be put in Maven core.



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)