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 class CommonsDistributionStagingMojo
extends org.apache.maven.plugin.AbstractMojo
This class checks out the dev distribution location, copies the distributions into that directory
structure under the
target/commons-release-plugin/scm
directory. Then commits the
distributions back up to SVN. Also, we include the built and zipped site as well as the RELEASE-NOTES.txt.- Since:
- 1.0
-
Field Summary
Modifier and TypeFieldDescriptionprivate File
TheFile
that contains a file to 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 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 withusername
.private org.apache.maven.project.MavenProject
TheMavenProject
object is essentially the context of the maven build at a given time.private static final String
The name of 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
MavenSettings
.private org.apache.maven.settings.crypto.SettingsDecrypter
MavenSettingsDecrypter
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 during runningmvn site
.private String
The username for the distribution subversion repository.private File
The main working directory for the plugin, namelytarget/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
-
Method Summary
Modifier and TypeMethodDescriptionBuilds upREADME.html
andHEADER.html
that reside in following.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 theworkingDirectory
into the directory structure of the distribution staging repository.copyHeaderAndReadmeToSubdirectories
(File headerFile, File readmeFile) CopiesREADME.html
andHEADER.html
to the source and binaries directories.private File
A utility method that takes theRELEASE-NOTES.txt
file from the base directory of the project and copies it intoworkingDirectory
.private File
Copies oursignature-validator.sh
script into${basedir}/target/commons-release-plugin/scm/signature-validator.sh
.Copies${basedir}/target/site
to${basedir}/target/commons-release-plugin/scm/site
.void
execute()
private void
listNotHiddenFilesAndDirectories
(File directory, List<File> files) Lists all directories and files to a flat list.protected void
setBaseDir
(File baseDir) This method is the setter for thebaseDir
field, specifically for the usage in the unit tests.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
README_FILE_NAME
The name of file generated from the README.vm velocity template to be checked into the dist svn repo.- See Also:
-
HEADER_FILE_NAME
The name of file generated from the HEADER.vm velocity template to be checked into the dist svn repo.- See Also:
-
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 projectTheMavenProject
object is essentially the context of the maven build at a given time. -
baseDir
TheFile
that contains a file to the root directory of the working project. Typically this directory is where thepom.xml
resides. -
siteDirectory
@Parameter(defaultValue="${project.build.directory}/site", property="commons.siteOutputDirectory") private File siteDirectoryThe location to which the site gets built during runningmvn site
. -
workingDirectory
@Parameter(defaultValue="${project.build.directory}/commons-release-plugin", property="commons.outputDirectory") private File workingDirectoryThe main working directory for the plugin, namelytarget/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 distCheckoutDirectoryThe 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 releaseNotesFileThe location of the RELEASE-NOTES.txt file such that multi-module builds can configure it. -
dryRun
A boolean that determines whether or not we actually commit the files up to the subversion repository. If this is set totrue
, we do all but make the commits. We do checkout the repository in question though. -
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 substringhttps
is a requirement. -
isDistModule
@Parameter(defaultValue="false", property="commons.release.isDistModule") private Boolean isDistModuleA parameter to generally avoid running unless it is specifically turned on by the consuming module. -
commonsReleaseVersion
The release version of the artifact to be built. -
commonsRcVersion
The RC version of the release. For example the first voted on candidate would be "RC1". -
distServer
-
username
The username for the distribution subversion repository. This is typically your Apache id. -
password
The password associated withusername
. -
settings
@Parameter(defaultValue="${settings}", readonly=true, required=true) private org.apache.maven.settings.Settings settingsMavenSettings
. -
settingsDecrypter
MavenSettingsDecrypter
component. -
distRcVersionDirectory
A subdirectory of the dist directory into which we are going to stage the release candidate. We build this up in theexecute()
method. And, for example, the directory should look likehttps://dist.apache.org/repos/dist/dev/commons/text/1.4-RC1
.
-
-
Constructor Details
-
CommonsDistributionStagingMojo
public CommonsDistributionStagingMojo()
-
-
Method Details
-
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
Lists all directories and files to a flat list. -
copyReleaseNotesToWorkingDirectory
private File copyReleaseNotesToWorkingDirectory() throws org.apache.maven.plugin.MojoExecutionExceptionA utility method that takes theRELEASE-NOTES.txt
file from the base directory of the project and copies it intoworkingDirectory
.- Returns:
- the RELEASE-NOTES.txt file that exists in the
target/commons-release-notes/scm
directory for the purpose of adding it to the scm change set in the methodcopyDistributionsIntoScmDirectoryStructureAndAddToSvn(File, ScmProvider, ScmRepository)
. - Throws:
org.apache.maven.plugin.MojoExecutionException
- if anIOException
occurs as a wrapper so that maven can properly handle the exception.
-
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 theworkingDirectory
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 thetarget/commons-release-plugin/scm
directory.provider
- is theScmProvider
that we will use for adding the files we wish to commit.repository
- is theScmRepository
that we will use for adding the files that we wish to commit.- Returns:
- a
List
ofFile
's in the directory for the purpose of adding them to the mavenScmFileSet
. - Throws:
org.apache.maven.plugin.MojoExecutionException
- if anIOException
occurs so that Maven can handle it properly.
- root:
-
copySignatureValidatorScriptToScmDirectory
private File copySignatureValidatorScriptToScmDirectory() throws org.apache.maven.plugin.MojoExecutionExceptionCopies oursignature-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
- if an error occurs while the resource is being copied
-
copySiteToScmDirectory
Copies${basedir}/target/site
to${basedir}/target/commons-release-plugin/scm/site
. -
buildReadmeAndHeaderHtmlFiles
private List<File> buildReadmeAndHeaderHtmlFiles() throws org.apache.maven.plugin.MojoExecutionExceptionBuilds upREADME.html
andHEADER.html
that reside in following.- 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
- if anIOException
occurs in the creation of these files fails.
- distRoot
-
copyHeaderAndReadmeToSubdirectories
private List<File> copyHeaderAndReadmeToSubdirectories(File headerFile, File readmeFile) throws org.apache.maven.plugin.MojoExecutionException CopiesREADME.html
andHEADER.html
to the source and binaries directories.- Parameters:
headerFile
- The originally createdHEADER.html
file.readmeFile
- The originally createdREADME.html
file.- Returns:
- a
List
of created files. - Throws:
org.apache.maven.plugin.MojoExecutionException
- if theSharedFunctions.copyFile(Log, File, File)
fails.
-
setBaseDir
This method is the setter for thebaseDir
field, specifically for the usage in the unit tests.- Parameters:
baseDir
- is theFile
to be used as the project's root directory when this mojo is invoked.
-