@Mojo(name="compress-site",
defaultPhase=POST_SITE,
threadSafe=true)
public class CommonsSiteCompressionMojo
extends org.apache.maven.plugin.AbstractMojo
./target/site
directory and compresses it to
./target/commons-release-plugin/site.zip
.Modifier and Type | Field and Description |
---|---|
private org.apache.commons.compress.archivers.zip.ScatterZipOutputStream |
dirs
A variable for the process of creating the site.zip file.
|
private List<File> |
filesToCompress
The list of files to compress into the site.zip file.
|
private org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator |
scatterZipCreator
A second variable for the process of creating the site.zip file.
|
private File |
siteDirectory |
private File |
workingDirectory
The working directory for the plugin which, assuming the maven uses the default
${project.build.directory} , this becomes target/commons-release-plugin . |
Constructor and Description |
---|
CommonsSiteCompressionMojo() |
Modifier and Type | Method and Description |
---|---|
private void |
addToZip(File directoryToZip,
File file,
ZipOutputStream zos)
Given the
directoryToZip we add the file to the zip archive represented by
zos . |
void |
execute() |
private void |
getAllSiteFiles(File siteDirectory,
List<File> filesToCompress)
By default this method iterates across the
target/site directory and adds all of the files
to the filesToCompress List . |
private void |
writeZipFile(File workingDirectory,
File directoryToZip,
List<File> fileList)
A helper method for writing all of the files in our
fileList to a site.zip file
in the workingDirectory . |
@Parameter(defaultValue="${project.build.directory}/commons-release-plugin", alias="outputDirectory") private File workingDirectory
${project.build.directory}
, this becomes target/commons-release-plugin
.@Parameter(defaultValue="${project.build.directory}/site", alias="siteOutputDirectory") private File siteDirectory
private org.apache.commons.compress.archivers.zip.ScatterZipOutputStream dirs
private org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator scatterZipCreator
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
private void getAllSiteFiles(File siteDirectory, List<File> filesToCompress)
target/site
directory and adds all of the files
to the filesToCompress
List
.private void writeZipFile(File workingDirectory, File directoryToZip, List<File> fileList) throws IOException
fileList
to a site.zip
file
in the workingDirectory
.workingDirectory
- is a File
representing the place to put the site.zip file.directoryToZip
- is a File
representing the directory of the site (normally
target/site
).fileList
- the list of files to be zipped up, generally generated by
getAllSiteFiles(File, List)
.IOException
- when the copying of the files goes incorrectly.private void addToZip(File directoryToZip, File file, ZipOutputStream zos) throws IOException
directoryToZip
we add the file
to the zip archive represented by
zos
.directoryToZip
- a File
representing the directory from which the file exists that we are
compressing. Generally this is target/site
.file
- a File
to add to the ZipOutputStream
zos
.zos
- the ZipOutputStream
to which to add our file
.IOException
- if adding the file
doesn't work out properly.Copyright © 2018 The Apache Software Foundation. All rights reserved.