/** * @param parameter add a new parameter * @throws DuplicateParameterException if any */ public void addParameter( Parameter parameter ) throws DuplicateParameterException { if ( parameters != null && parameters.contains( parameter ) ) { throw new DuplicateParameterException( parameter.getName() + " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " + getImplementation() + ")" ); } if ( parameters == null ) { parameters = new LinkedList<>(); } parameters.add( parameter ); }
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 ); } }
/** * @param parameter add a new parameter * @throws DuplicateParameterException if any */ public void addParameter( Parameter parameter ) throws DuplicateParameterException { if ( parameters != null && parameters.contains( parameter ) ) { throw new DuplicateParameterException( parameter.getName() + " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " + getImplementation() + ")" ); } if ( parameters == null ) { parameters = new LinkedList<>(); } parameters.add( parameter ); }
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 ); } }
Logger mojoLogger = loggerManager.getLoggerForComponent( mojoDescriptor.getImplementation() ); ( (Mojo) mojo ).setLog( new DefaultLog( mojoLogger ) );
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); } }
private Class<?> getMojoClassForMaven2(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException { Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" ); org.codehaus.classworlds.ClassRealm cl = (org.codehaus.classworlds.ClassRealm) ReflectionUtils.invokeMethod( method, pd ); Class<?> clazz = cl.loadClass( md.getImplementation() ); return clazz; }
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); } }
/** * @param parameter add a new parameter * @throws DuplicateParameterException if any */ public void addParameter( Parameter parameter ) throws DuplicateParameterException { if ( parameters != null && parameters.contains( parameter ) ) { throw new DuplicateParameterException( parameter.getName() + " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " + getImplementation() + ")" ); } if ( parameters == null ) { parameters = new LinkedList<Parameter>(); } parameters.add( parameter ); }
private Class<?> getMojoClassForMaven2(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException { Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" ); org.codehaus.classworlds.ClassRealm cl = (org.codehaus.classworlds.ClassRealm) ReflectionUtils.invokeMethod( method, pd ); if (cl==null) { return null; } Class<?> clazz = cl.loadClass( md.getImplementation() ); return clazz; }
/** * @param parameter add a new parameter * @throws DuplicateParameterException if any */ public void addParameter( Parameter parameter ) throws DuplicateParameterException { if ( parameters != null && parameters.contains( parameter ) ) { throw new DuplicateParameterException( parameter.getName() + " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " + getImplementation() + ")" ); } if ( parameters == null ) { parameters = new LinkedList(); } parameters.add( parameter ); parameterMap = null; }
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 mojos = getComponents(); if ( mojos != null && mojos.contains( mojoDescriptor ) ) { int indexOf = mojos.indexOf( mojoDescriptor ); existing = (MojoDescriptor) 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 ); } }
private Class<?> getMojoClass(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException { try { return pd.getClassRealm().loadClass( md.getImplementation() ); } catch (NoSuchMethodError e) { // maybe we are in maven2 build ClassRealm package has changed return getMojoClassForMaven2( md, pd ); } }
private Class<?> getMojoClass(MojoDescriptor md, PluginDescriptor pd) throws ClassNotFoundException { try { ClassRealm classRealm = pd.getClassRealm(); return classRealm == null ? null : classRealm.loadClass( md.getImplementation() ); } catch (NoSuchMethodError e) { // maybe we are in maven2 build ClassRealm package has changed return getMojoClassForMaven2( md, pd ); } }
public ExecutedMojo(MojoInfo mojo, long duration) throws IOException, InterruptedException { this.groupId = mojo.pluginName.groupId; this.artifactId = mojo.pluginName.artifactId; this.version = mojo.pluginName.version; this.goal = mojo.getGoal(); this.executionId = mojo.mojoExecution.getExecutionId(); this.duration = duration; String digest = null; MojoDescriptor md = mojo.mojoExecution.getMojoDescriptor(); PluginDescriptor pd = md.getPluginDescriptor(); try { Class clazz = getMojoClass( md, pd );// pd.getClassRealm().loadClass(md.getImplementation()); digest = Util.getDigestOf(new FileInputStream(Which.jarFile(clazz))); } catch (IllegalArgumentException e) { LOGGER.log(Level.WARNING, "Failed to locate jar for "+md.getImplementation(),e); } catch (ClassNotFoundException e) { // perhaps the plugin has failed to load. } this.digest = digest; }
JClass jClass = classes.get( mojoDescriptor.getImplementation() );
JClass jClass = classes.get( mojoDescriptor.getImplementation() );
/** * @param mojoDescriptor not null * @param w not null */ private void writeReportNotice( MojoDescriptor mojoDescriptor, XMLWriter w ) { if ( GeneratorUtils.isMavenReport( mojoDescriptor.getImplementation(), project ) ) { w.startElement( "p" ); w.writeMarkup( getString( "pluginxdoc.mojodescriptor.notice.note" ) ); w.writeText( getString( "pluginxdoc.mojodescriptor.notice.isMavenReport" ) ); w.endElement(); //p } }