You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2018/01/09 15:58:59 UTC
commons-release-plugin git commit: COMMONSSITE-99: All checkstyle and
findbugs errors sorted out for now
Repository: commons-release-plugin
Updated Branches:
refs/heads/master 21e282ae6 -> 3ff3a7cb2
COMMONSSITE-99: All checkstyle and findbugs errors sorted out for now
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/3ff3a7cb
Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/3ff3a7cb
Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/3ff3a7cb
Branch: refs/heads/master
Commit: 3ff3a7cb23c1114f415220b129bc560551230d58
Parents: 21e282a
Author: Rob Tompkins <ch...@gmail.com>
Authored: Tue Jan 9 10:58:54 2018 -0500
Committer: Rob Tompkins <ch...@gmail.com>
Committed: Tue Jan 9 10:58:54 2018 -0500
----------------------------------------------------------------------
fb-excludes.xml | 30 +++++++++++-
.../commons/release/plugin/SharedFunctions.java | 2 +-
.../mojos/CommonsSiteCompressionMojo.java | 48 ++++++++++++++++++--
3 files changed, 75 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3ff3a7cb/fb-excludes.xml
----------------------------------------------------------------------
diff --git a/fb-excludes.xml b/fb-excludes.xml
index ceca29f..9e64cdc 100644
--- a/fb-excludes.xml
+++ b/fb-excludes.xml
@@ -14,5 +14,33 @@
limitations under the License.
-->
<FindBugsFilter>
-
+ <!-- Omit junit tests -->
+ <Match>
+ <Class name="~.*\.*Test.*"/>
+ <Not>
+ <Bug code="IJU"/>
+ </Not>
+ </Match>
+ <Match>
+ <Class name="~.*\.*Test.*"/>
+ <Not>
+ <Bug pattern="SE_BAD_FIELD, EI_EXPOSE_REP, EI_EXPOSE_REP2"/>
+ </Not>
+ </Match>
+ <Match>
+ <Class name="~.*\.*SharedFunctions.*" />
+ <Bug pattern="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE,RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
+ </Match>
+ <Match>
+ <Class name="~.*\.*CommonsDistributionDetachmentMojo.*" />
+ <Bug pattern="DM_DEFAULT_ENCODING" />
+ </Match>
+ <Match>
+ <Class name="~.*\.*CommonsDistributionStagingMojo.*" />
+ <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
+ </Match>
+ <Match>
+ <Class name="~.*\.*CommonsSiteCompressionMojo.*" />
+ <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE,OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE,UUF_UNUSED_FIELD" />
+ </Match>
</FindBugsFilter>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3ff3a7cb/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
index eaf7927..f5ecde4 100644
--- a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
+++ b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
@@ -37,7 +37,7 @@ public final class SharedFunctions {
* I want a buffer that is an array with 1024 elements of bytes. We declare
* the constant here for the sake of making the code more readable.
*/
- private static final int BUFFER_BYTE_SIZE = 1024;
+ public static final int BUFFER_BYTE_SIZE = 1024;
/**
* Making the constructor private because the class only contains static methods.
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/3ff3a7cb/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
index c5d5af9..7fa14a8 100644
--- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
+++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
@@ -46,6 +46,8 @@ import java.util.zip.ZipOutputStream;
public class CommonsSiteCompressionMojo extends AbstractMojo {
/**
+ * The working directory for the plugin which, assuming the maven uses the default
+ * <code>${project.build.directory}</code>, this becomes <code>target/commons-release-plugin</code>.
*/
@Parameter(defaultValue = "${project.build.directory}/commons-release-plugin", alias = "outputDirectory")
private File workingDirectory;
@@ -55,10 +57,19 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.build.directory}/site", alias = "siteOutputDirectory")
private File siteDirectory;
+ /**
+ * A variable for the process of creating the site.zip file.
+ */
private ScatterZipOutputStream dirs;
+ /**
+ * A second variable for the process of creating the site.zip file.
+ */
private ParallelScatterZipCreator scatterZipCreator;
+ /**
+ * The list of files to compress into the site.zip file.
+ */
private List<File> filesToCompress;
@Override
@@ -78,11 +89,21 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
writeZipFile(workingDirectory, siteDirectory, filesToCompress);
} catch (IOException e) {
getLog().error("Failed to create ./target/commons-release-plugin/site.zip: " + e.getMessage(), e);
- throw new MojoExecutionException("Failed to create ./target/commons-release-plugin/site.zip: " + e.getMessage(), e);
+ throw new MojoExecutionException(
+ "Failed to create ./target/commons-release-plugin/site.zip: " + e.getMessage(),
+ e
+ );
}
}
- private void getAllSiteFiles(File siteDirectory, List<File> filesToCompress) throws IOException {
+ /**
+ * By default this method iterates across the <code>target/site</code> directory and adds all of the files
+ * to the {@link CommonsSiteCompressionMojo#filesToCompress} {@link List}.
+ *
+ * @param siteDirectory the {@link File} that represents the <code>target/site</code> directory.
+ * @param filesToCompress the {@link List} to which to add all the files.
+ */
+ private void getAllSiteFiles(File siteDirectory, List<File> filesToCompress) {
File[] files = siteDirectory.listFiles();
for (File file : files) {
filesToCompress.add(file);
@@ -92,6 +113,17 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
}
}
+ /**
+ * A helper method for writing all of the files in our <code>fileList</code> to a <code>site.zip</code> file
+ * in the <code>workingDirectory</code>.
+ *
+ * @param workingDirectory is a {@link File} representing the place to put the site.zip file.
+ * @param directoryToZip is a {@link File} representing the directory of the site (normally
+ * <code>target/site</code>).
+ * @param fileList the list of files to be zipped up, generally generated by
+ * {@link CommonsSiteCompressionMojo#getAllSiteFiles(File, List)}.
+ * @throws IOException when the copying of the files goes incorrectly.
+ */
private void writeZipFile(File workingDirectory, File directoryToZip, List<File> fileList) throws IOException {
FileOutputStream fos = new FileOutputStream(workingDirectory.getAbsolutePath() + "/site.zip");
ZipOutputStream zos = new ZipOutputStream(fos);
@@ -104,6 +136,16 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
fos.close();
}
+ /**
+ * Given the <code>directoryToZip</code> we add the <code>file</code> to the zip archive represented by
+ * <code>zos</code>.
+ *
+ * @param directoryToZip a {@link File} representing the directory from which the file exists that we are
+ * compressing. Generally this is <code>target/site</code>.
+ * @param file a {@link File} to add to the {@link ZipOutputStream} <code>zos</code>.
+ * @param zos the {@link ZipOutputStream} to which to add our <code>file</code>.
+ * @throws IOException if adding the <code>file</code> doesn't work out properly.
+ */
private void addToZip(File directoryToZip, File file, ZipOutputStream zos) throws IOException {
FileInputStream fis = new FileInputStream(file);
// we want the zipEntry's path to be a relative path that is relative
@@ -112,7 +154,7 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
file.getCanonicalPath().length());
ZipEntry zipEntry = new ZipEntry(zipFilePath);
zos.putNextEntry(zipEntry);
- byte[] bytes = new byte[1024];
+ byte[] bytes = new byte[SharedFunctions.BUFFER_BYTE_SIZE];
int length;
while ((length = fis.read(bytes)) >= 0) {
zos.write(bytes, 0, length);