From 09ffe933d104de7cc94f11e3a3b196a53dfa385b Mon Sep 17 00:00:00 2001 From: mindless Date: Thu, 1 Jul 2010 02:05:00 +0000 Subject: [PATCH] [FIXED HUDSON-6779] When a MavenModuleSetBuild is deleted, delete its contained module builds too.. this avoids orphaned module builds that then get looked at in determining the overall result for the prior ModuleSetBuild.. possibly mysteriously changing the displayed result for that prior build, with no visual indication as to why (this part just fixed in r32410.. build page will now list all module builds, so you can see/delete the orphaned module build). git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@32411 71c3de6d-444a-0410-be80-ed276b4c234a --- .../hudson/maven/MavenModuleSetBuild.java | 14 +++++++++++++- .../java/hudson/maven/MavenProjectTest.java | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 098766f78e..b84d454658 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -1,7 +1,8 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Red Hat, Inc., Victor Glushenkov + * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, + * Red Hat, Inc., Victor Glushenkov, Alan Harder * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -236,6 +237,15 @@ public class MavenModuleSetBuild extends AbstractMavenBuild list : getModuleBuilds().values()) + for (MavenBuild build : list) + build.delete(); + } + @Override public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { // map corresponding module build under this object @@ -248,6 +258,8 @@ public class MavenModuleSetBuild extends AbstractMavenBuild getModuleLastBuilds() { Collection mods = getParent().getModules(); diff --git a/test/src/test/java/hudson/maven/MavenProjectTest.java b/test/src/test/java/hudson/maven/MavenProjectTest.java index 1e694e7fd0..2d4b81b1e6 100755 --- a/test/src/test/java/hudson/maven/MavenProjectTest.java +++ b/test/src/test/java/hudson/maven/MavenProjectTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc. + * Copyright (c) 2004-2010, Sun Microsystems, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,15 +23,11 @@ */ package hudson.maven; -import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; -import hudson.model.Descriptor; -import hudson.tasks.ArtifactArchiver; import hudson.tasks.Maven.MavenInstallation; import org.jvnet.hudson.test.ExtractResourceSCM; import org.jvnet.hudson.test.HudsonTestCase; import org.jvnet.hudson.test.Bug; -import org.xml.sax.SAXException; import java.io.IOException; @@ -123,4 +119,17 @@ public class MavenProjectTest extends HudsonTestCase { wc.getPage(project, "site/client"); } + @Bug(6779) + public void testDeleteSetBuildDeletesModuleBuilds() throws Exception { + MavenModuleSet project = createProject("maven-multimod.zip"); + project.setGoals("package"); + buildAndAssertSuccess(project); + buildAndAssertSuccess(project.getModule("org.jvnet.hudson.main.test.multimod:moduleB")); + buildAndAssertSuccess(project); + assertEquals(2, project.getBuilds().size()); // Module build does not add a ModuleSetBuild + project.getFirstBuild().delete(); + // A#1, B#1 and B#2 should all be deleted too + assertEquals(1, project.getModule("org.jvnet.hudson.main.test.multimod:moduleA").getBuilds().size()); + assertEquals(1, project.getModule("org.jvnet.hudson.main.test.multimod:moduleB").getBuilds().size()); + } }