You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2023/03/04 16:13:42 UTC
[maven-scm-publish-plugin] branch MSCMPUB-53 created (now 91cc55e)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch MSCMPUB-53
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
at 91cc55e [MSCMPUB-53] Require Java 8
This branch includes the following new commits:
new 91cc55e [MSCMPUB-53] Require Java 8
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-scm-publish-plugin] 01/01: [MSCMPUB-53] Require Java 8
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MSCMPUB-53
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
commit 91cc55e05eb7990f9123c0598a4c51be11ba15df
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Mar 4 17:13:33 2023 +0100
[MSCMPUB-53] Require Java 8
---
pom.xml | 2 +-
.../plugins/scmpublish/AbstractScmPublishMojo.java | 32 ++++++----------------
.../scmpublish/ScmPublishPublishScmMojo.java | 22 +++++++--------
3 files changed, 21 insertions(+), 35 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2dfd403..c18375f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@ under the License.
<properties>
<scmVersion>1.11.2</scmVersion>
<mavenVersion>3.0</mavenVersion>
- <javaVersion>7</javaVersion>
+ <javaVersion>8</javaVersion>
<!-- for documentation purpose -->
<maven-scm-provider-svnjava-version>2.0.6</maven-scm-provider-svnjava-version>
diff --git a/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java b/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
index 06a890c..e9822a0 100644
--- a/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
+++ b/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
@@ -299,7 +299,7 @@ public abstract class AbstractScmPublishMojo
{
if ( normalizeExtensions == null )
{
- normalizeExtensions = new HashSet<String>( Arrays.asList( NORMALIZE_EXTENSIONS ) );
+ normalizeExtensions = new HashSet<>( Arrays.asList( NORMALIZE_EXTENSIONS ) );
if ( extraNormalizeExtensions != null )
{
normalizeExtensions.addAll( Arrays.asList( extraNormalizeExtensions ) );
@@ -471,13 +471,7 @@ public abstract class AbstractScmPublishMojo
}
checkScmResult( scmResult, "check out from SCM" );
}
- catch ( ScmException e )
- {
- logError( e.getMessage() );
-
- throw new MojoExecutionException( "An error occurred during the checkout process: " + e.getMessage(), e );
- }
- catch ( IOException e )
+ catch ( ScmException | IOException e )
{
logError( e.getMessage() );
@@ -538,11 +532,7 @@ public abstract class AbstractScmPublishMojo
FileUtils.deleteDirectory( checkoutDirectory );
}
}
- catch ( IOException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- catch ( ScmException e )
+ catch ( IOException | ScmException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
@@ -576,11 +566,7 @@ public abstract class AbstractScmPublishMojo
{
setupScm();
}
- catch ( ScmRepositoryException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- catch ( NoSuchScmProviderException e )
+ catch ( ScmRepositoryException | NoSuchScmProviderException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
@@ -653,7 +639,7 @@ public abstract class AbstractScmPublishMojo
logInfo( "Deleting files is skipped." );
return;
}
- List<File> deletedList = new ArrayList<File>();
+ List<File> deletedList = new ArrayList<>();
for ( File f : deleted )
{
deletedList.add( relativize( checkoutDirectory, f ) );
@@ -682,9 +668,9 @@ public abstract class AbstractScmPublishMojo
protected void addFiles( Collection<File> added )
throws MojoFailureException, MojoExecutionException
{
- List<File> addedList = new ArrayList<File>();
- Set<File> createdDirs = new HashSet<File>();
- Set<File> dirsToAdd = new TreeSet<File>();
+ List<File> addedList = new ArrayList<>();
+ Set<File> createdDirs = new HashSet<>();
+ Set<File> dirsToAdd = new TreeSet<>();
createdDirs.add( relativize( checkoutDirectory, checkoutDirectory ) );
@@ -731,7 +717,7 @@ public abstract class AbstractScmPublishMojo
{ // add all directories in one command
try
{
- List<File> dirs = new ArrayList<File>( dirsToAdd );
+ List<File> dirs = new ArrayList<>( dirsToAdd );
ScmFileSet fileSet = new ScmFileSet( checkoutDirectory, dirs );
getLog().info( "scm add directories: " + dirs );
AddScmResult addDirResult = scmProvider.add( scmRepository, fileSet, "Adding directories" );
diff --git a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
index c79ef0d..265d65a 100644
--- a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
+++ b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
@@ -21,8 +21,6 @@ package org.apache.maven.plugins.scmpublish;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
@@ -70,11 +68,11 @@ public class ScmPublishPublishScmMojo
@Parameter( defaultValue = "${project}", readonly = true, required = true )
protected MavenProject project;
- private List<File> deleted = new ArrayList<File>();
+ private List<File> deleted = new ArrayList<>();
- private List<File> added = new ArrayList<File>();
+ private List<File> added = new ArrayList<>();
- private List<File> updated = new ArrayList<File>();
+ private List<File> updated = new ArrayList<>();
private int directories = 0;
private int files = 0;
@@ -97,14 +95,14 @@ public class ScmPublishPublishScmMojo
? checkout.list( new NotFileFilter( new NameFileFilter( scmSpecificFilename ) ) )
: checkout.list();
- Set<String> checkoutContent = new HashSet<String>( Arrays.asList( files ) );
- List<String> dirContent = ( dir != null ) ? Arrays.asList( dir.list() ) : Collections.<String>emptyList();
+ Set<String> checkoutContent = new HashSet<>( Arrays.asList( files ) ) ;
+ List<String> dirContent = ( dir != null ) ? Arrays.asList( dir.list() ) : Collections.emptyList();
- Set<String> deleted = new HashSet<String>( checkoutContent );
+ Set<String> deleted = new HashSet<>( checkoutContent );
deleted.removeAll( dirContent );
MatchPatterns ignoreDeleteMatchPatterns = null;
- List<String> pathsAsList = new ArrayList<String>( 0 );
+ List<String> pathsAsList = new ArrayList<>( 0 );
if ( ignorePathsToDelete != null && ignorePathsToDelete.length > 0 )
{
ignoreDeleteMatchPatterns = MatchPatterns.from( ignorePathsToDelete );
@@ -228,8 +226,10 @@ public class ScmPublishPublishScmMojo
PrintWriter out = null;
try
{
- in = new BufferedReader( new InputStreamReader( new FileInputStream( srcFile ), siteOutputEncoding ) );
- out = new PrintWriter( new OutputStreamWriter( new FileOutputStream( destFile ), siteOutputEncoding ) );
+ in = new BufferedReader( new InputStreamReader( Files.newInputStream( srcFile.toPath() ),
+ siteOutputEncoding ) );
+ out = new PrintWriter( new OutputStreamWriter( Files.newOutputStream( destFile.toPath() ),
+ siteOutputEncoding ) );
for ( String line = in.readLine(); line != null; line = in.readLine() )
{