Conflicts:
	core/src/main/java/hudson/model/AbstractItem.java
	core/src/main/java/hudson/model/AbstractProject.java
	core/src/main/java/hudson/model/Descriptor.java
	core/src/main/java/hudson/model/Hudson.java
	core/src/main/java/hudson/tasks/BuildTrigger.java
	core/src/main/resources/hudson/model/View/newJob.jelly
	core/src/main/resources/hudson/model/View/sidepanel.jelly
	core/src/main/resources/hudson/views/Messages_ja.properties
	maven-plugin/src/main/java/hudson/maven/MavenBuild.java
	maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifact.java
	maven-plugin/src/main/java/hudson/maven/reporters/MavenArtifactRecord.java
This commit is contained in:
Kohsuke Kawaguchi committed 2011-07-05 19:42:20 -07:00
commit 039e43cf48
65 files changed
+477 -97

No files matched your search

@@ -422,7 +422,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
public void reccordProjectSucceeded( ExecutionEvent event ) {
MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() );
mavenBuildProxy2.end();
mavenBuildProxy2.setResult( Result.SUCCESS );
@@ -452,7 +451,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
}
}
}
mavenBuildProxy2.end();
}
/**
* @see org.apache.maven.execution.ExecutionListener#projectFailed(org.apache.maven.execution.ExecutionEvent)
@@ -467,7 +467,6 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
public void reccordProjectFailed( ExecutionEvent event ) {
MavenBuildProxy2 mavenBuildProxy2 = getMavenBuildProxy2( event.getProject() );
mavenBuildProxy2.end();
mavenBuildProxy2.setResult( Result.FAILURE );
MavenProject mavenProject = event.getProject();
List<MavenReporter> mavenReporters = getMavenReporters( mavenProject );
@@ -495,7 +494,9 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
}
}
}
}
mavenBuildProxy2.end();
}
/**
* @see org.apache.maven.execution.ExecutionListener#mojoSkipped(org.apache.maven.execution.ExecutionEvent)
@@ -25,6 +25,10 @@ package hudson.maven;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.maven.reporters.MavenArtifactRecord;
import hudson.maven.reporters.SurefireArchiver;
import hudson.slaves.WorkspaceList;
import hudson.slaves.WorkspaceList.Lease;
import hudson.maven.agent.AbortException;
import hudson.maven.reporters.SurefireArchiver;
import hudson.model.AbstractBuild;
@@ -50,6 +54,17 @@ import hudson.util.ArgumentListBuilder;
import hudson.util.DescribableList;
import hudson.util.IOUtils;
import hudson.util.ReflectionUtils;
import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.project.MavenProject;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.Exported;
import java.io.File;
import java.io.FileNotFoundException;
@@ -189,6 +204,14 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
return true;
}
/**
* Information about artifacts produced by Maven.
*/
@Exported
public MavenArtifactRecord getMavenArtifacts() {
return getAction(MavenArtifactRecord.class);
}
/**
* Exposes {@code MAVEN_OPTS} to forked processes.
*
@@ -232,6 +232,10 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
private DescribableList<BuildWrapper,Descriptor<BuildWrapper>> buildWrappers =
new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this);
/**
* @deprecated
* Use {@link #MavenModuleSet(ItemGroup, String)}
*/
public MavenModuleSet(String name) {
this(Jenkins.getInstance(),name);
}
@@ -33,6 +33,8 @@ import hudson.FilePath.FileCallable;
import hudson.Launcher;
import hudson.Util;
import hudson.maven.MavenBuild.ProxyImpl2;
import hudson.maven.reporters.MavenAggregatedArtifactRecord;
import hudson.maven.reporters.MavenArtifactRecord;
import hudson.maven.reporters.MavenFingerprinter;
import hudson.maven.reporters.MavenMailer;
import hudson.model.AbstractBuild;
@@ -99,6 +101,7 @@ import org.apache.maven.project.ProjectBuildingException;
import org.codehaus.plexus.util.PathTool;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;
import org.sonatype.aether.transfer.TransferCancelledException;
import org.sonatype.aether.transfer.TransferEvent;
import org.sonatype.aether.transfer.TransferListener;
@@ -376,6 +379,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
* null if this build is done by earlier version of Jenkins that didn't record this information
* (this means the build was done by Maven2.x)
*/
@Exported
public String getMavenVersionUsed() {
return mavenVersionUsed;
}
@@ -404,6 +408,14 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
return super.getDynamic(token,req,rsp);
}
/**
* Information about artifacts produced by Maven.
*/
@Exported
public MavenAggregatedArtifactRecord getMavenArtifacts() {
return getAction(MavenAggregatedArtifactRecord.class);
}
/**
* Computes the latest module builds that correspond to this build.
* (when individual modules are built, a new ModuleSetBuild is not created,
@@ -512,7 +524,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
// new AggregatableAction
MavenAggregatedReport mar = aa.createAggregatedAction(this, moduleBuilds);
mar.update(moduleBuilds,newBuild);
actions.add(mar);
addAction(mar);
modified = true;
}
}
@@ -30,6 +30,7 @@ import hudson.maven.MavenUtil;
import hudson.maven.RedeployPublisher.WrappedArtifactRepository;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Api;
import hudson.model.BallColor;
import hudson.model.BuildBadgeAction;
import hudson.model.Result;
@@ -62,6 +63,8 @@ import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
/**
* UI to redeploy artifacts after the fact.
@@ -73,10 +76,12 @@ import org.kohsuke.stapler.StaplerResponse;
* @author Kohsuke Kawaguchi
*/
public abstract class MavenAbstractArtifactRecord<T extends AbstractBuild<?,?>> extends TaskAction implements BuildBadgeAction {
@ExportedBean
public final class Record {
/**
* Repository URL that artifacts were deployed.
*/
@Exported
public final String url;
/**
@@ -107,26 +112,32 @@ public abstract class MavenAbstractArtifactRecord<T extends AbstractBuild<?,?>>
/**
* Result of the deployment. During the build, this value is null.
*/
@Exported
public Result getResult() {
return result;
}
@Exported
public int getNumber() {
return records.indexOf(this);
}
@Exported
public boolean isBuilding() {
return result==null;
}
@Exported
public Calendar getTimestamp() {
return (Calendar) timeStamp.clone();
}
@Exported
public String getBuildStatusUrl() {
return getIconColor().getImage();
}
@Exported
public BallColor getIconColor() {
if(result==null)
return BallColor.GREY_ANIME;
@@ -144,6 +155,7 @@ public abstract class MavenAbstractArtifactRecord<T extends AbstractBuild<?,?>>
/**
* Records of a deployment.
*/
@Exported
public final CopyOnWriteArrayList<Record> records = new CopyOnWriteArrayList<Record>();
/**
@@ -171,6 +183,10 @@ public abstract class MavenAbstractArtifactRecord<T extends AbstractBuild<?,?>>
return REDEPLOY;
}
public Api getApi() {
return new Api(this);
}
public boolean hasBadge() {
if (records != null) {
for (final Record record : records) {
@@ -34,18 +34,22 @@ import hudson.model.Action;
import hudson.model.TaskListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
/**
* Redeploy action for the entire {@link MavenModuleSetBuild}.
*
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public class MavenAggregatedArtifactRecord extends MavenAbstractArtifactRecord<MavenModuleSetBuild> implements MavenAggregatedReport {
public final MavenModuleSetBuild parent;
@@ -68,17 +72,27 @@ public class MavenAggregatedArtifactRecord extends MavenAbstractArtifactRecord<M
return null;
}
/**
* {@link MavenArtifactRecord}s of every module build contributed to {@link #parent}.
*/
@Exported(inline=true)
public List<MavenArtifactRecord> getModuleRecords() {
List<MavenArtifactRecord> r = new ArrayList<MavenArtifactRecord>();
for (MavenBuild build : parent.getModuleLastBuilds().values()) {
MavenArtifactRecord mar = build.getAction(MavenArtifactRecord.class);
if(mar!=null) r.add(mar);
}
return r;
}
public void deploy(MavenEmbedder embedder, ArtifactRepository deploymentRepository, TaskListener listener) throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactDeploymentException {
if(debug)
listener.getLogger().println("Redeploying artifacts of "+parent+" timestamp="+parent.getTimestamp());
for (MavenBuild build : parent.getModuleLastBuilds().values()) {
MavenArtifactRecord mar = build.getAction(MavenArtifactRecord.class);
if(mar!=null) {
if(debug)
listener.getLogger().println("Deploying module: "+build+" timestamp="+build.getTimestamp());
mar.deploy(embedder,deploymentRepository,listener);
}
for (MavenArtifactRecord mar : getModuleRecords()) {
if(debug)
listener.getLogger().println("Deploying module: "+mar.parent+" timestamp="+mar.parent.getTimestamp());
mar.deploy(embedder,deploymentRepository,listener);
}
}
}
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, CloudBees, 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
@@ -27,10 +27,12 @@ import hudson.FilePath;
import hudson.Util;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy;
import hudson.model.Api;
import hudson.model.BuildListener;
import hudson.model.FingerprintMap;
import jenkins.model.Jenkins;
import hudson.util.HttpResponses;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.handler.ArtifactHandler;
@@ -38,6 +40,10 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import com.google.common.collect.Maps;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import java.io.File;
import java.io.FileInputStream;
@@ -60,10 +66,12 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
* @since 1.189
*/
@ExportedBean
public final class MavenArtifact implements Serializable {
/**
* Basic parameters of a Maven artifact.
*/
@Exported
public final String groupId, artifactId, version, classifier, type;
/**
@@ -77,6 +85,7 @@ public final class MavenArtifact implements Serializable {
* use their <tt>finalName</tt> if one is configured.) This is often
* different from {@link #canonicalName}.
*/
@Exported
public final String fileName;
/**
@@ -87,13 +96,15 @@ public final class MavenArtifact implements Serializable {
* The reason we persist this is that the extension is only available
* through {@link ArtifactHandler}.
*/
@Exported
public final String canonicalName;
/**
* The md5sum for this artifact.
*/
@Exported
public final String md5sum;
public MavenArtifact(Artifact a) throws IOException {
this.groupId = a.getGroupId();
this.artifactId = a.getArtifactId();
@@ -185,6 +196,15 @@ public final class MavenArtifact implements Serializable {
return f;
}
/**
* Serve the file.
*
* TODO: figure out how to make this URL more discoverable to the remote API.
*/
public HttpResponse doFile(@AncestorInPath MavenArtifactRecord parent) throws IOException {
return HttpResponses.staticResource(getFile(parent.parent));
}
private FilePath getArtifactArchivePath(MavenBuildProxy build, String groupId, String artifactId, String version) {
return build.getArtifactsDir().child(groupId).child(artifactId).child(version).child(canonicalName);
}
@@ -260,6 +280,10 @@ public final class MavenArtifact implements Serializable {
map.getOrCreate(build,fileName,md5sum);
}
public Api getApi() {
return new Api(this);
}
private static final Logger LOGGER = Logger.getLogger(MavenArtifact.class.getName());
private static final long serialVersionUID = 1L;
@@ -1,8 +1,8 @@
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, CloudBees, 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
* in the Software without restriction, including without limitation the rights
@@ -25,8 +25,17 @@ package hudson.maven.reporters;
import hudson.maven.*;
import hudson.maven.RedeployPublisher.WrappedArtifactRepository;
import hudson.model.AbstractItem;
import hudson.model.Action;
import hudson.model.Api;
import hudson.model.TaskListener;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
@@ -37,6 +46,8 @@ import org.apache.maven.artifact.installer.ArtifactInstaller;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import java.io.IOException;
import java.io.PrintStream;
@@ -51,15 +62,18 @@ import java.util.Map;
* @author Kohsuke Kawaguchi
* @see MavenArtifactArchiver
*/
@ExportedBean
public class MavenArtifactRecord extends MavenAbstractArtifactRecord<MavenBuild> implements AggregatableAction {
/**
* The build to which this record belongs.
*/
@Exported
public final MavenBuild parent;
/**
* POM artifact.
*/
@Exported(inline=true)
public final MavenArtifact pomArtifact;
/**
@@ -67,11 +81,13 @@ public class MavenArtifactRecord extends MavenAbstractArtifactRecord<MavenBuild>
*
* If this is a POM module, the main artifact contains the same value as {@link #pomArtifact}.
*/
@Exported(inline=true)
public final MavenArtifact mainArtifact;
/**
* Attached artifacts. Can be empty but never null.
*/
@Exported(inline=true)
public final List<MavenArtifact> attachedArtifacts;
/**
@@ -108,11 +124,36 @@ public class MavenArtifactRecord extends MavenAbstractArtifactRecord<MavenBuild>
return parent;
}
/**
* Returns the URL of this record relative to the context root of the application.
*
* @see AbstractItem#getUrl() for how to implement this.
*
* @return
* URL that ends with '/'.
*/
public String getUrl() {
return parent.getUrl()+"mavenArtifacts/";
}
/**
* Obtains the absolute URL to this build.
*
* @deprecated
* This method shall <b>NEVER</b> be used during HTML page rendering, as it's too easy for
* misconfiguration to break this value, with network set up like Apache reverse proxy.
* This method is only intended for the remote API clients who cannot resolve relative references.
*/
@Exported(visibility=2,name="url")
public String getAbsoluteUrl() {
return parent.getAbsoluteUrl()+"mavenArtifacts/";
}
public boolean isPOM() {
return mainArtifact.isPOM();
}
public MavenAggregatedReport createAggregatedAction(MavenModuleSetBuild build, Map<MavenModule, List<MavenBuild>> moduleBuilds) {
public MavenAggregatedArtifactRecord createAggregatedAction(MavenModuleSetBuild build, Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenAggregatedArtifactRecord(build);
}
@@ -154,8 +195,6 @@ public class MavenArtifactRecord extends MavenAbstractArtifactRecord<MavenBuild>
}
}
/**
* Installs the artifact to the local Maven repository.
*/
@@ -170,7 +209,7 @@ public class MavenArtifactRecord extends MavenAbstractArtifactRecord<MavenBuild>
installer.install(mainArtifact.getFile(parent),main,embedder.getLocalRepository());
for (MavenArtifact aa : attachedArtifacts)
installer.install(aa.getFile(parent),aa.toArtifact(handlerManager,factory,parent),embedder.getLocalRepository());
installer.install(aa.getFile(parent), aa.toArtifact(handlerManager, factory, parent), embedder.getLocalRepository());
}
public void recordFingerprints() throws IOException {