@Override protected void setUp() throws Exception { super.setUp(); }
@Override protected void tearDown() throws Exception { super.tearDown(); }
public PlexusContainer getContainer() { return testCase.getContainer(); }
/** * Lookup the mojo leveraging the actual subprojects pom * * @param goal * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo lookupMojo( String goal, File pom ) throws Exception { File pluginPom = new File( getBasedir(), "pom.xml" ); Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) ); String artifactId = pluginPomDom.getChild( "artifactId" ).getValue(); String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" ); String version = resolveFromRootThenParent( pluginPomDom, "version" ); PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom ); return lookupMojo( groupId, artifactId, version, goal, pluginConfiguration ); }
protected void setUp() throws Exception { assertTrue( "Maven 3.2.4 or better is required", MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 ); configurator = getContainer().lookup( ComponentConfigurator.class, "basic" ); InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() ); XmlStreamReader reader = new XmlStreamReader( is ); InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() ); PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader ); Artifact artifact = lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion(), ".jar" ); artifact.setFile( getPluginArtifactFile() ); pluginDescriptor.setPluginArtifact( artifact ); pluginDescriptor.setArtifacts( Arrays.asList( artifact ) ); for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() ) { getContainer().addComponentDescriptor( desc ); } mojoDescriptors = new HashMap<String, MojoDescriptor>(); for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() ) { mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor ); } }
/** * Lookup the mojo leveraging the actual subprojects pom * * @param goal * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo lookupEmptyMojo( String goal, File pom ) throws Exception { File pluginPom = new File( getBasedir(), "pom.xml" ); Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) ); String artifactId = pluginPomDom.getChild( "artifactId" ).getValue(); String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" ); String version = resolveFromRootThenParent( pluginPomDom, "version" ); return lookupMojo( groupId, artifactId, version, goal, null ); }
/** * Configure the mojo * * @param mojo * @param artifactId * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo configureMojo( Mojo mojo, String artifactId, File pom ) throws Exception { validateContainerStatus(); PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom ); ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub(); configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() ); return mojo; }
throws Exception validateContainerStatus(); Mojo mojo = (Mojo) lookup( Mojo.ROLE, groupId + ":" + artifactId + ":" + version + ":" + goal ); LoggerManager loggerManager = (LoggerManager) getContainer().lookup( LoggerManager.class ); configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
protected void setUp() throws Exception { configurator = getContainer().lookup( ComponentConfigurator.class, "basic" ); InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() ); XmlStreamReader reader = new XmlStreamReader( is ); InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() ); PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader ); Artifact artifact = lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion(), ".jar" ); artifact.setFile( new File( getBasedir() ).getCanonicalFile() ); pluginDescriptor.setPluginArtifact( artifact ); pluginDescriptor.setArtifacts( Arrays.asList( artifact ) ); for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() ) { getContainer().addComponentDescriptor( desc ); } mojoDescriptors = new HashMap<String, MojoDescriptor>(); for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() ) { mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor ); } }
public Mojo lookupMojo( String groupId, String artifactId, String version, String goal, PlexusConfiguration pluginConfiguration ) throws Exception { return testCase.lookupMojo( groupId, artifactId, version, goal, pluginConfiguration ); }
/** * Configure the mojo with the given plexus configuration * * @param mojo * @param pluginConfiguration * @return a Mojo instance * @throws Exception */ protected Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration ) throws Exception { validateContainerStatus(); ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub(); configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() ); return mojo; }
MojoDescriptor mojoDescriptor = execution.getMojoDescriptor(); Mojo mojo = (Mojo) lookup( mojoDescriptor.getRole(), mojoDescriptor.getRoleHint() ); configurator = getContainer().lookup( ComponentConfigurator.class, mojoDescriptor.getComponentConfigurator() ); configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
protected void setupContainer() { ContainerConfiguration cc = setupContainerConfiguration(); try { List<Module> modules = new ArrayList<Module>(); addGuiceModules( modules ); container = new DefaultPlexusContainer( cc, modules.toArray( new Module[modules.size()] ) ); } catch ( PlexusContainerException e ) { e.printStackTrace(); fail( "Failed to create plexus container." ); } }
/** * * @param goal * @return * @since 2.0 */ protected MojoExecution newMojoExecution( String goal ) { MojoDescriptor mojoDescriptor = mojoDescriptors.get( goal ); assertNotNull(String.format("The MojoDescriptor for the goal %s cannot be null.", goal), mojoDescriptor ); MojoExecution execution = new MojoExecution( mojoDescriptor ); finalizeMojoConfiguration( execution ); return execution; }
public PlexusConfiguration extractPluginConfiguration( String artifactId, File pom ) throws Exception { return testCase.extractPluginConfiguration( artifactId, pom ); }
protected void setupContainer() { ContainerConfiguration cc = setupContainerConfiguration(); try { container = new DefaultPlexusContainer( cc ); } catch ( PlexusContainerException e ) { e.printStackTrace(); fail( "Failed to create plexus container." ); } }
public Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration ) throws Exception { return testCase.configureMojo( mojo, pluginConfiguration ); }
/** * Lookup the mojo leveraging the actual subprojects pom * * @param goal * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo lookupMojo( String goal, File pom ) throws Exception { File pluginPom = new File( getBasedir(), "pom.xml" ); Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) ); String artifactId = pluginPomDom.getChild( "artifactId" ).getValue(); String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" ); String version = resolveFromRootThenParent( pluginPomDom, "version" ); PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom ); return lookupMojo( groupId, artifactId, version, goal, pluginConfiguration ); }
/** * Lookup the mojo leveraging the actual subprojects pom * * @param goal * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo lookupEmptyMojo( String goal, File pom ) throws Exception { File pluginPom = new File( getBasedir(), "pom.xml" ); Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) ); String artifactId = pluginPomDom.getChild( "artifactId" ).getValue(); String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" ); String version = resolveFromRootThenParent( pluginPomDom, "version" ); return lookupMojo( groupId, artifactId, version, goal, null ); }
/** * Configure the mojo * * @param mojo * @param artifactId * @param pom * @return a Mojo instance * @throws Exception */ protected Mojo configureMojo( Mojo mojo, String artifactId, File pom ) throws Exception { validateContainerStatus(); PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom ); ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub(); configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() ); return mojo; }