Class CommonsDistributionDetachmentMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.commons.release.plugin.mojos.CommonsDistributionDetachmentMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="detach-distributions", defaultPhase=VERIFY, threadSafe=true, aggregator=true) public final class CommonsDistributionDetachmentMojo extends org.apache.maven.plugin.AbstractMojo
The purpose of this Maven mojo is to detach the artifacts generated by the maven-assembly-plugin, which for the Apache Commons Project do not get uploaded to Nexus, and put those artifacts in the dev distribution location for Apache projects.
Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Set<String>
    A list of "artifact types" in the Maven vernacular, to be detached from the deployment.
    private final org.apache.commons.collections4.properties.SortedProperties
    A SortedProperties mapping artifact file names to their SHA-512 hashes.
    private final List<org.apache.maven.artifact.Artifact>
    This list is supposed to hold the Maven references to the aforementioned artifacts so that we can upload them to SVN after they've been detached from the Maven deployment.
    private String
    The Subversion staging URL to which we upload all of our staged artifacts.
    private Boolean
    A parameter to generally avoid running unless it is specifically turned on by the consuming module.
    private org.apache.maven.project.MavenProject
    The Maven project context injection so that we can access the project variables.
    private File
    The working directory in target that we use as a sandbox for the plugin.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    A helper method to copy the newly detached artifacts to target/commons-release-plugin so that the CommonsDistributionStagingMojo can find the artifacts later.
    void
     
    private String
    getArtifactKey(org.apache.maven.artifact.Artifact artifact)
    Gets the unique artifact key for storage in our sha512 map.
    private String
    getSha512FilePath(File directory, File file)
    Gets the file path for the sha512 checksum file for a given file.
    private void
    Creates SHA-512 checksum files for detached artifacts in the target/commons-release-plugin directory for upload by CommonsDistributionStagingMojo.
    private void
    putAttachedArtifactInSha512Map(org.apache.maven.artifact.Artifact artifact)
    Computes the SHA-512 hash of an attached artifact and stores it in the map.
    private void
    putFileInSha512Map(String artifactKey, File file)
    Computes a file's SHA-512 hash and stores it under its release artifact name.
    private void
    Writes the artifacts' SHA-512 hashes to .

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ARTIFACT_TYPES_TO_DETACH

      private static final Set<String> ARTIFACT_TYPES_TO_DETACH
      A list of "artifact types" in the Maven vernacular, to be detached from the deployment. For the time being, we want all artifacts generated by the maven-assembly-plugin to be detached from the deployment, namely *-src.zip, *-src.tar.gz, *-bin.zip, *-bin.tar.gz, and the corresponding .asc PGP signatures.
    • detachedArtifacts

      private final List<org.apache.maven.artifact.Artifact> detachedArtifacts
      This list is supposed to hold the Maven references to the aforementioned artifacts so that we can upload them to SVN after they've been detached from the Maven deployment.
    • artifactSha512s

      private final org.apache.commons.collections4.properties.SortedProperties artifactSha512s
      A SortedProperties mapping artifact file names to their SHA-512 hashes.
    • project

      @Parameter(defaultValue="${project}", required=true) private org.apache.maven.project.MavenProject project
      The Maven project context injection so that we can access the project variables.
    • workingDirectory

      @Parameter(defaultValue="${project.build.directory}/commons-release-plugin", property="commons.outputDirectory") private File workingDirectory
      The working directory in target that we use as a sandbox for the plugin.
    • distSvnStagingUrl

      @Parameter(defaultValue="", property="commons.distSvnStagingUrl") private String distSvnStagingUrl
      The Subversion staging URL to which we upload all of our staged artifacts.
    • isDistModule

      @Parameter(defaultValue="false", property="commons.release.isDistModule") private Boolean isDistModule
      A parameter to generally avoid running unless it is specifically turned on by the consuming module.
  • Constructor Details

  • Method Details

    • copyRemovedArtifactsToWorkingDirectory

      private void copyRemovedArtifactsToWorkingDirectory() throws org.apache.maven.plugin.MojoExecutionException
      A helper method to copy the newly detached artifacts to target/commons-release-plugin so that the CommonsDistributionStagingMojo can find the artifacts later.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs.
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getArtifactKey

      private String getArtifactKey(org.apache.maven.artifact.Artifact artifact)
      Gets the unique artifact key for storage in our sha512 map. For example, commons-test-1.4-src.tar.gz should have its name as the key.
      Parameters:
      artifact - The Artifact that we wish to generate a key for.
      Returns:
      The generated key
    • getSha512FilePath

      private String getSha512FilePath(File directory, File file)
      Gets the file path for the sha512 checksum file for a given file.
      Parameters:
      directory - is the File for the directory in which to make the .sha512 file.
      file - The File whose name we should use to create the .sha512 file.
      Returns:
      A String that is the absolute path to the .sha512 file.
    • hashArtifacts

      private void hashArtifacts() throws org.apache.maven.plugin.MojoExecutionException
      Creates SHA-512 checksum files for detached artifacts in the target/commons-release-plugin directory for upload by CommonsDistributionStagingMojo.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs.
    • putAttachedArtifactInSha512Map

      private void putAttachedArtifactInSha512Map(org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException
      Computes the SHA-512 hash of an attached artifact and stores it in the map.
      Parameters:
      artifact - is a Maven Artifact taken from the project when the mojo starts.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs when computing the SHA-512 hash of the artifact.
    • putFileInSha512Map

      private void putFileInSha512Map(String artifactKey, File file) throws org.apache.maven.plugin.MojoExecutionException
      Computes a file's SHA-512 hash and stores it under its release artifact name.
      Parameters:
      artifactKey - the release artifact name.
      file - the file to hash.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the file cannot be read.
    • writeAllArtifactsInSha512PropertiesFile

      private void writeAllArtifactsInSha512PropertiesFile() throws org.apache.maven.plugin.MojoExecutionException
      Writes the artifacts' SHA-512 hashes to ./target/commons-release-plugin/sha512.properties.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs while writing the file.