提交 a451ce59 编写于 作者: K kohsuke

converted existing MavenReporters into the auto-discovery based mechanism.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15610 71c3de6d-444a-0410-be80-ed276b4c234a
上级 4923cd30
......@@ -158,7 +158,7 @@ public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBui
disabled = false;
if (pom.mailNotifier != null) {
MavenReporter reporter = getReporters().get(MavenMailer.DescriptorImpl.DESCRIPTOR);
MavenReporter reporter = getReporters().get(MavenMailer.class);
if (reporter != null) {
MavenMailer mailer = (MavenMailer) reporter;
mailer.dontNotifyEveryUnstableBuild = !pom.mailNotifier.isSendOnFailure();
......@@ -435,7 +435,7 @@ public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBui
getReporters().addAllTo(reporters);
getParent().getReporters().addAllTo(reporters);
for (MavenReporterDescriptor d : MavenReporters.LIST) {
for (MavenReporterDescriptor d : Hudson.getInstance().getExtensionList(MavenReporterDescriptor.class)) {
if(getReporters().contains(d))
continue; // already configured
MavenReporter auto = d.newAutoInstance(this);
......
......@@ -30,6 +30,7 @@ import hudson.model.Action;
import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.Describable;
import hudson.model.Hudson;
import hudson.tasks.BuildStep;
import hudson.tasks.Publisher;
import org.apache.maven.plugin.MojoExecutionException;
......@@ -280,5 +281,7 @@ public abstract class MavenReporter implements Describable<MavenReporter>, Exten
return null;
}
public abstract MavenReporterDescriptor getDescriptor();
public MavenReporterDescriptor getDescriptor() {
return (MavenReporterDescriptor)Hudson.getInstance().getDescriptor(getClass());
}
}
......@@ -24,6 +24,7 @@
package hudson.maven;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.maven.reporters.MavenArtifactArchiver;
import hudson.maven.reporters.MavenFingerprinter;
import hudson.maven.reporters.MavenJavadocArchiver;
......@@ -31,6 +32,7 @@ import hudson.maven.reporters.SurefireArchiver;
import hudson.maven.reporters.MavenMailer;
import hudson.maven.reporters.BuildInfoRecorder;
import hudson.maven.reporters.MavenSiteArchiver;
import hudson.util.DescriptorList;
import java.util.List;
import java.util.ArrayList;
......@@ -42,23 +44,22 @@ import java.util.ArrayList;
public final class MavenReporters {
/**
* List of all installed {@link MavenReporter}s.
*
* @deprecated as of 1.286. Use {@code Hudson.getInstance().getExtensionList(MavenReporterDescriptor.class)}
*/
public static final List<MavenReporterDescriptor> LIST = Descriptor.toList(
MavenArtifactArchiver.DescriptorImpl.DESCRIPTOR,
MavenFingerprinter.DescriptorImpl.DESCRIPTOR,
MavenJavadocArchiver.DescriptorImpl.DESCRIPTOR,
MavenSiteArchiver.DescriptorImpl.DESCRIPTOR,
SurefireArchiver.DescriptorImpl.DESCRIPTOR,
MavenMailer.DescriptorImpl.DESCRIPTOR,
BuildInfoRecorder.DescriptorImpl.DESCRIPTOR
);
public static final List<MavenReporterDescriptor> LIST = (List)new DescriptorList<MavenReporter>(MavenReporter.class);
static {
// emulate the behavior of the legacy code
LIST.add(MavenJavadocArchiver.DescriptorImpl.DESCRIPTOR);
}
/**
* Gets the subset of {@link #LIST} that has configuration screen.
*/
public static List<MavenReporterDescriptor> getConfigurableList() {
List<MavenReporterDescriptor> r = new ArrayList<MavenReporterDescriptor>();
for (MavenReporterDescriptor d : LIST) {
for (MavenReporterDescriptor d : Hudson.getInstance().getExtensionList(MavenReporterDescriptor.class)) {
if(d.hasConfigScreen())
r.add(d);
}
......
......@@ -32,6 +32,7 @@ import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy.BuildCallable;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.Extension;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
......@@ -85,13 +86,8 @@ public class BuildInfoRecorder extends MavenReporter {
return super.preExecute(build, pom, mojo, listener);
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.DESCRIPTOR;
}
@Extension
public static final class DescriptorImpl extends MavenReporterDescriptor {
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public String getDisplayName() {
return Messages.BuildInfoRecorder_DisplayName();
}
......
......@@ -32,6 +32,7 @@ import hudson.maven.MavenBuild;
import hudson.model.BuildListener;
import hudson.util.InvocationInterceptor;
import hudson.FilePath;
import hudson.Extension;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.project.MavenProject;
......@@ -152,13 +153,8 @@ public class MavenArtifactArchiver extends MavenReporter {
return true;
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.DESCRIPTOR;
}
@Extension
public static final class DescriptorImpl extends MavenReporterDescriptor {
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public String getDisplayName() {
return Messages.MavenArtifactArchiver_DisplayName();
}
......
......@@ -24,6 +24,7 @@
package hudson.maven.reporters;
import hudson.FilePath;
import hudson.Extension;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenBuildProxy.BuildCallable;
......@@ -144,13 +145,8 @@ public class MavenFingerprinter extends MavenReporter {
record.put(groupId+':'+f.getName(),digest);
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.DESCRIPTOR;
}
@Extension
public static final class DescriptorImpl extends MavenReporterDescriptor {
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public String getDisplayName() {
return Messages.MavenFingerprinter_DisplayName();
}
......
......@@ -24,6 +24,7 @@
package hudson.maven.reporters;
import hudson.Launcher;
import hudson.Extension;
import hudson.maven.MavenBuild;
import hudson.maven.MavenReporter;
import hudson.maven.MavenReporterDescriptor;
......@@ -54,13 +55,8 @@ public class MavenMailer extends MavenReporter {
return true;
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.DESCRIPTOR;
}
@Extension
public static final class DescriptorImpl extends MavenReporterDescriptor {
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public String getDisplayName() {
return Messages.MavenMailer_DisplayName();
}
......
......@@ -25,6 +25,7 @@ package hudson.maven.reporters;
import hudson.FilePath;
import hudson.Util;
import hudson.Extension;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenModule;
import hudson.maven.MavenModuleSet;
......@@ -127,13 +128,8 @@ public class MavenSiteArchiver extends MavenReporter {
}
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.DESCRIPTOR;
}
@Extension
public static final class DescriptorImpl extends MavenReporterDescriptor {
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public String getDisplayName() {
return "Maven site";
}
......
......@@ -24,6 +24,7 @@
package hudson.maven.reporters;
import hudson.Util;
import hudson.Extension;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenBuildProxy.BuildCallable;
......@@ -158,13 +159,8 @@ public class SurefireArchiver extends MavenReporter {
return true;
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.DESCRIPTOR;
}
@Extension
public static final class DescriptorImpl extends MavenReporterDescriptor {
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public String getDisplayName() {
return Messages.SurefireArchiver_DisplayName();
}
......
......@@ -207,7 +207,6 @@ public abstract class HudsonTestCase extends TestCase {
// without this, plugins loaded in the tests will be left and interferes with the later tests.
cleanUpDescriptors(Descriptor.ALL);
cleanUpDescriptors(BuildStep.PUBLISHERS);
cleanUpDescriptors(MavenReporters.LIST);
hudson.cleanUp();
env.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册