@Override void postExecute(MavenProject project, MojoInfo info, Exception exception) throws IOException, InterruptedException, AbortException { executedMojos.add(new ExecutedMojo(info,System.currentTimeMillis()-startTime)); for (MavenReporter r : reporters) if(!r.postExecute(buildProxy,project,info,listener,exception)) throw new AbortException(r+" failed"); }
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; }
PluginDescriptor pd = md.getPluginDescriptor(); try { Class<?> clazz = getMojoClass( md, pd ); if (clazz!=null) { File jarFile = Which.jarFile(clazz);
void postExecute(MavenProject project, MojoInfo mojoInfo, Exception exception) throws IOException, InterruptedException, hudson.maven.agent.AbortException { ModuleName name = new ModuleName(project); List<ExecutedMojo> mojoList = executedMojos.get(name); if(mojoList==null) executedMojos.put(name,mojoList=new ArrayList<ExecutedMojo>()); mojoList.add(new ExecutedMojo(mojoInfo,System.currentTimeMillis()-mojoStartTime)); MavenBuildProxy2 proxy = proxies.get(name); for (MavenReporter r : reporters.get(name)) if(!r.postExecute(proxy,project,mojoInfo,listener,exception)) throw new hudson.maven.agent.AbortException(r+" failed"); if(exception!=null) proxy.setResult(Result.FAILURE); }
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 ); } }
@Override void postExecute(MavenProject project, MojoInfo info, Exception exception) throws IOException, InterruptedException, AbortException { executedMojos.add(new ExecutedMojo(info,System.currentTimeMillis()-startTime)); for (MavenReporter r : reporters.get(moduleName)){ if(!r.postExecute(buildProxy,project,info,listener,exception)) { throw new AbortException(r+" failed"); } else if (r instanceof TestFailureDetector) { if(((TestFailureDetector) r).hasTestFailures()) { hasTestFailures.compareAndSet(false, true); } } } }
/** * Record how long it took to run this mojo. */ private void recordExecutionTime(ExecutionEvent event, MojoInfo mojoInfo) { MavenProject p = event.getProject(); List<ExecutedMojo> m = executedMojosPerModule.get(new ModuleName(p)); if (m==null) // defensive check executedMojosPerModule.put(new ModuleName(p), m=new CopyOnWriteArrayList<>()); Long startTime = getMojoStartTime( event.getProject() ); m.add(new ExecutedMojo( mojoInfo, startTime == null ? 0 : System.currentTimeMillis() - startTime )); }
void postExecute(MavenProject project, MojoInfo mojoInfo, Exception exception) throws IOException, InterruptedException, hudson.maven.agent.AbortException { ModuleName name = new ModuleName(project); List<ExecutedMojo> mojoList = executedMojos.get(name); if(mojoList==null) executedMojos.put(name,mojoList=new ArrayList<>()); mojoList.add(new ExecutedMojo(mojoInfo,System.currentTimeMillis()-mojoStartTime)); MavenBuildProxy2 proxy = proxies.get(name); for (MavenReporter r : reporters.get(name)){ if(!r.postExecute(proxy,project,mojoInfo,listener,exception)) { throw new hudson.maven.agent.AbortException(r+" failed"); } else if (r instanceof TestFailureDetector) { if(((TestFailureDetector) r).hasTestFailures()) { hasTestFailures.compareAndSet(false, true); } } } if(exception!=null) proxy.setResult(Result.FAILURE); }
/** * Lots of {@link ExecutedMojo}s tend to have the same groupId, artifactId, etc., so interning them help * with memory consumption. * * TODO: better if XStream has a declarative way of marking fields as "target for intern". */ protected Object readResolve() { return new ExecutedMojo(intern(groupId),intern(artifactId),intern(version),intern(goal),intern(executionId),duration,intern(digest)); }
new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ).add( executedMojo );
/** * Lots of {@link ExecutedMojo}s tend to have the same groupId, artifactId, etc., so interning them help * with memory consumption. * * TODO: better if XStream has a declarative way of marking fields as "target for intern". */ ExecutedMojo readResolve() { return new ExecutedMojo(intern(groupId),intern(artifactId),intern(version),intern(goal),intern(executionId),duration,intern(digest)); }
new ExecutedMojo( mojoInfo, startTime == null ? 0 : endTime.getTime() - startTime.longValue() ); this.executedMojosPerModule.get( new ModuleName( mavenProject.getGroupId(), mavenProject.getArtifactId() ) ).add( executedMojo );