This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-release-plugin.git
The following commit(s) were added to refs/heads/master by this push: new 9dfa6b3 Use final. 9dfa6b3 is described below commit 9dfa6b3a872d58590f18f8f925f4f8e3afedb7b1 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Sun Apr 7 09:37:51 2019 -0400 Use final. --- .../commons/release/plugin/SharedFunctions.java | 18 ++--- .../mojos/CommonsDistributionDetachmentMojo.java | 38 +++++----- .../mojos/CommonsDistributionStagingMojo.java | 80 +++++++++++----------- .../plugin/mojos/CommonsSiteCompressionMojo.java | 18 ++--- .../plugin/mojos/CommonsStagingCleanupMojo.java | 20 +++--- .../velocity/HeaderHtmlVelocityDelegate.java | 8 +-- .../velocity/ReadmeHtmlVelocityDelegate.java | 22 +++--- .../CommonsDistributionDetachmentMojoTest.java | 36 +++++----- .../mojos/CommonsDistributionStagingMojoTest.java | 60 ++++++++-------- .../mojos/CommonsSiteCompressionMojoTest.java | 16 ++--- .../mojos/CommonsStagingCleanupMojoTest.java | 8 +-- .../stubs/DistributionDetachmentProjectStub.java | 4 +- .../velocity/HeaderHtmlVelocityDelegateTest.java | 2 +- .../velocity/ReadmeHtmlVelocityDelegateTest.java | 12 ++-- 14 files changed, 171 insertions(+), 171 deletions(-) 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 feb786d..fb04950 100755 --- a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java +++ b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java @@ -60,7 +60,7 @@ public final class SharedFunctions { * @throws MojoExecutionException when an {@link IOException} or {@link NullPointerException} is caught for the * purpose of bubbling the exception up to Maven properly. */ - public static void initDirectory(Log log, File workingDirectory) throws MojoExecutionException { + public static void initDirectory(final Log log, final File workingDirectory) throws MojoExecutionException { if (workingDirectory.exists()) { try { FileUtils.deleteDirectory(workingDirectory); @@ -85,7 +85,7 @@ public final class SharedFunctions { * @param toFile the {@link File} to which to copy into. * @throws MojoExecutionException if an {@link IOException} or {@link NullPointerException} is caught. */ - public static void copyFile(Log log, File fromFile, File toFile) throws MojoExecutionException { + public static void copyFile(final Log log, final File fromFile, final File toFile) throws MojoExecutionException { try { FileUtils.copyFile(fromFile, toFile); } catch (IOException | NullPointerException e) { @@ -104,13 +104,13 @@ public final class SharedFunctions { * @param username temp. * @param password temp. */ - public static void setAuthentication(ScmProviderRepository providerRepository, - String distServer, - Settings settings, - SettingsDecrypter settingsDecrypter, - String username, - String password) { - Optional<Server> server = + public static void setAuthentication(final ScmProviderRepository providerRepository, + final String distServer, + final Settings settings, + final SettingsDecrypter settingsDecrypter, + final String username, + final String password) { + final Optional<Server> server = Optional.ofNullable(distServer).map(settings::getServer).map(DefaultSettingsDecryptionRequest::new) .map(settingsDecrypter::decrypt).map(SettingsDecryptionResult::getServer); diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java index 285cb0a..9c54c1e 100755 --- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java +++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java @@ -62,7 +62,7 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { */ private static final Set<String> ARTIFACT_TYPES_TO_DETACH; static { - Set<String> hashSet = new HashSet<>(); + final Set<String> hashSet = new HashSet<>(); hashSet.add("zip"); hashSet.add("tar.gz"); hashSet.add("zip.asc"); @@ -120,7 +120,7 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { return; } getLog().info("Detaching Assemblies"); - for (Object attachedArtifact : project.getAttachedArtifacts()) { + for (final Object attachedArtifact : project.getAttachedArtifacts()) { putAttachedArtifactInSha512Map((Artifact) attachedArtifact); if (ARTIFACT_TYPES_TO_DETACH.contains(((Artifact) attachedArtifact).getType())) { detachedArtifacts.add((Artifact) attachedArtifact); @@ -130,7 +130,7 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { getLog().info("Current project contains no distributions. Not executing."); return; } - for (Artifact artifactToRemove : detachedArtifacts) { + for (final Artifact artifactToRemove : detachedArtifacts) { project.getAttachedArtifacts().remove(artifactToRemove); } if (!workingDirectory.exists()) { @@ -148,13 +148,13 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { * @throws MojoExecutionException if an {@link IOException} occurs when getting the sha512 of the * artifact. */ - private void putAttachedArtifactInSha512Map(Artifact artifact) throws MojoExecutionException { + private void putAttachedArtifactInSha512Map(final Artifact artifact) throws MojoExecutionException { try { - String artifactKey = getArtifactKey(artifact); + final String artifactKey = getArtifactKey(artifact); try (FileInputStream fis = new FileInputStream(artifact.getFile())) { artifactSha512s.put(artifactKey, DigestUtils.sha512Hex(fis)); } - } catch (IOException e) { + } catch (final IOException e) { throw new MojoExecutionException( "Could not find artifact signature for: " + artifact.getArtifactId() @@ -174,11 +174,11 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { * @throws MojoExecutionException if we can't write the file due to an {@link IOException}. */ private void writeAllArtifactsInSha512PropertiesFile() throws MojoExecutionException { - File propertiesFile = new File(workingDirectory, "sha512.properties"); + final File propertiesFile = new File(workingDirectory, "sha512.properties"); getLog().info("Writting " + propertiesFile); try (FileOutputStream fileWriter = new FileOutputStream(propertiesFile)) { artifactSha512s.store(fileWriter, "Release SHA-512s"); - } catch (IOException e) { + } catch (final IOException e) { throw new MojoExecutionException("Failure to write SHA-512's", e); } } @@ -194,12 +194,12 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { final String wdAbsolutePath = workingDirectory.getAbsolutePath(); getLog().info( "Copying " + detachedArtifacts.size() + " detached artifacts to working directory " + wdAbsolutePath); - for (Artifact artifact: detachedArtifacts) { - File artifactFile = artifact.getFile(); - StringBuilder copiedArtifactAbsolutePath = new StringBuilder(wdAbsolutePath); + for (final Artifact artifact: detachedArtifacts) { + final File artifactFile = artifact.getFile(); + final StringBuilder copiedArtifactAbsolutePath = new StringBuilder(wdAbsolutePath); copiedArtifactAbsolutePath.append("/"); copiedArtifactAbsolutePath.append(artifactFile.getName()); - File copiedArtifact = new File(copiedArtifactAbsolutePath.toString()); + final File copiedArtifact = new File(copiedArtifactAbsolutePath.toString()); getLog().info("Copying: " + artifactFile.getName()); SharedFunctions.copyFile(getLog(), artifactFile, copiedArtifact); } @@ -214,9 +214,9 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { * properly wrapped so that Maven can handle it. */ private void hashArtifacts() throws MojoExecutionException { - for (Artifact artifact : detachedArtifacts) { + for (final Artifact artifact : detachedArtifacts) { if (!artifact.getFile().getName().contains("asc")) { - String artifactKey = getArtifactKey(artifact); + final String artifactKey = getArtifactKey(artifact); try { String digest; // SHA-512 @@ -226,7 +226,7 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { getSha512FilePath(workingDirectory, artifact.getFile()))) { printWriter.println(digest); } - } catch (IOException e) { + } catch (final IOException e) { throw new MojoExecutionException("Could not sign file: " + artifact.getFile().getName(), e); } } @@ -240,8 +240,8 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { * @param file the {@link File} whose name we should use to create the <code>.sha512</code> file. * @return a {@link String} that is the absolute path to the <code>.sha512</code> file. */ - private String getSha512FilePath(File directory, File file) { - StringBuilder buffer = new StringBuilder(directory.getAbsolutePath()); + private String getSha512FilePath(final File directory, final File file) { + final StringBuilder buffer = new StringBuilder(directory.getAbsolutePath()); buffer.append("/"); buffer.append(file.getName()); buffer.append(".sha512"); @@ -255,8 +255,8 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { * @param artifact the {@link Artifact} that we wish to generate a key for. * @return the generated key */ - private String getArtifactKey(Artifact artifact) { - StringBuilder artifactKey = new StringBuilder(); + private String getArtifactKey(final Artifact artifact) { + final StringBuilder artifactKey = new StringBuilder(); artifactKey.append(artifact.getArtifactId()).append('-') .append(artifact.getVersion()).append('-'); if (artifact.hasClassifier()) { 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 d592974..6b7d87f 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 @@ -200,11 +200,11 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { } getLog().info("Preparing to stage distributions"); try { - ScmManager scmManager = new BasicScmManager(); + final ScmManager scmManager = new BasicScmManager(); scmManager.setScmProvider("svn", new SvnExeScmProvider()); - ScmRepository repository = scmManager.makeScmRepository(distSvnStagingUrl); - ScmProvider provider = scmManager.getProviderByRepository(repository); - SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository(); + final ScmRepository repository = scmManager.makeScmRepository(distSvnStagingUrl); + final ScmProvider provider = scmManager.getProviderByRepository(repository); + final SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository(); SharedFunctions.setAuthentication( providerRepository, distServer, @@ -218,21 +218,21 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { if (!distCheckoutDirectory.exists()) { SharedFunctions.initDirectory(getLog(), distCheckoutDirectory); } - ScmFileSet scmFileSet = new ScmFileSet(distCheckoutDirectory); + final ScmFileSet scmFileSet = new ScmFileSet(distCheckoutDirectory); getLog().info("Checking out dist from: " + distSvnStagingUrl); final CheckOutScmResult checkOutResult = provider.checkOut(repository, scmFileSet); if (!checkOutResult.isSuccess()) { throw new MojoExecutionException("Failed to checkout files from SCM: " + checkOutResult.getProviderMessage() + " [" + checkOutResult.getCommandOutput() + "]"); } - File copiedReleaseNotes = copyReleaseNotesToWorkingDirectory(); + final File copiedReleaseNotes = copyReleaseNotesToWorkingDirectory(); copyDistributionsIntoScmDirectoryStructureAndAddToSvn(copiedReleaseNotes, provider, repository); - List<File> filesToAdd = new ArrayList<>(); + final List<File> filesToAdd = new ArrayList<>(); listNotHiddenFilesAndDirectories(distCheckoutDirectory, filesToAdd); if (!dryRun) { - ScmFileSet fileSet = new ScmFileSet(distCheckoutDirectory, filesToAdd); - AddScmResult addResult = provider.add( + final ScmFileSet fileSet = new ScmFileSet(distCheckoutDirectory, filesToAdd); + final AddScmResult addResult = provider.add( repository, fileSet ); @@ -241,7 +241,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { + " [" + addResult.getCommandOutput() + "]"); } getLog().info("Staging release: " + project.getArtifactId() + ", version: " + project.getVersion()); - CheckInScmResult checkInResult = provider.checkIn( + final CheckInScmResult checkInResult = provider.checkIn( repository, fileSet, "Staging release: " + project.getArtifactId() + ", version: " + project.getVersion() @@ -258,7 +258,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { getLog().info( "[Dry run] Staging release: " + project.getArtifactId() + ", version: " + project.getVersion()); } - } catch (ScmException e) { + } catch (final ScmException e) { getLog().error("Could not commit files to dist: " + distSvnStagingUrl, e); throw new MojoExecutionException("Could not commit files to dist: " + distSvnStagingUrl, e); } @@ -269,10 +269,10 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { * @param directory {@link File} containing directory to list * @param files a {@link List} of {@link File} to which to append the files. */ - private void listNotHiddenFilesAndDirectories(File directory, List<File> files) { + private void listNotHiddenFilesAndDirectories(final File directory, final List<File> files) { // Get all the files and directories from a directory. - File[] fList = directory.listFiles(); - for (File file : fList) { + final File[] fList = directory.listFiles(); + for (final File file : fList) { if (file.isFile() && !file.isHidden()) { files.add(file); } else if (file.isDirectory() && !file.isHidden()) { @@ -296,7 +296,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { private File copyReleaseNotesToWorkingDirectory() throws MojoExecutionException { SharedFunctions.initDirectory(getLog(), distVersionRcVersionDirectory); getLog().info("Copying RELEASE-NOTES.txt to working directory."); - File copiedReleaseNotes = new File(distVersionRcVersionDirectory, releaseNotesFile.getName()); + final File copiedReleaseNotes = new File(distVersionRcVersionDirectory, releaseNotesFile.getName()); SharedFunctions.copyFile(getLog(), releaseNotesFile, copiedReleaseNotes); return copiedReleaseNotes; } @@ -332,18 +332,18 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { * {@link ScmFileSet}. * @throws MojoExecutionException if an {@link IOException} occurs so that Maven can handle it properly. */ - private List<File> copyDistributionsIntoScmDirectoryStructureAndAddToSvn(File copiedReleaseNotes, - ScmProvider provider, - ScmRepository repository) + private List<File> copyDistributionsIntoScmDirectoryStructureAndAddToSvn(final File copiedReleaseNotes, + final ScmProvider provider, + final ScmRepository repository) throws MojoExecutionException { - List<File> workingDirectoryFiles = Arrays.asList(workingDirectory.listFiles()); - List<File> filesForMavenScmFileSet = new ArrayList<>(); - File scmBinariesRoot = new File(distVersionRcVersionDirectory, "binaries"); - File scmSourceRoot = new File(distVersionRcVersionDirectory, "source"); + final List<File> workingDirectoryFiles = Arrays.asList(workingDirectory.listFiles()); + final List<File> filesForMavenScmFileSet = new ArrayList<>(); + final File scmBinariesRoot = new File(distVersionRcVersionDirectory, "binaries"); + final File scmSourceRoot = new File(distVersionRcVersionDirectory, "source"); SharedFunctions.initDirectory(getLog(), scmBinariesRoot); SharedFunctions.initDirectory(getLog(), scmSourceRoot); File copy; - for (File file : workingDirectoryFiles) { + for (final File file : workingDirectoryFiles) { if (file.getName().contains("src")) { copy = new File(scmSourceRoot, file.getName()); SharedFunctions.copyFile(getLog(), file, copy); @@ -380,10 +380,10 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { "\"mvn site\" was not run before this goal, or a siteDirectory did not exist." ); } - File siteInScm = new File(distVersionRcVersionDirectory, "site"); + final File siteInScm = new File(distVersionRcVersionDirectory, "site"); try { FileUtils.copyDirectory(siteDirectory, siteInScm); - } catch (IOException e) { + } catch (final IOException e) { throw new MojoExecutionException("Site copying failed", e); } return new ArrayList<>(FileUtils.listFiles(siteInScm, null, true)); @@ -408,14 +408,14 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { * files fails. */ private List<File> buildReadmeAndHeaderHtmlFiles() throws MojoExecutionException { - List<File> headerAndReadmeFiles = new ArrayList<>(); - File headerFile = new File(distVersionRcVersionDirectory, HEADER_FILE_NAME); + final List<File> headerAndReadmeFiles = new ArrayList<>(); + final File headerFile = new File(distVersionRcVersionDirectory, HEADER_FILE_NAME); // // HEADER file // try (Writer headerWriter = new OutputStreamWriter(new FileOutputStream(headerFile), "UTF-8")) { HeaderHtmlVelocityDelegate.builder().build().render(headerWriter); - } catch (IOException e) { + } catch (final IOException e) { final String message = "Could not build HEADER html file " + headerFile; getLog().error(message, e); throw new MojoExecutionException(message, e); @@ -424,17 +424,17 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { // // README file // - File readmeFile = new File(distVersionRcVersionDirectory, README_FILE_NAME); + final File readmeFile = new File(distVersionRcVersionDirectory, README_FILE_NAME); try (Writer readmeWriter = new OutputStreamWriter(new FileOutputStream(readmeFile), "UTF-8")) { // @formatter:off - ReadmeHtmlVelocityDelegate readmeHtmlVelocityDelegate = ReadmeHtmlVelocityDelegate.builder() + final ReadmeHtmlVelocityDelegate readmeHtmlVelocityDelegate = ReadmeHtmlVelocityDelegate.builder() .withArtifactId(project.getArtifactId()) .withVersion(project.getVersion()) .withSiteUrl(project.getUrl()) .build(); // @formatter:on readmeHtmlVelocityDelegate.render(readmeWriter); - } catch (IOException e) { + } catch (final IOException e) { final String message = "Could not build README html file " + readmeFile; getLog().error(message, e); throw new MojoExecutionException(message, e); @@ -454,15 +454,15 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { * @throws MojoExecutionException if the {@link SharedFunctions#copyFile(Log, File, File)} * fails. */ - private List<File> copyHeaderAndReadmeToSubdirectories(File headerFile, File readmeFile) + private List<File> copyHeaderAndReadmeToSubdirectories(final File headerFile, final File readmeFile) throws MojoExecutionException { - List<File> symbolicLinkFiles = new ArrayList<>(); - 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); - File binariesReadmeFile = new File(binariesRoot, README_FILE_NAME); + final List<File> symbolicLinkFiles = new ArrayList<>(); + final File sourceRoot = new File(distVersionRcVersionDirectory, "source"); + final File binariesRoot = new File(distVersionRcVersionDirectory, "binaries"); + final File sourceHeaderFile = new File(sourceRoot, HEADER_FILE_NAME); + final File sourceReadmeFile = new File(sourceRoot, README_FILE_NAME); + final File binariesHeaderFile = new File(binariesRoot, HEADER_FILE_NAME); + final File binariesReadmeFile = new File(binariesRoot, README_FILE_NAME); SharedFunctions.copyFile(getLog(), headerFile, sourceHeaderFile); symbolicLinkFiles.add(sourceHeaderFile); SharedFunctions.copyFile(getLog(), readmeFile, sourceReadmeFile); @@ -481,7 +481,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo { * @param baseDir is the {@link File} to be used as the project's root directory when this mojo * is invoked. */ - protected void setBaseDir(File baseDir) { + protected void setBaseDir(final File baseDir) { this.baseDir = baseDir; } } 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 2441200..4afc774 100755 --- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java +++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java @@ -120,7 +120,7 @@ public class CommonsSiteCompressionMojo extends AbstractMojo { filesToCompress = new ArrayList<>(); getAllSiteFiles(siteDirectory, filesToCompress); writeZipFile(workingDirectory, siteDirectory, filesToCompress); - } catch (IOException e) { + } catch (final 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(), @@ -136,9 +136,9 @@ public class CommonsSiteCompressionMojo extends AbstractMojo { * @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) { + private void getAllSiteFiles(final File siteDirectory, final List<File> filesToCompress) { + final File[] files = siteDirectory.listFiles(); + for (final File file : files) { filesToCompress.add(file); if (file.isDirectory()) { getAllSiteFiles(file, filesToCompress); @@ -157,10 +157,10 @@ public class CommonsSiteCompressionMojo extends AbstractMojo { * {@link CommonsSiteCompressionMojo#getAllSiteFiles(File, List)}. * @throws IOException when the copying of the files goes incorrectly. */ - private void writeZipFile(File outputDirectory, File directoryToZip, List<File> fileList) throws IOException { + private void writeZipFile(final File outputDirectory, final File directoryToZip, final List<File> fileList) throws IOException { try (FileOutputStream fos = new FileOutputStream(outputDirectory.getAbsolutePath() + "/site.zip"); ZipOutputStream zos = new ZipOutputStream(fos)) { - for (File file : fileList) { + for (final File file : fileList) { if (!file.isDirectory()) { // we only zip files, not directories addToZip(directoryToZip, file, zos); } @@ -178,13 +178,13 @@ public class CommonsSiteCompressionMojo extends AbstractMojo { * @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 { + private void addToZip(final File directoryToZip, final File file, final ZipOutputStream zos) throws IOException { try (FileInputStream fis = new FileInputStream(file)) { // we want the zipEntry's path to be a relative path that is relative // to the directory being zipped, so chop off the rest of the path - String zipFilePath = file.getCanonicalPath().substring(directoryToZip.getCanonicalPath().length() + 1, + final String zipFilePath = file.getCanonicalPath().substring(directoryToZip.getCanonicalPath().length() + 1, file.getCanonicalPath().length()); - ZipEntry zipEntry = new ZipEntry(zipFilePath); + final ZipEntry zipEntry = new ZipEntry(zipFilePath); zos.putNextEntry(zipEntry); IOUtils.copy(fis, zos); } diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojo.java index 65c4d32..3da1181 100644 --- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojo.java +++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojo.java @@ -147,11 +147,11 @@ public class CommonsStagingCleanupMojo extends AbstractMojo { SharedFunctions.initDirectory(getLog(), workingDirectory); } try { - ScmManager scmManager = new BasicScmManager(); + final ScmManager scmManager = new BasicScmManager(); scmManager.setScmProvider("svn", new SvnExeScmProvider()); - ScmRepository repository = scmManager.makeScmRepository(distSvnStagingUrl); - ScmProvider provider = scmManager.getProviderByRepository(repository); - SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository(); + final ScmRepository repository = scmManager.makeScmRepository(distSvnStagingUrl); + final ScmProvider provider = scmManager.getProviderByRepository(repository); + final SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository(); SharedFunctions.setAuthentication( providerRepository, distServer, @@ -161,27 +161,27 @@ public class CommonsStagingCleanupMojo extends AbstractMojo { password ); getLog().info("Checking out dist from: " + distSvnStagingUrl); - ScmFileSet scmFileSet = new ScmFileSet(distCleanupDirectory); + final ScmFileSet scmFileSet = new ScmFileSet(distCleanupDirectory); final CheckOutScmResult checkOutResult = provider.checkOut(repository, scmFileSet); if (!checkOutResult.isSuccess()) { throw new MojoExecutionException("Failed to checkout files from SCM: " + checkOutResult.getProviderMessage() + " [" + checkOutResult.getCommandOutput() + "]"); } - List<File> filesToRemove = Arrays.asList(distCleanupDirectory.listFiles()); + final List<File> filesToRemove = Arrays.asList(distCleanupDirectory.listFiles()); if (filesToRemove.size() == 1) { getLog().info("No files to delete"); return; } if (!dryRun) { - ScmFileSet fileSet = new ScmFileSet(distCleanupDirectory, filesToRemove); - RemoveScmResult removeScmResult = provider.remove(repository, fileSet, "Cleaning up staging area"); + final ScmFileSet fileSet = new ScmFileSet(distCleanupDirectory, filesToRemove); + final RemoveScmResult removeScmResult = provider.remove(repository, fileSet, "Cleaning up staging area"); if (!removeScmResult.isSuccess()) { throw new MojoFailureException("Failed to remove files from SCM: " + removeScmResult.getProviderMessage() + " [" + removeScmResult.getCommandOutput() + "]"); } getLog().info("Cleaning distribution area for: " + project.getArtifactId()); - CheckInScmResult checkInResult = provider.checkIn( + final CheckInScmResult checkInResult = provider.checkIn( repository, fileSet, "Cleaning distribution area for: " + project.getArtifactId() @@ -193,7 +193,7 @@ public class CommonsStagingCleanupMojo extends AbstractMojo { } else { getLog().info("Would have attempted to delete files from: " + distSvnStagingUrl); } - } catch (ScmException e) { + } catch (final ScmException e) { throw new MojoFailureException(e.getMessage()); } diff --git a/src/main/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegate.java b/src/main/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegate.java index 3852451..638bd65 100755 --- a/src/main/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegate.java +++ b/src/main/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegate.java @@ -54,13 +54,13 @@ public class HeaderHtmlVelocityDelegate { * @param writer any {@link Writer} that we wish to have the filled velocity template written to. * @return the {@link Writer} that we've filled out the template into. */ - public Writer render(Writer writer) { - VelocityEngine ve = new VelocityEngine(); + public Writer render(final Writer writer) { + final VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); ve.init(); - Template template = ve.getTemplate(TEMPLATE); - VelocityContext context = new VelocityContext(); + final Template template = ve.getTemplate(TEMPLATE); + final VelocityContext context = new VelocityContext(); template.merge(context, writer); return writer; } diff --git a/src/main/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegate.java b/src/main/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegate.java index 9141a49..39032dc 100755 --- a/src/main/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegate.java +++ b/src/main/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegate.java @@ -49,7 +49,7 @@ public class ReadmeHtmlVelocityDelegate { * @param version sets the {@link ReadmeHtmlVelocityDelegate#version}. * @param siteUrl sets the {@link ReadmeHtmlVelocityDelegate#siteUrl}. */ - private ReadmeHtmlVelocityDelegate(String artifactId, String version, String siteUrl) { + private ReadmeHtmlVelocityDelegate(final String artifactId, final String version, final String siteUrl) { this.artifactId = artifactId; this.version = version; this.siteUrl = siteUrl; @@ -71,14 +71,14 @@ public class ReadmeHtmlVelocityDelegate { * @param writer is the {@link Writer} to which we wish to render the <code>README.vm</code> template. * @return a reference to the {@link Writer} passed in. */ - public Writer render(Writer writer) { - VelocityEngine ve = new VelocityEngine(); + public Writer render(final Writer writer) { + final VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); ve.init(); - Template template = ve.getTemplate(TEMPLATE); - String[] splitArtifactId = artifactId.split("-"); - String wordCommons = "commons"; + final Template template = ve.getTemplate(TEMPLATE); + final String[] splitArtifactId = artifactId.split("-"); + final String wordCommons = "commons"; String artifactShortName = ""; if (splitArtifactId.length > 1) { artifactShortName = splitArtifactId[1]; @@ -89,11 +89,11 @@ public class ReadmeHtmlVelocityDelegate { if (artifactShortName.matches(".+\\d$")) { artifactShortName = artifactShortName.substring(0, artifactShortName.length() - 1); } - String artifactIdWithFirstLetterscapitalized = + final String artifactIdWithFirstLetterscapitalized = StringUtils.capitalize(wordCommons) + "-" + artifactShortName.toUpperCase(); - VelocityContext context = new VelocityContext(); + final VelocityContext context = new VelocityContext(); context.internalPut("artifactIdWithFirstLetterscapitalized", artifactIdWithFirstLetterscapitalized); context.internalPut("artifactShortName", artifactShortName.toUpperCase()); context.internalPut("artifactId", artifactId); @@ -127,7 +127,7 @@ public class ReadmeHtmlVelocityDelegate { * @param artifactId the {@link String} representing the maven artifactId. * @return the builder to continue building. */ - public ReadmeHtmlVelocityDelegateBuilder withArtifactId(String artifactId) { + public ReadmeHtmlVelocityDelegateBuilder withArtifactId(final String artifactId) { this.artifactId = artifactId; return this; } @@ -137,7 +137,7 @@ public class ReadmeHtmlVelocityDelegate { * @param version the maven version. * @return the builder to continue building. */ - public ReadmeHtmlVelocityDelegateBuilder withVersion(String version) { + public ReadmeHtmlVelocityDelegateBuilder withVersion(final String version) { this.version = version; return this; } @@ -147,7 +147,7 @@ public class ReadmeHtmlVelocityDelegate { * @param siteUrl the site url to be used in the <code>README.html</code> * @return the builder to continue building. */ - public ReadmeHtmlVelocityDelegateBuilder withSiteUrl(String siteUrl) { + public ReadmeHtmlVelocityDelegateBuilder withSiteUrl(final String siteUrl) { this.siteUrl = siteUrl; return this; } diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java index c49caa7..22c0517 100755 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java @@ -52,7 +52,7 @@ public class CommonsDistributionDetachmentMojoTest { @Before public void setUp() throws Exception { - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); if (testingDirectory.exists()) { FileUtils.deleteDirectory(testingDirectory); } @@ -60,25 +60,25 @@ public class CommonsDistributionDetachmentMojoTest { @Test public void testSuccess() throws Exception { - File testPom = new File("src/test/resources/mojos/detach-distributions/detach-distributions.xml"); + final File testPom = new File("src/test/resources/mojos/detach-distributions/detach-distributions.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); mojo = (CommonsDistributionDetachmentMojo) rule.lookupMojo("detach-distributions", testPom); mojo.execute(); - File detachedSrcTarGz = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz"); - File detachedSrcTarGzAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.asc"); - File detachedSrcTarGzSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.sha512"); - File detachedSrcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip"); - File detachedSrcZipAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.asc"); - File detachedSrcZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.sha512"); - File detachedBinTarGz = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz"); - File detachedBinTarGzAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.asc"); - File detachedBinTarGzSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.sha512"); - File detachedBinZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip"); - File detachedBinZipAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.asc"); - File detachedBinZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.sha512"); - File notDetachedMockAttachedFile = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4.jar"); - File sha512Properties = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/sha512.properties"); + final File detachedSrcTarGz = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz"); + final File detachedSrcTarGzAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.asc"); + final File detachedSrcTarGzSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.sha512"); + final File detachedSrcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip"); + final File detachedSrcZipAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.asc"); + final File detachedSrcZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.sha512"); + final File detachedBinTarGz = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz"); + final File detachedBinTarGzAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.asc"); + final File detachedBinTarGzSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.sha512"); + final File detachedBinZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip"); + final File detachedBinZipAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.asc"); + final File detachedBinZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.sha512"); + final File notDetachedMockAttachedFile = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4.jar"); + final File sha512Properties = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/sha512.properties"); assertTrue(detachedSrcTarGz.exists()); assertTrue(detachedSrcTarGzAsc.exists()); assertTrue(detachedSrcTarGzSha512.exists()); @@ -97,12 +97,12 @@ public class CommonsDistributionDetachmentMojoTest { @Test public void testDisabled() throws Exception { - File testPom = new File("src/test/resources/mojos/detach-distributions/detach-distributions-disabled.xml"); + final File testPom = new File("src/test/resources/mojos/detach-distributions/detach-distributions-disabled.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); mojo = (CommonsDistributionDetachmentMojo) rule.lookupMojo("detach-distributions", testPom); mojo.execute(); - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); assertFalse(testingDirectory.exists()); } } 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 1bca8c5..5ace108 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 @@ -55,7 +55,7 @@ public class CommonsDistributionStagingMojoTest { @Before public void setUp() throws Exception { - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); if (testingDirectory.exists()) { FileUtils.deleteDirectory(testingDirectory); } @@ -63,16 +63,16 @@ public class CommonsDistributionStagingMojoTest { @Test public void testSuccess() throws Exception { - File testPom = new File("src/test/resources/mojos/stage-distributions/stage-distributions.xml"); + final File testPom = new File("src/test/resources/mojos/stage-distributions/stage-distributions.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); - File detachmentPom = new File("src/test/resources/mojos/detach-distributions/detach-distributions.xml"); + final File detachmentPom = new File("src/test/resources/mojos/detach-distributions/detach-distributions.xml"); assertNotNull(detachmentPom); assertTrue(detachmentPom.exists()); mojoForTest = (CommonsDistributionStagingMojo) rule.lookupMojo("stage-distributions", testPom); detachmentMojo = (CommonsDistributionDetachmentMojo) rule.lookupMojo("detach-distributions", detachmentPom); detachmentMojo.execute(); - File releaseNotesBasedir = new File("src/test/resources/mojos/stage-distributions/"); + final File releaseNotesBasedir = new File("src/test/resources/mojos/stage-distributions/"); mojoForTest.setBaseDir(releaseNotesBasedir); mojoForTest.execute(); assertRequisiteFilesExist(); @@ -80,40 +80,40 @@ public class CommonsDistributionStagingMojoTest { @Test public void testDisabled() throws Exception { - File testPom = new File("src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml"); + final 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); + final 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/commons-text-1.4-bin.tar.gz"); - File binTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.asc"); - File binTarSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.sha512"); - File binZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip"); - File binZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.asc"); - File binZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.sha512"); - 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/commons-text-1.4-src.tar.gz"); - File srcTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.asc"); - File srcTarSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.sha512"); - File srcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip"); - File srcZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.asc"); - File srcZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.sha512"); - 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"); + final File targetScmDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1"); + final File releaseNotes = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/RELEASE-NOTES.txt"); + final File readmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/README.html"); + final File headerHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/HEADER.html"); + final File binariesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/README.html"); + final File binariesHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/HEADER.html"); + final File binTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz"); + final File binTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.asc"); + final File binTarSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.sha512"); + final File binZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip"); + final File binZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.asc"); + final File binZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.sha512"); + final File sourcesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/README.html"); + final File sourceHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/HEADER.html"); + final File srcTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz"); + final File srcTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.asc"); + final File srcTarSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.sha512"); + final File srcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip"); + final File srcZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.asc"); + final File srcZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.sha512"); + final File site = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site"); + final File siteIndexHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site/index.html"); + final File siteSubdirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site/subdirectory"); + final 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()); diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java index f69533a..3fed59a 100755 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java @@ -55,7 +55,7 @@ public class CommonsSiteCompressionMojoTest { @Before public void setUp() throws Exception { - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); if (testingDirectory.exists()) { FileUtils.deleteDirectory(testingDirectory); } @@ -63,26 +63,26 @@ public class CommonsSiteCompressionMojoTest { @Test public void testCompressSiteSuccess() throws Exception { - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); testingDirectory.mkdir(); - File testPom = new File("src/test/resources/mojos/compress-site/compress-site.xml"); + final File testPom = new File("src/test/resources/mojos/compress-site/compress-site.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testPom); mojo.execute(); - File siteZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/site.zip"); + final File siteZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/site.zip"); assertTrue(siteZip.exists()); } @Test public void testCompressSiteDirNonExistentFailure() throws Exception { - File testPom = new File("src/test/resources/mojos/compress-site/compress-site-failure.xml"); + final File testPom = new File("src/test/resources/mojos/compress-site/compress-site-failure.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testPom); try { mojo.execute(); - } catch (MojoFailureException e) { + } catch (final MojoFailureException e) { assertEquals( "\"mvn site\" was not run before this goal, or a siteDirectory did not exist.", e.getMessage() ); @@ -91,12 +91,12 @@ public class CommonsSiteCompressionMojoTest { @Test public void testDisabled() throws Exception { - File testPom = new File("src/test/resources/mojos/compress-site/compress-site-disabled.xml"); + final File testPom = new File("src/test/resources/mojos/compress-site/compress-site-disabled.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testPom); mojo.execute(); - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); assertFalse(testingDirectory.exists()); } } diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojoTest.java index 89f982e..1bcfb9e 100755 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsStagingCleanupMojoTest.java @@ -52,7 +52,7 @@ public class CommonsStagingCleanupMojoTest { @Before public void setUp() throws Exception { - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); if (testingDirectory.exists()) { FileUtils.deleteDirectory(testingDirectory); } @@ -60,14 +60,14 @@ public class CommonsStagingCleanupMojoTest { @Test public void testCompressSiteSuccess() throws Exception { - File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); + final File testingDirectory = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH); testingDirectory.mkdir(); - File testPom = new File("src/test/resources/mojos/staging-cleanup/staging-cleanup.xml"); + final File testPom = new File("src/test/resources/mojos/staging-cleanup/staging-cleanup.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); mojo = (CommonsStagingCleanupMojo) rule.lookupMojo("clean-staging", testPom); mojo.execute(); - File cleanupDir = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm-cleanup"); + final File cleanupDir = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm-cleanup"); assertTrue(cleanupDir.exists()); } } diff --git a/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetachmentProjectStub.java b/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetachmentProjectStub.java index d392915..26baec0 100755 --- a/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetachmentProjectStub.java +++ b/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetachmentProjectStub.java @@ -215,8 +215,8 @@ public class DistributionDetachmentProjectStub extends MavenProjectStub { private final String type; - public DistributionDetachmentArtifactStub(File file, String type, - String artifactId, String classifier, String version) { + public DistributionDetachmentArtifactStub(final File file, final String type, + final String artifactId, final String classifier, final String version) { this.setArtifactId(artifactId); this.artifact = file; this.type = type; diff --git a/src/test/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegateTest.java b/src/test/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegateTest.java index b49fd5f..0158311 100755 --- a/src/test/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegateTest.java +++ b/src/test/java/org/apache/commons/release/plugin/velocity/HeaderHtmlVelocityDelegateTest.java @@ -29,7 +29,7 @@ public class HeaderHtmlVelocityDelegateTest { @Test public void testSuccess() { - HeaderHtmlVelocityDelegate subject = HeaderHtmlVelocityDelegate.builder().build(); + final HeaderHtmlVelocityDelegate subject = HeaderHtmlVelocityDelegate.builder().build(); Writer writer = new StringWriter(); writer = subject.render(writer); assertTrue(writer.toString().contains("<h2>Apache Commons Project Distributions</h2>")); diff --git a/src/test/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegateTest.java b/src/test/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegateTest.java index 0d78f37..6e5fd8a 100755 --- a/src/test/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegateTest.java +++ b/src/test/java/org/apache/commons/release/plugin/velocity/ReadmeHtmlVelocityDelegateTest.java @@ -32,27 +32,27 @@ public class ReadmeHtmlVelocityDelegateTest { @Test public void testSuccessfulRun() { - ReadmeHtmlVelocityDelegate delegate = ReadmeHtmlVelocityDelegate.builder() + final ReadmeHtmlVelocityDelegate delegate = ReadmeHtmlVelocityDelegate.builder() .withArtifactId("commons-text") .withVersion("1.4") .withSiteUrl("http://commons.apache.org/text") .build(); Writer writer = new StringWriter(); writer = delegate.render(writer); - String filledOutTemplate = writer.toString(); + final String filledOutTemplate = writer.toString(); assertTrue(filledOutTemplate.contains("<h1>Commons-TEXT v1.4.</h1>")); } @Test public void testSuccessfulRunLang3() { - ReadmeHtmlVelocityDelegate delegate = ReadmeHtmlVelocityDelegate.builder() + final ReadmeHtmlVelocityDelegate delegate = ReadmeHtmlVelocityDelegate.builder() .withArtifactId("commons-lang3") .withVersion("3.8.1") .withSiteUrl("http://commons.apache.org/text") .build(); Writer writer = new StringWriter(); writer = delegate.render(writer); - String filledOutTemplate = writer.toString(); + final String filledOutTemplate = writer.toString(); assertTrue(filledOutTemplate.contains("<h1>Commons-LANG v3.8.1.</h1>")); } @@ -60,14 +60,14 @@ public class ReadmeHtmlVelocityDelegateTest { @Test public void testSuccessfulRunBcel() { - ReadmeHtmlVelocityDelegate delegate = ReadmeHtmlVelocityDelegate.builder() + final ReadmeHtmlVelocityDelegate delegate = ReadmeHtmlVelocityDelegate.builder() .withArtifactId("bcel") .withVersion("1.5") .withSiteUrl("http://commons.apache.org/text") .build(); Writer writer = new StringWriter(); writer = delegate.render(writer); - String filledOutTemplate = writer.toString(); + final String filledOutTemplate = writer.toString(); assertTrue(filledOutTemplate.contains("<h1>Commons-BCEL v1.5.</h1>")); } }