Repository: commons-release-plugin Updated Branches: refs/heads/master 92eb2abd3 -> 3b775f6f6
COMMONSSITE-113: moving the logic from parent to release-plugin Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/3b775f6f Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/3b775f6f Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/3b775f6f Branch: refs/heads/master Commit: 3b775f6f6a8d4a27aabafea7476084dd5b171a3d Parents: 92eb2ab Author: Rob Tompkins <chtom...@apache.org> Authored: Mon Jun 11 10:46:53 2018 -0400 Committer: Rob Tompkins <chtom...@apache.org> Committed: Mon Jun 11 10:46:53 2018 -0400 ---------------------------------------------------------------------- .../mojos/CommonsDistributionStagingMojo.java | 69 +++++++-------- .../CommonsDistributionStagingMojoTest.java | 90 ++++++++++---------- .../stage-distributions-disabled.xml | 2 + .../stage-distributions/stage-distributions.xml | 2 + 4 files changed, 83 insertions(+), 80 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3b775f6f/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java index af439f4..e86f56d 100755 --- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java +++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java @@ -130,6 +130,18 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { private Boolean isDistModule; /** + * The release version of the artifact to be built. + */ + @Parameter(property = "commons.release.version") + private String commonsReleaseVersion; + + /** + * The RC version of the release. For example the first voted on candidate would be "RC1". + */ + @Parameter(property = "commons.rc.version") + private String commonsRcVersion; + + /** * The username for the distribution subversion repository. This is typically your Apache id. */ @Parameter(property = "user.name") @@ -141,6 +153,13 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { @Parameter(property = "user.password") private String password; + /** + * A subdirectory of the dist directory into which we are going to stage the release candidate. We + * build this up in the {@link CommonsDistributionStagingMojo#execute()} method. And, for example, + * the directory should look like <code>https://https://dist.apache.org/repos/dist/dev/commons/text/1.4-RC1</code>. + */ + private File distVersionRcVersionDirectory; + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (!isDistModule) { @@ -165,6 +184,8 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository(); providerRepository.setUser(username); providerRepository.setPassword(password); + distVersionRcVersionDirectory = + new File(distCheckoutDirectory, commonsReleaseVersion + "-" + commonsRcVersion); if (!distCheckoutDirectory.exists()) { SharedFunctions.initDirectory(getLog(), distCheckoutDirectory); } @@ -221,11 +242,9 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { */ private File copyReleaseNotesToWorkingDirectory() throws MojoExecutionException { StringBuffer copiedReleaseNotesAbsolutePath; + SharedFunctions.initDirectory(getLog(), distVersionRcVersionDirectory); getLog().info("Copying RELEASE-NOTES.txt to working directory."); - copiedReleaseNotesAbsolutePath = new StringBuffer(workingDirectory.getAbsolutePath()); - copiedReleaseNotesAbsolutePath.append("/scm/"); - copiedReleaseNotesAbsolutePath.append(releaseNotesFile.getName()); - File copiedReleaseNotes = new File(copiedReleaseNotesAbsolutePath.toString()); + File copiedReleaseNotes = new File(distVersionRcVersionDirectory, releaseNotesFile.getName()); SharedFunctions.copyFile(getLog(), releaseNotesFile, copiedReleaseNotes); return copiedReleaseNotes; } @@ -258,10 +277,10 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { private List<File> copyDistributionsIntoScmDirectoryStructure(File copiedReleaseNotes) throws MojoExecutionException { List<File> workingDirectoryFiles = Arrays.asList(workingDirectory.listFiles()); - String scmBinariesRoot = buildDistBinariesRoot(); - String scmSourceRoot = buildDistSourceRoot(); - SharedFunctions.initDirectory(getLog(), new File(scmBinariesRoot)); - SharedFunctions.initDirectory(getLog(), new File(scmSourceRoot)); + File scmBinariesRoot = new File(distVersionRcVersionDirectory, "binaries"); + File scmSourceRoot = new File(distVersionRcVersionDirectory, "source"); + SharedFunctions.initDirectory(getLog(), scmBinariesRoot); + SharedFunctions.initDirectory(getLog(), scmSourceRoot); List<File> filesForMavenScmFileSet = new ArrayList<>(); File copy; for (File file : workingDirectoryFiles) { @@ -303,7 +322,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { ); } try { - FileUtils.copyDirectoryToDirectory(siteDirectory, distCheckoutDirectory); + FileUtils.copyDirectoryToDirectory(siteDirectory, distVersionRcVersionDirectory); } catch (IOException e) { throw new MojoExecutionException("Site copying failed", e); } @@ -330,7 +349,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { */ private List<File> buildReadmeAndHeaderHtmlFiles() throws MojoExecutionException { List<File> headerAndReadmeFiles = new ArrayList<>(); - File headerFile = new File(distCheckoutDirectory, HEADER_FILE_NAME); + File headerFile = new File(distVersionRcVersionDirectory, HEADER_FILE_NAME); // // HEADER file // @@ -345,7 +364,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { // // README file // - File readmeFile = new File(distCheckoutDirectory, README_FILE_NAME); + File readmeFile = new File(distVersionRcVersionDirectory, README_FILE_NAME); try (Writer readmeWriter = new OutputStreamWriter(new FileOutputStream(readmeFile), "UTF-8")) { // @formatter:off ReadmeHtmlVelocityDelegate readmeHtmlVelocityDelegate = ReadmeHtmlVelocityDelegate.builder() @@ -378,8 +397,8 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { private List<File> copyHeaderAndReadmeToSubdirectories(File headerFile, File readmeFile) throws MojoExecutionException { List<File> symbolicLinkFiles = new ArrayList<>(); - File sourceRoot = new File(buildDistSourceRoot()); - File binariesRoot = new File(buildDistBinariesRoot()); + File sourceRoot = new File(distVersionRcVersionDirectory, "source"); + File binariesRoot = new File(distVersionRcVersionDirectory, "binaries"); File sourceHeaderFile = new File(sourceRoot, HEADER_FILE_NAME); File sourceReadmeFile = new File(sourceRoot, README_FILE_NAME); File binariesHeaderFile = new File(binariesRoot, HEADER_FILE_NAME); @@ -396,30 +415,6 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { } /** - * Build the path for the distribution binaries directory. - * - * @return the local absolute path into the checked out subversion repository that is where - * the binaries distributions are to be copied. - */ - private String buildDistBinariesRoot() { - StringBuffer buffer = new StringBuffer(distCheckoutDirectory.getAbsolutePath()); - buffer.append("/binaries"); - return buffer.toString(); - } - - /** - * Build the path for the distribution source directory. - * - * @return the local absolute path into the checked out subversion repository that is where - * the source distributions are to be copied. - */ - private String buildDistSourceRoot() { - StringBuffer buffer = new StringBuffer(distCheckoutDirectory.getAbsolutePath()); - buffer.append("/source"); - return buffer.toString(); - } - - /** * This method is the setter for the {@link CommonsDistributionStagingMojo#baseDir} field, specifically * for the usage in the unit tests. * http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3b775f6f/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java index 2542a75..9b40cc7 100755 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java @@ -75,38 +75,53 @@ public class CommonsDistributionStagingMojoTest { File releaseNotesBasedir = new File("src/test/resources/mojos/stage-distributions/"); mojoForTest.setBaseDir(releaseNotesBasedir); mojoForTest.execute(); - File targetScmDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm"); - File releaseNotes = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/RELEASE-NOTES.txt"); - File readmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/README.html"); - File headerHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/HEADER.html"); - File binariesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/README.html"); - File binariesHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/HEADER.html"); - File binTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedTar-bin.tar.gz"); - File binTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedTar-bin.tar.gz.asc"); - File binTarMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedTar-bin.tar.gz.md5"); - File binTarSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedTar-bin.tar.gz.sha1"); - File binTarSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedTar-bin.tar.gz.sha256"); - File binZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedZip-bin.zip"); - File binZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedZip-bin.zip.asc"); - File binZipMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedZip-bin.zip.md5"); - File binZipSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedZip-bin.zip.sha1"); - File binZipSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/mockAttachedZip-bin.zip.sha256"); - File sourcesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/README.html"); - File sourceHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/binaries/HEADER.html"); - File srcTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedTar-src.tar.gz"); - File srcTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedTar-src.tar.gz.asc"); - File srcTarMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedTar-src.tar.gz.md5"); - File srcTarSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedTar-src.tar.gz.sha1"); - File srcTarSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedTar-src.tar.gz.sha256"); - File srcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedZip-src.zip"); - File srcZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedZip-src.zip.asc"); - File srcZipMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedZip-src.zip.md5"); - File srcZipSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedZip-src.zip.sha1"); - File srcZipSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/source/mockAttachedZip-src.zip.sha256"); - File site = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/site"); - File siteIndexHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/site/index.html"); - File siteSubdirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/site/subdirectory"); - File siteSubdirectoryIndexHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/site/subdirectory/index.html"); + assertRequisiteFilesExist(); + } + + @Test + public void testDisabled() throws Exception { + File testPom = new File("src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml"); + assertNotNull(testPom); + assertTrue(testPom.exists()); + mojoForTest = (CommonsDistributionStagingMojo) rule.lookupMojo("stage-distributions", testPom); + mojoForTest.execute(); + File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + assertFalse(testingDirectory.exists()); + } + + private void assertRequisiteFilesExist() { + File targetScmDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1"); + File releaseNotes = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/RELEASE-NOTES.txt"); + File readmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/README.html"); + File headerHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/HEADER.html"); + File binariesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/README.html"); + File binariesHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/HEADER.html"); + File binTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedTar-bin.tar.gz"); + File binTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedTar-bin.tar.gz.asc"); + File binTarMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedTar-bin.tar.gz.md5"); + File binTarSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedTar-bin.tar.gz.sha1"); + File binTarSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedTar-bin.tar.gz.sha256"); + File binZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedZip-bin.zip"); + File binZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedZip-bin.zip.asc"); + File binZipMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedZip-bin.zip.md5"); + File binZipSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedZip-bin.zip.sha1"); + File binZipSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/mockAttachedZip-bin.zip.sha256"); + File sourcesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/README.html"); + File sourceHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/HEADER.html"); + File srcTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedTar-src.tar.gz"); + File srcTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedTar-src.tar.gz.asc"); + File srcTarMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedTar-src.tar.gz.md5"); + File srcTarSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedTar-src.tar.gz.sha1"); + File srcTarSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedTar-src.tar.gz.sha256"); + File srcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedZip-src.zip"); + File srcZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedZip-src.zip.asc"); + File srcZipMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedZip-src.zip.md5"); + File srcZipSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedZip-src.zip.sha1"); + File srcZipSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/mockAttachedZip-src.zip.sha256"); + File site = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site"); + File siteIndexHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site/index.html"); + File siteSubdirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site/subdirectory"); + File siteSubdirectoryIndexHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site/subdirectory/index.html"); assertTrue(targetScmDirectory.exists()); assertTrue(releaseNotes.exists()); assertTrue(readmeHtml.exists()); @@ -140,15 +155,4 @@ public class CommonsDistributionStagingMojoTest { assertTrue(siteSubdirectory.exists()); assertTrue(siteSubdirectoryIndexHtml.exists()); } - - @Test - public void testDisabled() throws Exception { - File testPom = new File("src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml"); - assertNotNull(testPom); - assertTrue(testPom.exists()); - mojoForTest = (CommonsDistributionStagingMojo) rule.lookupMojo("stage-distributions", testPom); - mojoForTest.execute(); - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); - assertFalse(testingDirectory.exists()); - } } http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3b775f6f/src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml b/src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml index 987e3a2..023a57f 100755 --- a/src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml +++ b/src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml @@ -50,6 +50,8 @@ <distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/release-plugin</distSvnStagingUrl> <isDistModule>false</isDistModule> <dryRun>true</dryRun> + <commonsReleaseVersion>1.0-SNAPSHOT</commonsReleaseVersion> + <commonsRcVersion>RC1</commonsRcVersion> </configuration> </plugin> </plugins> http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3b775f6f/src/test/resources/mojos/stage-distributions/stage-distributions.xml ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/stage-distributions/stage-distributions.xml b/src/test/resources/mojos/stage-distributions/stage-distributions.xml index cdbb9aa..b191969 100755 --- a/src/test/resources/mojos/stage-distributions/stage-distributions.xml +++ b/src/test/resources/mojos/stage-distributions/stage-distributions.xml @@ -50,6 +50,8 @@ <distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/release-plugin</distSvnStagingUrl> <isDistModule>true</isDistModule> <dryRun>true</dryRun> + <commonsReleaseVersion>1.0-SNAPSHOT</commonsReleaseVersion> + <commonsRcVersion>RC1</commonsRcVersion> </configuration> </plugin> </plugins>