Class CommonsDistributionStagingMojo

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

@Mojo(name="stage-distributions", defaultPhase=DEPLOY, threadSafe=true, aggregator=true) public final class CommonsDistributionStagingMojo extends org.apache.maven.plugin.AbstractMojo
Checks out the dev distribution location, copies the distributions into that directory structure under the target/commons-release-plugin/scm directory, and commits the distributions back to SVN. Includes the built and zipped site as well as the RELEASE-NOTES.txt file.
Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private File
    The File representing the root directory of the working project.
    private String
    The RC version of the release.
    private String
    The release version of the artifact to be built.
    private File
    The location to which to check out the dist Subversion repository under our working directory, which was given above.
    private File
    A subdirectory of the dist directory into which we are going to stage the release candidate.
    private String
    The ID of the server (specified in settings.xml) which should be used for dist authentication.
    private String
    The URL of the Subversion repository to which we wish the artifacts to be staged.
    private Boolean
    A boolean that determines whether or not we actually commit the files up to the Subversion repository.
    private static final String
    The name of the file generated from the HEADER.vm Velocity template to be checked into the dist SVN repo.
    private Boolean
    A parameter to generally avoid running unless it is specifically turned on by the consuming module.
    private String
    The password associated with username.
    private org.apache.maven.project.MavenProject
    The MavenProject object is essentially the context of the Maven build at a given time.
    private static final String
    The name of the file generated from the README.vm Velocity template to be checked into the dist SVN repo.
    private File
    The location of the RELEASE-NOTES.txt file such that multi-module builds can configure it.
    private org.apache.maven.settings.Settings
    Maven Settings.
    private org.apache.maven.settings.crypto.SettingsDecrypter
    Maven SettingsDecrypter component.
    private static final String
    The name of the signature validation shell script to be checked into the dist SVN repo.
    private File
    The location to which the site gets built when running mvn site.
    private String
    The username for the distribution Subversion repository.
    private File
    The main working directory for the plugin, namely target/commons-release-plugin, but that assumes that we're using the default Maven ${project.build.directory}.

    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 List<File>
    Builds up README.html and HEADER.html that reside in the following directory structure: distRoot binaries/HEADER.html (symlink) binaries/README.html (symlink) source/HEADER.html (symlink) source/README.html (symlink) HEADER.html README.html
    private List<File>
    copyDistributionsIntoScmDirectoryStructureAndAddToSvn(File copiedReleaseNotes, org.apache.maven.scm.provider.ScmProvider provider, org.apache.maven.scm.repository.ScmRepository repository)
    Copies the list of files at the root of the workingDirectory into the directory structure of the distribution staging repository.
    private List<File>
    Copies README.html and HEADER.html to the source and binaries directories.
    private File
    Copies the configured release notes file into distRcVersionDirectory.
    private File
    Copies our signature-validator.sh script into ${basedir}/target/commons-release-plugin/scm/signature-validator.sh.
    private List<File>
    Copies ${basedir}/target/site to ${basedir}/target/commons-release-plugin/scm/site.
    void
     
    private void
    Lists all directories and files in a flat list.
    protected void
    setBaseDir(File baseDir)
    Sets the baseDir field for use in unit tests.

    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

    • README_FILE_NAME

      private static final String README_FILE_NAME
      The name of the file generated from the README.vm Velocity template to be checked into the dist SVN repo.
      See Also:
    • HEADER_FILE_NAME

      private static final String HEADER_FILE_NAME
      The name of the file generated from the HEADER.vm Velocity template to be checked into the dist SVN repo.
      See Also:
    • SIGNATURE_VALIDATOR_NAME

      private static final String SIGNATURE_VALIDATOR_NAME
      The name of the signature validation shell script to be checked into the dist SVN repo.
      See Also:
    • project

      @Parameter(defaultValue="${project}", required=true) private org.apache.maven.project.MavenProject project
      The MavenProject object is essentially the context of the Maven build at a given time.
    • baseDir

      @Parameter(defaultValue="${basedir}") private File baseDir
      The File representing the root directory of the working project. Typically this directory is where the pom.xml resides.
    • siteDirectory

      @Parameter(defaultValue="${project.build.directory}/site", property="commons.siteOutputDirectory") private File siteDirectory
      The location to which the site gets built when running mvn site.
    • workingDirectory

      @Parameter(defaultValue="${project.build.directory}/commons-release-plugin", property="commons.outputDirectory") private File workingDirectory
      The main working directory for the plugin, namely target/commons-release-plugin, but that assumes that we're using the default Maven ${project.build.directory}.
    • distCheckoutDirectory

      @Parameter(defaultValue="${project.build.directory}/commons-release-plugin/scm", property="commons.distCheckoutDirectory") private File distCheckoutDirectory
      The location to which to check out the dist Subversion repository under our working directory, which was given above.
    • releaseNotesFile

      @Parameter(defaultValue="${basedir}/RELEASE-NOTES.txt", property="commons.releaseNotesLocation") private File releaseNotesFile
      The location of the RELEASE-NOTES.txt file such that multi-module builds can configure it.
    • dryRun

      @Parameter(property="commons.release.dryRun", defaultValue="false") private Boolean dryRun
      A boolean that determines whether or not we actually commit the files up to the Subversion repository. If this is set to true, we do all but make the commits. We do check out the repository in question, though.
    • distSvnStagingUrl

      @Parameter(defaultValue="", property="commons.distSvnStagingUrl") private String distSvnStagingUrl
      The URL of the Subversion repository to which we wish the artifacts to be staged. Typically this would need to be of the form: scm:svn:https://dist.apache.org/repos/dist/dev/commons/foo/version-RC#. Note that the prefix to the substring https is a requirement.
    • 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.
    • commonsReleaseVersion

      @Parameter(property="commons.release.version") private String commonsReleaseVersion
      The release version of the artifact to be built.
    • commonsRcVersion

      @Parameter(property="commons.rc.version") private String commonsRcVersion
      The RC version of the release. For example, the first release candidate would be "RC1".
    • distServer

      @Parameter(property="commons.distServer") private String distServer
      The ID of the server (specified in settings.xml) which should be used for dist authentication. This will be used in preference to username/password.
    • username

      @Parameter(property="user.name") private String username
      The username for the distribution Subversion repository. This is typically your Apache ID.
    • password

      @Parameter(property="user.password") private String password
      The password associated with username.
    • settings

      @Parameter(defaultValue="${settings}", readonly=true, required=true) private org.apache.maven.settings.Settings settings
      Maven Settings.
    • settingsDecrypter

      @Component private org.apache.maven.settings.crypto.SettingsDecrypter settingsDecrypter
      Maven SettingsDecrypter component.
    • distRcVersionDirectory

      A subdirectory of the dist directory into which we are going to stage the release candidate. We build this up in the execute() method. For example, the directory should look like https://dist.apache.org/repos/dist/dev/commons/text/1.4-RC1.
  • Constructor Details

  • Method Details

    • buildReadmeAndHeaderHtmlFiles

      private List<File> buildReadmeAndHeaderHtmlFiles() throws org.apache.maven.plugin.MojoExecutionException
      Builds up README.html and HEADER.html that reside in the following directory structure:
      • distRoot
        • binaries/HEADER.html (symlink)
        • binaries/README.html (symlink)
        • source/HEADER.html (symlink)
        • source/README.html (symlink)
        • HEADER.html
        • README.html
      Returns:
      The List of created files above
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs while creating these files.
    • copyDistributionsIntoScmDirectoryStructureAndAddToSvn

      private List<File> copyDistributionsIntoScmDirectoryStructureAndAddToSvn(File copiedReleaseNotes, org.apache.maven.scm.provider.ScmProvider provider, org.apache.maven.scm.repository.ScmRepository repository) throws org.apache.maven.plugin.MojoExecutionException
      Copies the list of files at the root of the workingDirectory into the directory structure of the distribution staging repository. Specifically:
      • root:
        • site
        • site.zip
        • RELEASE-NOTES.txt
        • source:
          • -src artifacts....
        • binaries:
          • -bin artifacts....
      Parameters:
      copiedReleaseNotes - is the RELEASE-NOTES.txt file that exists in the target/commons-release-plugin/scm directory.
      provider - is the ScmProvider that we will use for adding the files we wish to commit.
      repository - is the ScmRepository that we will use for adding the files that we wish to commit.
      Returns:
      A List of File objects in the directory for the purpose of adding them to the Maven ScmFileSet.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs.
    • copyHeaderAndReadmeToSubdirectories

      private List<File> copyHeaderAndReadmeToSubdirectories(File headerFile, File readmeFile) throws org.apache.maven.plugin.MojoExecutionException
      Copies README.html and HEADER.html to the source and binaries directories.
      Parameters:
      headerFile - The originally created HEADER.html file.
      readmeFile - The originally created README.html file.
      Returns:
      A List of created files.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if SharedFunctions.copyFile(Log, File, File) fails.
    • copyReleaseNotesToWorkingDirectory

      private File copyReleaseNotesToWorkingDirectory() throws org.apache.maven.plugin.MojoExecutionException
      Copies the configured release notes file into distRcVersionDirectory.
      Returns:
      The copied release notes file in distRcVersionDirectory, for inclusion in the SCM change set in the method copyDistributionsIntoScmDirectoryStructureAndAddToSvn(File, ScmProvider, ScmRepository).
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an IOException occurs while copying the file.
    • copySignatureValidatorScriptToScmDirectory

      private File copySignatureValidatorScriptToScmDirectory() throws org.apache.maven.plugin.MojoExecutionException
      Copies our signature-validator.sh script into ${basedir}/target/commons-release-plugin/scm/signature-validator.sh.
      Returns:
      The File for the signature-validator.sh
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an error occurs while copying the resource.
    • copySiteToScmDirectory

      private List<File> copySiteToScmDirectory() throws org.apache.maven.plugin.MojoExecutionException
      Copies ${basedir}/target/site to ${basedir}/target/commons-release-plugin/scm/site.
      Returns:
      The List of File objects contained in ${basedir}/target/commons-release-plugin/scm/site, after the copy is complete.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Thrown if an error occurs while copying the site.
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • listNotHiddenFilesAndDirectories

      private void listNotHiddenFilesAndDirectories(File directory, List<File> files)
      Lists all directories and files in a flat list.
      Parameters:
      directory - File containing directory to list
      files - A List of File to which to append the files.
    • setBaseDir

      protected void setBaseDir(File baseDir)
      Sets the baseDir field for use in unit tests.
      Parameters:
      baseDir - is the File to be used as the project's root directory when this mojo is invoked.