Skip to content
Permalink
Browse files
COMMONSSITE-113: site unpacked in dist staging area now
  • Loading branch information
chtompki committed Jun 1, 2018
1 parent 6ae1e8b commit 4cda015b5e088dd0d187c507e1982bbb9ee37dba
Showing 7 changed files with 98 additions and 8 deletions.
@@ -16,14 +16,7 @@
*/
package org.apache.commons.release.plugin.mojos;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.release.plugin.SharedFunctions;
import org.apache.commons.release.plugin.velocity.HeaderHtmlVelocityDelegate;
@@ -47,6 +40,15 @@
import org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider;
import org.apache.maven.scm.repository.ScmRepository;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* This class checks out the dev distribution location, copies the distributions into that directory
* structure under the <code>target/commons-release-plugin/scm</code> directory. Then commits the
@@ -80,6 +82,10 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
@Parameter(defaultValue = "${basedir}")
private File baseDir;

/** The location to which the site gets built during running <code>mvn site</code>. */
@Parameter(defaultValue = "${project.build.directory}/site", property = "commons.siteOutputDirectory")
private File siteDirectory;

/**
* The main working directory for the plugin, namely <code>target/commons-release-plugin</code>, but
* that assumes that we're using the default maven <code>${project.build.directory}</code>.
@@ -276,11 +282,34 @@ private List<File> copyDistributionsIntoScmDirectoryStructure(File copiedRelease
filesForMavenScmFileSet.add(copy);
}
}
filesForMavenScmFileSet.addAll(copySiteToScmDirectory());
filesForMavenScmFileSet.addAll(buildReadmeAndHeaderHtmlFiles());
filesForMavenScmFileSet.add(copiedReleaseNotes);
return filesForMavenScmFileSet;
}

/**
* Copies <code>${basedir}/target/site</code> to <code>${basedir}/target/commons-release-plugin/scm/site</code>.
*
* @return the {@link List} of {@link File}'s contained in
* <code>${basedir}/target/commons-release-plugin/scm/site</code>, after the copy is complete.
* @throws MojoExecutionException if the site copying fails for some reason.
*/
private List<File> copySiteToScmDirectory() throws MojoExecutionException {
if (!siteDirectory.exists()) {
getLog().error("\"mvn site\" was not run before this goal, or a siteDirectory did not exist.");
throw new MojoExecutionException(
"\"mvn site\" was not run before this goal, or a siteDirectory did not exist."
);
}
try {
FileUtils.copyDirectoryToDirectory(siteDirectory, distCheckoutDirectory);
} catch (IOException e) {
throw new MojoExecutionException("Site copying failed", e);
}
return new ArrayList<>(FileUtils.listFiles(siteDirectory, null, true));
}

/**
* Builds up <code>README.html</code> and <code>HEADER.html</code> that reside in following.
* <ul>
@@ -42,7 +42,10 @@
*
* @author chtompki
* @since 1.0
* @deprecated - as we no longer wish to compress the site, we are going to put this functionality in the
* {@link CommonsDistributionStagingMojo}.
*/
@Deprecated
@Mojo(name = "compress-site",
defaultPhase = LifecyclePhase.POST_SITE,
threadSafe = true,
@@ -103,6 +103,10 @@ public void testSuccess() throws Exception {
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");
assertTrue(targetScmDirectory.exists());
assertTrue(releaseNotes.exists());
assertTrue(readmeHtml.exists());
@@ -131,6 +135,10 @@ public void testSuccess() throws Exception {
assertTrue(srcZipMD5.exists());
assertTrue(srcZipSHA1.exists());
assertTrue(srcZipSHA256.exists());
assertTrue(site.exists());
assertTrue(siteIndexHtml.exists());
assertTrue(siteSubdirectory.exists());
assertTrue(siteSubdirectoryIndexHtml.exists());
}

@Test
@@ -0,0 +1,24 @@
<html>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<header><title>Mock maven site</title></header>
<body>
mock body
</body>
</html>
@@ -0,0 +1,24 @@
<html>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<header><title>Mock maven site</title></header>
<body>
mock body
</body>
</html>
@@ -45,6 +45,7 @@
<project implementation="org.apache.commons.release.plugin.stubs.DistributionDetachmentProjectStub" />
<workingDirectory>target/testing-commons-release-plugin</workingDirectory>
<distCheckoutDirectory>target/testing-commons-release-plugin/scm</distCheckoutDirectory>
<siteDirectory>${basedir}/target/test-classes/mojos/detach-distributions/target/site</siteDirectory>
<releaseNotesFile>src/test/resources/mojos/stage-distributions/RELEASE-NOTES.txt</releaseNotesFile>
<distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/release-plugin</distSvnStagingUrl>
<isDistModule>false</isDistModule>
@@ -45,6 +45,7 @@
<project implementation="org.apache.commons.release.plugin.stubs.DistributionDetachmentProjectStub" />
<workingDirectory>target/testing-commons-release-plugin</workingDirectory>
<distCheckoutDirectory>target/testing-commons-release-plugin/scm</distCheckoutDirectory>
<siteDirectory>${basedir}/target/test-classes/mojos/detach-distributions/target/site</siteDirectory>
<releaseNotesFile>src/test/resources/mojos/stage-distributions/RELEASE-NOTES.txt</releaseNotesFile>
<distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/release-plugin</distSvnStagingUrl>
<isDistModule>true</isDistModule>

0 comments on commit 4cda015

Please sign in to comment.