@Override public synchronized void delete() throws IOException { super.delete(); // Delete all contained module builds too for (List<MavenBuild> list : getModuleBuilds().values()) for (MavenBuild build : list) build.delete(); }
@Override public MavenModuleSet getParent() {// don't know why, but javac wants this return super.getParent(); }
/** * Exposes {@code MAVEN_OPTS} to forked processes. * * When we fork Maven, we do so directly by executing Java, thus this environment variable * is pointless (we have to tweak JVM launch option correctly instead, which can be seen in * {@link MavenProcessFactory}), but setting the environment variable explicitly is still * useful in case this Maven forks other Maven processes via normal way. See HUDSON-3644. */ @Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars envs = super.getEnvironment(log); String opts = project.getMavenOpts(); if(opts!=null) envs.put("MAVEN_OPTS", opts); return envs; }
/** * If the parent {@link MavenModuleSetBuild} is kept, keep this record, too. */ @Override public String getWhyKeepLog() { MavenModuleSetBuild pb = getParentBuild(); if(pb!=null && pb.getWhyKeepLog()!=null) return Messages.MavenBuild_KeptBecauseOfParent(pb); return super.getWhyKeepLog(); }
@Override public Fingerprint.RangeSet getDownstreamRelationship(AbstractProject that) { Fingerprint.RangeSet rs = super.getDownstreamRelationship(that); for(List<MavenBuild> builds : getModuleBuilds().values()) for (MavenBuild b : builds) rs.add(b.getDownstreamRelationship(that)); return rs; }
@Override public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { // map corresponding module build under this object if(token.indexOf('$')>0) { MavenModule m = getProject().getModule(token); if(m!=null) return m.getBuildByNumber(getNumber()); } return super.getDynamic(token,req,rsp); }
@Override public String getUpUrl() { StaplerRequest req = Stapler.getCurrentRequest(); if(req!=null) { List<Ancestor> ancs = req.getAncestors(); for( int i=1; i<ancs.size(); i++) { if(ancs.get(i).getObject()==this) { if(ancs.get(i-1).getObject() instanceof MavenModuleSetBuild) { // if under MavenModuleSetBuild, "up" means MMSB return ancs.get(i-1).getUrl()+'/'; } } } } return super.getUpUrl(); }
@Override public String getDisplayName() { StaplerRequest req = Stapler.getCurrentRequest(); if(req!=null) { List<Ancestor> ancs = req.getAncestors(); for( int i=1; i<ancs.size(); i++) { if(ancs.get(i).getObject()==this) { if(ancs.get(i-1).getObject() instanceof MavenModuleSetBuild) { // if under MavenModuleSetBuild, display the module name return getParent().getDisplayName(); } } } } return super.getDisplayName(); }
/** * Displays the combined status of all modules. * <p> * More precisely, this picks up the status of this build itself, * plus all the latest builds of the modules that belongs to this build. */ @Override public Result getResult() { Result r = super.getResult(); for (MavenBuild b : getModuleLastBuilds().values()) { Result br = b.getResult(); if(r==null) r = br; else if(br==Result.NOT_BUILT) continue; // UGLY: when computing combined status, ignore the modules that were not built else if(br!=null) r = r.combine(br); } return r; }
return super.getEstimatedDuration(); return super.getEstimatedDuration();
/** * Exposes {@code MAVEN_OPTS} to forked processes. * * <p> * See {@link MavenModuleSetBuild#getEnvironment(TaskListener)} for discussion. */ @Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars envs = super.getEnvironment(log); String opts = project.getParent().getMavenOpts(); if(opts!=null) envs.put("MAVEN_OPTS", opts); return envs; }
/** * If the parent {@link MavenModuleSetBuild} is kept, keep this record, too. */ @Override public String getWhyKeepLog() { MavenModuleSetBuild pb = getParentBuild(); if(pb!=null && pb.getWhyKeepLog()!=null) return Messages.MavenBuild_KeptBecauseOfParent(pb); return super.getWhyKeepLog(); }
@Override public Fingerprint.RangeSet getDownstreamRelationship(@SuppressWarnings("rawtypes") AbstractProject that) { Fingerprint.RangeSet rs = super.getDownstreamRelationship(that); for(List<MavenBuild> builds : getModuleBuilds().values()) for (MavenBuild b : builds) rs.add(b.getDownstreamRelationship(that)); return rs; }
@Override public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { // map corresponding module build under this object if(token.indexOf('$')>0) { MavenModule m = getProject().getModule(token); if(m!=null) return m.getBuildByNumber(getNumber()); } return super.getDynamic(token,req,rsp); }
@Override public String getUpUrl() { StaplerRequest req = Stapler.getCurrentRequest(); if(req!=null) { List<Ancestor> ancs = req.getAncestors(); for( int i=1; i<ancs.size(); i++) { if(ancs.get(i).getObject()==this) { if(ancs.get(i-1).getObject() instanceof MavenModuleSetBuild) { // if under MavenModuleSetBuild, "up" means MMSB return ancs.get(i-1).getUrl()+'/'; } } } } return super.getUpUrl(); }
@Override public String getDisplayName() { StaplerRequest req = Stapler.getCurrentRequest(); if(req!=null) { List<Ancestor> ancs = req.getAncestors(); for( int i=1; i<ancs.size(); i++) { if(ancs.get(i).getObject()==this) { if(ancs.get(i-1).getObject() instanceof MavenModuleSetBuild) { // if under MavenModuleSetBuild, display the module name return getParent().getDisplayName(); } } } } return super.getDisplayName(); }
private Result computeResult() { Result r = super.getResult(); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("Current result is: " + r); } for (MavenBuild b : getModuleLastBuilds().values()) { Result br = b.getResult(); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("Module result is: " + br + " for " + b.getParent().getGroupId() + ":" + b.getParent().getArtifactId()); } if (r == null) { r = br; } else if (br == Result.NOT_BUILT || br == Result.ABORTED) { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("Result not updated: " + r); } continue; // UGLY: when computing combined status, ignore the modules that were not built } else if (br != null) { r = r.combine(br); } if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("New result is: " + r); } } return r; }
/** * Returns the estimated duration for this builds. * Takes only the modules into account which are actually being build in * case of incremental builds. */ @Override public long getEstimatedDuration() { if (!project.isIncrementalBuild()) { return super.getEstimatedDuration(); } long result = 0; Map<MavenModule, List<MavenBuild>> moduleBuilds = getModuleBuilds(); for (List<MavenBuild> builds : moduleBuilds.values()) { if (!builds.isEmpty()) { MavenBuild build = builds.get(0); if (build.getResult() != Result.NOT_BUILT && build.getEstimatedDuration() != -1) { result += build.getEstimatedDuration(); } } } result += estimateModuleSetBuildDurationOverhead(3); return result != 0 ? result : -1; }
@Override public MavenModule getParent() {// don't know why, but javac wants this return super.getParent(); }
/** * Exposes {@code MAVEN_OPTS} to forked processes. * * <p> * See {@link MavenModuleSetBuild#getEnvironment(TaskListener)} for discussion. */ @Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars envs = super.getEnvironment(log); // We need to add M2_HOME and the mvn binary to the PATH so if Maven // needs to run Maven it will pick the correct one. // This can happen if maven calls ANT which itself calls Maven // or if Maven calls itself e.g. maven-release-plugin MavenInstallation mvn = project.getParent().getMaven(); if (mvn == null) throw new hudson.AbortException(Messages.MavenModuleSetBuild_NoMavenConfigured()); mvn = mvn.forEnvironment(envs).forNode(Computer.currentComputer().getNode(), log); mvn.buildEnvVars(envs); return envs; }