protected void setSourceDirectoryForAllMojo ( File newSourceDirectory ) { final List < String > sourceRoots = this . mavenProject . getCompileSourceRoots ( ) ; getLog ( ) . debug ( "Old source roots: " + sourceRoots . toString ( ) ) ; //$NON-NLS-1$ final Iterator < String > iterator = sourceRoots . iterator ( ) ; final String removableSourcePath = this . javaSourceRoot . getAbsolutePath ( ) ; getLog ( ) . debug ( "Removable source root: " + removableSourcePath ) ; //$NON-NLS-1$ String path ; while ( iterator . hasNext ( ) ) { path = iterator . next ( ) ; if ( path != null && path . equals ( removableSourcePath ) ) { getLog ( ) . debug ( "Removing source root: " + path ) ; //$NON-NLS-1$ iterator . remove ( ) ; } } getLog ( ) . debug ( "Adding source root: " + newSourceDirectory . getAbsolutePath ( ) ) ; //$NON-NLS-1$ this . mavenProject . addCompileSourceRoot ( newSourceDirectory . toString ( ) ) ; this . sourceDirectory = newSourceDirectory ; }
Replace the current source directory by the given directory .