Source:
<code>public Set<Project> applyChanges( final List<Project> projects, final ManipulationSession session ) throws ManipulationException { final GroovyState state = session.getState( GroovyState.class ); if ( !session.isEnabled() || !state.isEnabled() ) { logger.debug( getClass().getSimpleName() + ": Nothing to do!" ); return Collections.emptySet(); } final Set<Project> changed = new HashSet<Project>(); final List<ArtifactRef> scripts = state.getGroovyScripts(); for (ArtifactRef ar : scripts) { logger.info ("Attempting to read GAV with classifier and type ", ar.asProjectVersionRef(), ar.getClassifier(), ar.getType()); final File groovyScript = modelBuilder.resolveRawFile( ar ); Binding binding = new Binding( ); GroovyShell shell = new GroovyShell( binding ); Script script = null; for ( final Project project : projects ) { if ( project.isExecutionRoot() ) { binding.setProperty( "basedir", project.getPom().getParentFile().toString() ); binding.setProperty( "name", project.getKey() ); <START> <END> logger.info ("Executing on with binding ", groovyScript, project, binding.getVariables()); try { script = shell.parse( groovyScript ); } catch (CompilationFailedException e) { throw new ManipulationException( "Unable to parse script", e ); } catch ( IOException e ) { throw new ManipulationException( "Unable to parse script", e ); } try { script.run(); } catch ( Exception e ) { throw new ManipulationException( "Unable to parse script", e ); } changed.add( project ); } } } return changed; }</code><technical_language>bind projects too, avoid confusion in rewriting in groovy, in java...if happened, java rewrite erase changes groovy script, project in memory read of time</technical_language>

Target:
public Set<Project> applyChanges( final List<Project> projects, final ManipulationSession session ) throws ManipulationException { final GroovyState state = session.getState( GroovyState.class ); if ( !session.isEnabled() || !state.isEnabled() ) { logger.debug( getClass().getSimpleName() + ": Nothing to do!" ); return Collections.emptySet(); } final Set<Project> changed = new HashSet<Project>(); final List<ArtifactRef> scripts = state.getGroovyScripts(); for (ArtifactRef ar : scripts) { logger.info ("Attempting to read GAV with classifier and type ", ar.asProjectVersionRef(), ar.getClassifier(), ar.getType()); final File groovyScript = modelBuilder.resolveRawFile( ar ); CompilerConfiguration config = new CompilerConfiguration(); config.setScriptBaseClass(org.commonjava.maven.ext.manip.groovy.BaseScript.class.getName()); GroovyShell shell = new GroovyShell( ); Script script = null; for ( final Project project : projects ) { if ( project.isExecutionRoot() ) { logger.info ("Executing on {}", groovyScript, project); try { script = shell.parse( groovyScript ); script.invokeMethod( "setValues", new Object[] { projects, project } ); } catch (MissingMethodException e) { throw new ManipulationException( "Unable to inject values into base script", e ); } catch (CompilationFailedException e) { throw new ManipulationException( "Unable to parse script", e ); } catch ( IOException e ) { throw new ManipulationException( "Unable to parse script", e ); } try { script.run(); } catch ( Exception e ) { throw new ManipulationException( "Unable to parse script", e ); } changed.add( project ); } } } return changed; }