Package hudson.maven.reporters
Class MavenArtifact
- java.lang.Object
-
- hudson.maven.reporters.MavenArtifact
-
- All Implemented Interfaces:
Serializable
@ExportedBean public final class MavenArtifact extends Object implements Serializable
Captures information about an artifact created by Maven and archived by Jenkins, so that we can later deploy it to repositories of our choice.This object is created within the Maven process and sent back to the controller, so it shouldn't contain anything non-serializable as fields.
Once it's constructed, the object should be considered final and immutable.
- Since:
- 1.189
- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MavenArtifact.CloseableArtifact
Artifact
holder that can be released in afinally
-block.class
MavenArtifact.TemporaryFile
Representation of an archived artifact that might be accessed in various ways.
-
Field Summary
Fields Modifier and Type Field Description String
artifactId
Basic parameters of a Maven artifact.String
canonicalName
The canonical artifact file name, used by Maven in the repository.String
classifier
Basic parameters of a Maven artifact.String
fileName
File name (without directory portion) of this artifact in the Hudson archive.String
groupId
Basic parameters of a Maven artifact.String
md5sum
The md5sum for this artifact.String
type
Basic parameters of a Maven artifact.String
version
Basic parameters of a Maven artifact.
-
Constructor Summary
Constructors Constructor Description MavenArtifact(String groupId, String artifactId, String version, String classifier, String type, String fileName, String md5sum)
MavenArtifact(org.apache.maven.artifact.Artifact a)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
archive(MavenBuildProxy build, File file, BuildListener listener)
Called from within Maven to archive an artifact in Hudson.static MavenArtifact
create(org.apache.maven.artifact.Artifact a)
Convenience method to check if the givenArtifact
object contains enough information suitable for recording, and if so, createMavenArtifact
.org.kohsuke.stapler.HttpResponse
doFile(MavenArtifactRecord parent)
Serve the file.Api
getApi()
File
getFile(MavenBuild build)
Deprecated.only works withStandardArtifactManager
and subclasses; usegetTemporaryFile(hudson.maven.MavenBuild)
insteadMavenArtifact.TemporaryFile
getTemporaryFile(MavenBuild build)
Gets an archived artifact.boolean
isPOM()
org.apache.maven.artifact.Artifact
toArtifact(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager handlerManager, org.apache.maven.artifact.factory.ArtifactFactory factory, MavenBuild build)
Deprecated.MavenArtifact.CloseableArtifact
toCloseableArtifact(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager handlerManager, org.apache.maven.artifact.factory.ArtifactFactory factory, MavenBuild build)
Creates a MavenArtifact
back from the persisted data.
-
-
-
Field Detail
-
groupId
@Exported public final String groupId
Basic parameters of a Maven artifact.
-
artifactId
@Exported public final String artifactId
Basic parameters of a Maven artifact.
-
version
@Exported public final String version
Basic parameters of a Maven artifact.
-
classifier
@Exported public final String classifier
Basic parameters of a Maven artifact.
-
type
@Exported public final String type
Basic parameters of a Maven artifact.
-
fileName
@Exported public final String fileName
File name (without directory portion) of this artifact in the Hudson archive. Remembered explicitly because some times this doesn't follow the standard naming convention, due to<finalName>
setting in POM.This name is taken directly from the name of the file as used during the build (thus POM would be most likely just
pom.xml
and artifacts would use theirfinalName
if one is configured.) This is often different fromcanonicalName
.
-
canonicalName
@Exported public final String canonicalName
The canonical artifact file name, used by Maven in the repository. This isartifactId-version[-classifier].extension
.The reason we persist this is that the extension is only available through
ArtifactHandler
.
-
md5sum
@Exported public final String md5sum
The md5sum for this artifact.
-
-
Constructor Detail
-
MavenArtifact
public MavenArtifact(org.apache.maven.artifact.Artifact a) throws IOException
- Throws:
IOException
-
-
Method Detail
-
create
public static MavenArtifact create(org.apache.maven.artifact.Artifact a) throws IOException
Convenience method to check if the givenArtifact
object contains enough information suitable for recording, and if so, createMavenArtifact
.- Throws:
IOException
-
isPOM
public boolean isPOM()
-
toArtifact
@Deprecated public org.apache.maven.artifact.Artifact toArtifact(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager handlerManager, org.apache.maven.artifact.factory.ArtifactFactory factory, MavenBuild build) throws IOException
Deprecated.- Throws:
IOException
-
toCloseableArtifact
public MavenArtifact.CloseableArtifact toCloseableArtifact(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager handlerManager, org.apache.maven.artifact.factory.ArtifactFactory factory, MavenBuild build) throws IOException
Creates a MavenArtifact
back from the persisted data.- Throws:
IOException
-
getFile
@Deprecated public File getFile(MavenBuild build) throws IOException
Deprecated.only works withStandardArtifactManager
and subclasses; usegetTemporaryFile(hudson.maven.MavenBuild)
insteadObtains theFile
representing the archived artifact.- Throws:
FileNotFoundException
- if the archived artifact was missingIOException
-
getTemporaryFile
@Nonnull public MavenArtifact.TemporaryFile getTemporaryFile(MavenBuild build)
Gets an archived artifact.- Parameters:
build
- a Maven build that might have archived this- Returns:
- a representation of the artifact
- Since:
- 2.0.3
-
doFile
public org.kohsuke.stapler.HttpResponse doFile(@AncestorInPath MavenArtifactRecord parent) throws IOException
Serve the file. TODO: figure out how to make this URL more discoverable to the remote API.- Throws:
IOException
-
archive
public void archive(MavenBuildProxy build, File file, BuildListener listener) throws IOException, InterruptedException
Called from within Maven to archive an artifact in Hudson.- Throws:
IOException
InterruptedException
-
getApi
public Api getApi()
-
-