public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException { modules = Collections.emptyMap(); // needed during load super.onLoad(parent, name); modules = loadChildren( this, getModulesDir(), new Function1<ModuleName, MavenModule>() { public ModuleName call(MavenModule module) { return module.getModuleName(); } }); // update the transient nest level field. MavenModule root = getRootModule(); if (root != null && root.getChildren() != null) { List<MavenModule> sortedList = new ArrayList<MavenModule>(); Stack<MavenModule> q = new Stack<MavenModule>(); root.nestLevel = 0; q.push(root); while (!q.isEmpty()) { MavenModule p = q.pop(); sortedList.add(p); List<MavenModule> children = p.getChildren(); if (children != null) { for (MavenModule m : children) m.nestLevel = p.nestLevel + 1; for (int i = children.size() - 1; i >= 0; i--) // add them in the reverse order q.push(children.get(i)); } } this.sortedActiveModules = sortedList; } else { this.sortedActiveModules = getDisabledModules(false); } if (reporters == null) reporters = new DescribableList<MavenReporter, Descriptor<MavenReporter>>(this); reporters.setOwner(this); if (publishers == null) publishers = new DescribableList<Publisher, Descriptor<Publisher>>(this); publishers.setOwner(this); if (buildWrappers == null) buildWrappers = new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this); buildWrappers.setOwner(this); updateTransientActions(); }
protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException { super.submit(req, rsp); JSONObject json = req.getSubmittedForm(); rootPOM = Util.fixEmpty(req.getParameter("rootPOM").trim()); if (rootPOM != null && rootPOM.equals("pom.xml")) rootPOM = null; // normalization goals = Util.fixEmpty(req.getParameter("goals").trim()); alternateSettings = Util.fixEmpty(req.getParameter("alternateSettings").trim()); mavenOpts = Util.fixEmpty(req.getParameter("mavenOpts").trim()); mavenName = req.getParameter("maven_version"); aggregatorStyleBuild = !req.hasParameter("maven.perModuleBuild"); usePrivateRepository = req.hasParameter("maven.usePrivateRepository"); ignoreUpstremChanges = !json.has("triggerByDependency"); incrementalBuild = req.hasParameter("maven.incrementalBuild"); archivingDisabled = req.hasParameter("maven.archivingDisabled"); reporters.rebuild(req, json, MavenReporters.getConfigurableList()); publishers.rebuild(req, json, BuildStepDescriptor.filter(Publisher.all(), this.getClass())); buildWrappers.rebuild(req, json, BuildWrappers.getFor(this)); }
public void logRotate() throws IOException, InterruptedException { super.logRotate(); // perform the log rotation of modules for (MavenModule m : modules.values()) m.logRotate(); }
@Override // to make this accessible from MavenModuleSetBuild protected void updateTransientActions() { super.updateTransientActions(); }
@Override public boolean shouldTriggerBuild( AbstractBuild build, TaskListener listener, List<Action> actions) { /** * Schedules all the downstream builds. Returns immediately if build result doesn't meet the * required level (as specified by {@link BuildTrigger}, or {@link Result#SUCCESS} if none). * * @param listener Where the progress reports go. */ if (build.getResult().isWorseThan(Result.SUCCESS)) return false; // trigger dependency builds AbstractProject<?, ?> downstreamProject = getDownstreamProject(); if (AbstractMavenBuild.debug) listener .getLogger() .println("Considering whether to trigger " + downstreamProject + " or not"); // if the downstream module depends on multiple modules, // only trigger them when all the upstream dependencies are updated. boolean trigger = true; // Check to see if any of its upstream dependencies are already building or in queue. AbstractMavenProject<?, ?> parent = (AbstractMavenProject<?, ?>) getUpstreamProject(); if (areUpstreamsBuilding(downstreamProject, parent)) { if (AbstractMavenBuild.debug) listener .getLogger() .println(" -> No, because downstream has dependencies already building or in queue"); trigger = false; } // Check to see if any of its upstream dependencies are in this list of downstream projects. else if (inDownstreamProjects(downstreamProject)) { if (AbstractMavenBuild.debug) listener .getLogger() .println( " -> No, because downstream has dependencies in the downstream projects list"); trigger = false; } else { AbstractBuild<?, ?> dlb = downstreamProject.getLastBuild(); // can be null. for (AbstractMavenProject up : Util.filter(downstreamProject.getUpstreamProjects(), AbstractMavenProject.class)) { Run ulb; if (up == parent) { // the current build itself is not registered as lastSuccessfulBuild // at this point, so we have to take that into account. ugly. if (build.getResult() == null || !build.getResult().isWorseThan(Result.UNSTABLE)) ulb = build; else ulb = up.getLastSuccessfulBuild(); } else ulb = up.getLastSuccessfulBuild(); if (ulb == null) { // if no usable build is available from the upstream, // then we have to wait at least until this build is ready if (AbstractMavenBuild.debug) listener .getLogger() .println( " -> No, because another upstream " + up + " for " + downstreamProject + " has no successful build"); trigger = false; break; } // if no record of the relationship in the last build // is available, we'll just have to assume that the condition // for the new build is met, or else no build will be fired forever. if (dlb == null) continue; int n = dlb.getUpstreamRelationship(up); if (n == -1) continue; assert ulb.getNumber() >= n; } } return trigger; }