public MojoDescriptor getMojo( String goal ) { if ( getMojos() == null ) { return null; // no mojo in this POM } // TODO could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to // changes above not being propagated to the map for ( MojoDescriptor desc : getMojos() ) { if ( goal.equals( desc.getGoal() ) ) { return desc; } } return null; }
public MojoDescriptor getMojo( String goal ) { if ( getMojos() == null ) { return null; // no mojo in this POM } // TODO could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to // changes above not being propagated to the map for ( MojoDescriptor desc : getMojos() ) { if ( goal.equals( desc.getGoal() ) ) { return desc; } } return null; }
private static String toMessage( String goal, PluginDescriptor pluginDescriptor ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "Could not find goal '" ).append( goal ).append( '\'' ); if ( pluginDescriptor != null ) { buffer.append( " in plugin " ).append( pluginDescriptor.getId() ); buffer.append( " among available goals " ); List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); if ( mojos != null ) { for ( Iterator<MojoDescriptor> it = mojos.iterator(); it.hasNext(); ) { MojoDescriptor mojo = it.next(); if ( mojo != null ) { buffer.append( mojo.getGoal() ); } if ( it.hasNext() ) { buffer.append( ", " ); } } } } return buffer.toString(); }
private static String toMessage( String goal, PluginDescriptor pluginDescriptor ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "Could not find goal '" ).append( goal ).append( '\'' ); if ( pluginDescriptor != null ) { buffer.append( " in plugin " ).append( pluginDescriptor.getId() ); buffer.append( " among available goals " ); List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); if ( mojos != null ) { for ( Iterator<MojoDescriptor> it = mojos.iterator(); it.hasNext(); ) { MojoDescriptor mojo = it.next(); if ( mojo != null ) { buffer.append( mojo.getGoal() ); } if ( it.hasNext() ) { buffer.append( ", " ); } } } } return buffer.toString(); }
public void addMojo( MojoDescriptor mojoDescriptor ) throws DuplicateMojoDescriptorException { MojoDescriptor existing = null; // this relies heavily on the equals() and hashCode() for ComponentDescriptor, // which uses role:roleHint for identity...and roleHint == goalPrefix:goal. // role does not vary for Mojos. List<MojoDescriptor> mojos = getMojos(); if ( mojos != null && mojos.contains( mojoDescriptor ) ) { int indexOf = mojos.indexOf( mojoDescriptor ); existing = mojos.get( indexOf ); } if ( existing != null ) { throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing.getImplementation(), mojoDescriptor.getImplementation() ); } else { addComponentDescriptor( mojoDescriptor ); } }
public void addMojo( MojoDescriptor mojoDescriptor ) throws DuplicateMojoDescriptorException { MojoDescriptor existing = null; // this relies heavily on the equals() and hashCode() for ComponentDescriptor, // which uses role:roleHint for identity...and roleHint == goalPrefix:goal. // role does not vary for Mojos. List<MojoDescriptor> mojos = getMojos(); if ( mojos != null && mojos.contains( mojoDescriptor ) ) { int indexOf = mojos.indexOf( mojoDescriptor ); existing = mojos.get( indexOf ); } if ( existing != null ) { throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing.getImplementation(), mojoDescriptor.getImplementation() ); } else { addComponentDescriptor( mojoDescriptor ); } }
protected static PluginDescriptor clone( PluginDescriptor original ) { PluginDescriptor clone = null; if ( original != null ) { clone = new PluginDescriptor(); clone.setGroupId( original.getGroupId() ); clone.setArtifactId( original.getArtifactId() ); clone.setVersion( original.getVersion() ); clone.setGoalPrefix( original.getGoalPrefix() ); clone.setInheritedByDefault( original.isInheritedByDefault() ); clone.setName( original.getName() ); clone.setDescription( original.getDescription() ); clone.setRequiredMavenVersion( original.getRequiredMavenVersion() ); clone.setPluginArtifact( ArtifactUtils.copyArtifactSafe( original.getPluginArtifact() ) ); clone.setComponents( clone( original.getMojos(), clone ) ); clone.setId( original.getId() ); clone.setIsolatedRealm( original.isIsolatedRealm() ); clone.setSource( original.getSource() ); clone.setDependencies( original.getDependencies() ); } return clone; }
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 ); } }
public MojoDescriptor getMojo( String goal ) { if ( getMojos() == null ) { return null; // no mojo in this POM } // TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to // changes above not being propagated to the map for ( MojoDescriptor desc : getMojos() ) { if ( goal.equals( desc.getGoal() ) ) { return desc; } } return null; }
public MojoDescriptor getMojo( String goal ) { if ( getMojos() == null ) { return null; // no mojo in this POM } // TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to // changes above not being propogated to the map MojoDescriptor mojoDescriptor = null; for ( Iterator i = getMojos().iterator(); i.hasNext() && mojoDescriptor == null; ) { MojoDescriptor desc = (MojoDescriptor) i.next(); if ( goal.equals( desc.getGoal() ) ) { mojoDescriptor = desc; } } return mojoDescriptor; }
/** {@inheritDoc} */ public void execute( File destinationDirectory, PluginToolsRequest request ) throws IOException { if ( request.getPluginDescriptor().getMojos() != null ) { for ( Iterator it = request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); ) { MojoDescriptor descriptor = (MojoDescriptor) it.next(); processMojoDescriptor( descriptor, destinationDirectory ); } } }
/** {@inheritDoc} */ public void execute( File destinationDirectory, PluginToolsRequest request ) throws IOException { if ( request.getPluginDescriptor().getMojos() != null ) { for ( Iterator it = request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); ) { MojoDescriptor descriptor = (MojoDescriptor) it.next(); processMojoDescriptor( descriptor, destinationDirectory ); } } }
private String getGoalName() { PluginDescriptor pluginDescriptor = getPluginDescriptor(); for (MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos()) { if (mojoDescriptor.getImplementation().equals(getClass().getName())) { return mojoDescriptor.getGoal(); } } return null; }
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException { List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); for (MojoDescriptor mojo : mojos) { if (className.equals(mojo.getImplementation())) { return mojo.getGoal(); } } throw new ComponentConfigurationException("Cannot find the goal implementation with " + className); } }
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException { List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); for (MojoDescriptor mojo : mojos) { if (className.equals(mojo.getImplementation())) { return mojo.getGoal(); } } throw new ComponentConfigurationException("Cannot find the goal implementation with " + className); } }
/** * {@inheritDoc} */ public void execute( File destinationDirectory, PluginToolsRequest request ) throws GeneratorException { try { if ( request.getPluginDescriptor().getMojos() != null ) { @SuppressWarnings( "unchecked" ) List<MojoDescriptor> mojos = request.getPluginDescriptor().getMojos(); for ( MojoDescriptor descriptor : mojos ) { processMojoDescriptor( descriptor, destinationDirectory ); } } } catch ( IOException e ) { throw new GeneratorException( e.getMessage(), e ); } }
public static Collection<MojoDescriptor> readMojos(InputStream is) throws IOException, XmlPullParserException { Reader reader = ReaderFactory.newXmlReader(is); org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor; try { pluginDescriptor = new PluginDescriptorBuilder().build(reader); } catch (PlexusConfigurationException e) { Throwables.propagateIfPossible(e.getCause(), IOException.class, XmlPullParserException.class); throw Throwables.propagate(e); } List<MojoDescriptor> result = new ArrayList<>(); for (org.apache.maven.plugin.descriptor.MojoDescriptor mojo : pluginDescriptor.getMojos()) { result.add(toMojoDescriptor(mojo)); } return result; }
public static Collection<MojoDescriptor> readMojos(InputStream is) throws IOException, XmlPullParserException { Reader reader = ReaderFactory.newXmlReader(is); org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor; try { pluginDescriptor = new PluginDescriptorBuilder().build(reader); } catch (PlexusConfigurationException e) { Throwables.propagateIfPossible(e.getCause(), IOException.class, XmlPullParserException.class); throw Throwables.propagate(e); } List<MojoDescriptor> result = new ArrayList<>(); for (org.apache.maven.plugin.descriptor.MojoDescriptor mojo : pluginDescriptor.getMojos()) { result.add(toMojoDescriptor(mojo)); } return result; }
public void addMojo( MojoDescriptor mojoDescriptor ) throws DuplicateMojoDescriptorException { MojoDescriptor existing = null; // this relies heavily on the equals() and hashCode() for ComponentDescriptor, // which uses role:roleHint for identity...and roleHint == goalPrefix:goal. // role does not vary for Mojos. List<MojoDescriptor> mojos = getMojos(); if ( mojos != null && mojos.contains( mojoDescriptor ) ) { int indexOf = mojos.indexOf( mojoDescriptor ); existing = mojos.get( indexOf ); } if ( existing != null ) { throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing .getImplementation(), mojoDescriptor.getImplementation() ); } else { addComponentDescriptor( mojoDescriptor ); } }
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 ); } }