@Test public void testGroovyExceptions() throws Exception { final File groovy = TestUtils.resolveFileResource( "", "GroovyExceptions.groovy" ); final File pom = new File( ROOT_DIRECTORY.toFile(), "pom.xml" ); final File tmpFolder = temporaryFolder.newFolder(); FileUtils.copyFileToDirectory( pom, tmpFolder); List<Project> projects = new PomIO().parseProject( new File (tmpFolder, "pom.xml" )); Properties userProperties = new Properties(); userProperties.setProperty( "versionIncrementalSuffix", "rebuild" ); userProperties.setProperty( "groovyScripts", groovy.toURI().toString() ); ManipulationSession session = TestUtils.createSession( userProperties ); VersioningState state = session.getState( VersioningState.class ); assertNotNull( state ); assertTrue( state.isEnabled() ); assertEquals( "rebuild", state.getIncrementalSerialSuffix() ); assertNull( state.getSuffix() ); Project root = projects.stream().filter( p -> p.getProjectParent() == null ).findAny().orElse( null ); logger.info( "Found project root " + root ); final DefaultContainerConfiguration config = new DefaultContainerConfiguration(); config.setClassPathScanning( PlexusConstants.SCANNING_ON ); config.setComponentVisibility( PlexusConstants.GLOBAL_VISIBILITY ); config.setName( "PME-TEST" ); final PlexusContainer container = new DefaultPlexusContainer( config ); InitialGroovyManipulator gm = container.lookup( InitialGroovyManipulator.class ); FileIO fileIO = new FileIO( new GalleyInfrastructure( session, null).init( null, null, temporaryFolder.newFolder( "cache-dir" ) )) ; FieldUtils.writeField( gm, "fileIO", fileIO, true ); gm.init( session ); session.getUserProperties().setProperty( "manipExcep", "true" ); try { gm.applyChanges( projects ); fail("No exception thrown"); } catch ( ManipulationException ex ) { assertTrue( ex.getCause() == null && ex.getMessage().contains( "Manip Except" ) ); } session.getUserProperties().setProperty( "manipExcep", "false" ); try { gm.applyChanges( projects ); fail("No exception thrown"); } catch ( ManipulationException ex ) { assertTrue( ex.getMessage().contains( "Problem running script" ) ); assertTrue( ex.getCause().getMessage().contains( "IO problems" ) ); } }
public Properties getUserProperties() { return userProperties; }
BaseScript extends BaseScriptUtils { public Properties getUserProperties() { return userProperties; } }
BaseScript extends BaseScriptUtils { public Properties getUserProperties() { return userProperties; }  }
BaseScript extends BaseScriptUtils { public Properties getUserProperties() { return userProperties; }  Project getProject(); List<Project> getProjects(); ProjectVersionRef getGAV(); File getBaseDir(); Properties getUserProperties(); MavenSessionHandler getSession(); InvocationStage getInvocationStage(); void setValues(PomIO pomIO, FileIO fileIO, ModelIO modelIO, ManipulationSession session, List<Project> projects, Project project,
                          InvocationStage stage); }
BaseScript extends BaseScriptUtils { public Properties getUserProperties() { return userProperties; }  Project getProject(); List<Project> getProjects(); ProjectVersionRef getGAV(); File getBaseDir(); Properties getUserProperties(); MavenSessionHandler getSession(); InvocationStage getInvocationStage(); void setValues(PomIO pomIO, FileIO fileIO, ModelIO modelIO, ManipulationSession session, List<Project> projects, Project project,
                          InvocationStage stage);  }