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:59:07 UTC
[maven-scm-publish-plugin] branch master updated (0873657 -> c8b0849)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
from 0873657 [MSCMPUB-54] Require Maven 3.2.5+
new b96e65d [MSCMPUB-57] Upgrade parent pom to 39
new ef21a97 [MSCMPUB-57] Reformat
new c8b0849 [MSCMPUB-57] Upgrade misc deps maven-shared-utils to 3.3.4 commons-land to 3.12.0 maven-release-manager to 3.0.0-M7 org.apache.maven.scm:* to 2.0.0-M3
The 3 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.
Summary of changes:
pom.xml | 44 +-
.../plugins/scmpublish/AbstractScmPublishMojo.java | 568 +++++++++------------
.../scmpublish/ScmPublishPublishScmMojo.java | 279 +++++-----
3 files changed, 379 insertions(+), 512 deletions(-)
[maven-scm-publish-plugin] 02/03: [MSCMPUB-57] Reformat
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
commit ef21a970c9cdd66ef8107ad95b886a3d322018a1
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Mar 4 17:19:18 2023 +0100
[MSCMPUB-57] Reformat
---
pom.xml | 12 +-
.../plugins/scmpublish/AbstractScmPublishMojo.java | 564 +++++++++------------
.../scmpublish/ScmPublishPublishScmMojo.java | 279 +++++-----
3 files changed, 349 insertions(+), 506 deletions(-)
diff --git a/pom.xml b/pom.xml
index e3b620a..5c2fcb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,7 +17,6 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -41,11 +39,15 @@ under the License.
</contributor>
</contributors>
+ <prerequisites>
+ <maven>${mavenVersion}</maven>
+ </prerequisites>
+
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git</developerConnection>
- <url>https://github.com/apache/maven-scm-publish-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-scm-publish-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>JIRA</system>
@@ -72,10 +74,6 @@ under the License.
<svnkit-version>1.7.11</svnkit-version>
<project.build.outputTimestamp>2020-12-23T07:12:37Z</project.build.outputTimestamp>
</properties>
-
- <prerequisites>
- <maven>${mavenVersion}</maven>
- </prerequisites>
<dependencies>
<dependency>
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 e9822a0..d4689f9 100644
--- a/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
+++ b/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.scmpublish;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.scmpublish;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.scmpublish;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.scmpublish;
import java.io.File;
import java.io.IOException;
@@ -68,9 +67,7 @@ import org.apache.maven.shared.utils.logging.MessageUtils;
/**
* Base class for the scm-publish mojos.
*/
-public abstract class AbstractScmPublishMojo
- extends AbstractMojo
-{
+public abstract class AbstractScmPublishMojo extends AbstractMojo {
// CHECKSTYLE_OFF: LineLength
/**
* Location of the scm publication tree:
@@ -79,19 +76,21 @@ public abstract class AbstractScmPublishMojo
* <code>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin-LATEST/</code>
*/
// CHECKSTYLE_ON: LineLength
- @Parameter ( property = "scmpublish.pubScmUrl", defaultValue = "${project.distributionManagement.site.url}",
- required = true )
+ @Parameter(
+ property = "scmpublish.pubScmUrl",
+ defaultValue = "${project.distributionManagement.site.url}",
+ required = true)
protected String pubScmUrl;
/**
* If the checkout directory exists and this flag is activated, the plugin will try an SCM-update instead
* of delete then checkout.
*/
- @Parameter ( property = "scmpublish.tryUpdate", defaultValue = "false" )
+ @Parameter(property = "scmpublish.tryUpdate", defaultValue = "false")
protected boolean tryUpdate;
// CHECKSTYLE_OFF: LineLength
- /**
+ /**
* Location where the scm check-out is done. By default, scm checkout is done in build (target) directory,
* which is deleted on every <code>mvn clean</code>. To avoid this and get better performance, configure
* this location outside build structure and set <code>tryUpdate</code> to <code>true</code>.
@@ -99,21 +98,22 @@ public abstract class AbstractScmPublishMojo
* Improving SCM Checkout Performance</a> for more information.
*/
// CHECKSTYLE_ON: LineLength
- @Parameter ( property = "scmpublish.checkoutDirectory",
- defaultValue = "${project.build.directory}/scmpublish-checkout" )
+ @Parameter(
+ property = "scmpublish.checkoutDirectory",
+ defaultValue = "${project.build.directory}/scmpublish-checkout")
protected File checkoutDirectory;
/**
* Location where the content is published inside the <code>${checkoutDirectory}</code>.
* By default, content is copyed at the root of <code>${checkoutDirectory}</code>.
*/
- @Parameter ( property = "scmpublish.subDirectory" )
+ @Parameter(property = "scmpublish.subDirectory")
protected String subDirectory;
/**
* Display list of added, deleted, and changed files, but do not do any actual SCM operations.
*/
- @Parameter ( property = "scmpublish.dryRun" )
+ @Parameter(property = "scmpublish.dryRun")
private boolean dryRun;
/**
@@ -122,25 +122,25 @@ public abstract class AbstractScmPublishMojo
* @deprecated Please use {@link #skipDeployment}.
*/
@Deprecated
- @Parameter ( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
private boolean skipDeployement;
/**
* Set this to 'true' to skip site deployment.
*/
- @Parameter ( property = "scmpublish.skipDeploy", alias = "maven.site.deploy.skip", defaultValue = "false" )
+ @Parameter(property = "scmpublish.skipDeploy", alias = "maven.site.deploy.skip", defaultValue = "false")
private boolean skipDeployment;
/**
* Run add and delete commands, but leave the actually checkin for the user to run manually.
*/
- @Parameter ( property = "scmpublish.skipCheckin" )
+ @Parameter(property = "scmpublish.skipCheckin")
private boolean skipCheckin;
/**
* SCM log/checkin comment for this publication.
*/
- @Parameter ( property = "scmpublish.checkinComment", defaultValue = "Site checkin for project ${project.name}" )
+ @Parameter(property = "scmpublish.checkinComment", defaultValue = "Site checkin for project ${project.name}")
private String checkinComment;
/**
@@ -186,13 +186,13 @@ public abstract class AbstractScmPublishMojo
/**
* The SCM username to use.
*/
- @Parameter ( property = "username" )
+ @Parameter(property = "username")
protected String username;
/**
* The SCM password to use.
*/
- @Parameter ( property = "password" )
+ @Parameter(property = "password")
protected String password;
/**
@@ -200,43 +200,42 @@ public abstract class AbstractScmPublishMojo
* <b>WARNING</b>: This will only work with distributed SCMs which support the file:// protocol.
* TODO: we should think about having the defaults for the various SCM providers provided via Modello!
*/
- @Parameter ( property = "localCheckout", defaultValue = "false" )
+ @Parameter(property = "localCheckout", defaultValue = "false")
protected boolean localCheckout;
/**
* The outputEncoding parameter of the site plugin. This plugin will corrupt your site
* if this does not match the value used by the site plugin.
*/
- @Parameter ( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" )
+ @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}")
protected String siteOutputEncoding;
/**
* Do not delete files to the scm
*/
- @Parameter ( property = "scmpublish.skipDeletedFiles", defaultValue = "false" )
+ @Parameter(property = "scmpublish.skipDeletedFiles", defaultValue = "false")
protected boolean skipDeletedFiles;
/**
* Add each directory in a separated SCM command: this can be necessary if SCM does not support
* adding subdirectories in one command.
*/
- @Parameter( defaultValue = "false" )
+ @Parameter(defaultValue = "false")
protected boolean addUniqueDirectory;
/**
*/
- @Parameter ( defaultValue = "${basedir}", readonly = true )
+ @Parameter(defaultValue = "${basedir}", readonly = true)
protected File basedir;
/**
*/
- @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+ @Parameter(defaultValue = "${settings}", readonly = true, required = true)
protected Settings settings;
@Component
private SettingsDecrypter settingsDecrypter;
-
/**
* Collections of paths not to delete when checking content to delete.
* If your site has subdirectories published by an other mechanism/build
@@ -247,19 +246,19 @@ public abstract class AbstractScmPublishMojo
/**
* SCM branch to use. For github, you must configure with <code>gh-pages</code>.
*/
- @Parameter ( property = "scmpublish.scm.branch" )
+ @Parameter(property = "scmpublish.scm.branch")
protected String scmBranch;
/**
* Configure svn automatic remote url creation.
*/
- @Parameter ( property = "scmpublish.automaticRemotePathCreation", defaultValue = "true" )
+ @Parameter(property = "scmpublish.automaticRemotePathCreation", defaultValue = "true")
protected boolean automaticRemotePathCreation;
/**
* Filename extensions of files which need new line normalization.
*/
- private static final String[] NORMALIZE_EXTENSIONS = { "html", "css", "js" };
+ private static final String[] NORMALIZE_EXTENSIONS = {"html", "css", "js"};
/**
* Extra file extensions to normalize line ending (will be added to default
@@ -274,52 +273,41 @@ public abstract class AbstractScmPublishMojo
protected ScmRepository scmRepository;
- protected void logInfo( String format, Object... params )
- {
- getLog().info( String.format( format, params ) );
+ protected void logInfo(String format, Object... params) {
+ getLog().info(String.format(format, params));
}
- protected void logWarn( String format, Object... params )
- {
- getLog().warn( String.format( format, params ) );
+ protected void logWarn(String format, Object... params) {
+ getLog().warn(String.format(format, params));
}
- protected void logError( String format, Object... params )
- {
- getLog().error( String.format( format, params ) );
+ protected void logError(String format, Object... params) {
+ getLog().error(String.format(format, params));
}
- private File relativize( File base, File file )
- {
- return new File( base.toURI().relativize( file.toURI() ).getPath() );
+ private File relativize(File base, File file) {
+ return new File(base.toURI().relativize(file.toURI()).getPath());
}
- protected boolean requireNormalizeNewlines( File f )
- throws IOException
- {
- if ( normalizeExtensions == null )
- {
- normalizeExtensions = new HashSet<>( Arrays.asList( NORMALIZE_EXTENSIONS ) );
- if ( extraNormalizeExtensions != null )
- {
- normalizeExtensions.addAll( Arrays.asList( extraNormalizeExtensions ) );
+ protected boolean requireNormalizeNewlines(File f) throws IOException {
+ if (normalizeExtensions == null) {
+ normalizeExtensions = new HashSet<>(Arrays.asList(NORMALIZE_EXTENSIONS));
+ if (extraNormalizeExtensions != null) {
+ normalizeExtensions.addAll(Arrays.asList(extraNormalizeExtensions));
}
}
- return FilenameUtils.isExtension( f.getName(), normalizeExtensions );
+ return FilenameUtils.isExtension(f.getName(), normalizeExtensions);
}
- private ReleaseDescriptor setupScm()
- throws ScmRepositoryException, NoSuchScmProviderException
- {
+ private ReleaseDescriptor setupScm() throws ScmRepositoryException, NoSuchScmProviderException {
String scmUrl;
- if ( localCheckout )
- {
+ if (localCheckout) {
// in the release phase we have to change the checkout URL
// to do a local checkout instead of going over the network.
- String provider = ScmUrlUtils.getProvider( pubScmUrl );
- String delimiter = ScmUrlUtils.getDelimiter( pubScmUrl );
+ String provider = ScmUrlUtils.getProvider(pubScmUrl);
+ String delimiter = ScmUrlUtils.getDelimiter(pubScmUrl);
String providerPart = "scm:" + provider + delimiter;
@@ -327,34 +315,28 @@ public abstract class AbstractScmPublishMojo
// X TODO: in case our toplevel git directory has no pom.
// X TODO: fix pathname once I understand this.
scmUrl = providerPart + "file://" + "target/localCheckout";
- logInfo( "Performing a LOCAL checkout from " + scmUrl );
+ logInfo("Performing a LOCAL checkout from " + scmUrl);
}
ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
- releaseDescriptor.setInteractive( settings.isInteractiveMode() );
+ releaseDescriptor.setInteractive(settings.isInteractiveMode());
- if ( username == null || password == null )
- {
- for ( Server server : settings.getServers() )
- {
- if ( server.getId().equals( serverId ) )
- {
- SettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest( server );
+ if (username == null || password == null) {
+ for (Server server : settings.getServers()) {
+ if (server.getId().equals(serverId)) {
+ SettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
- SettingsDecryptionResult decryptionResult = settingsDecrypter.decrypt( decryptionRequest );
+ SettingsDecryptionResult decryptionResult = settingsDecrypter.decrypt(decryptionRequest);
- if ( !decryptionResult.getProblems().isEmpty() )
- {
+ if (!decryptionResult.getProblems().isEmpty()) {
// todo throw exception?
}
- if ( username == null )
- {
+ if (username == null) {
username = decryptionResult.getServer().getUsername();
}
- if ( password == null )
- {
+ if (password == null) {
password = decryptionResult.getServer().getPassword();
}
@@ -363,238 +345,185 @@ public abstract class AbstractScmPublishMojo
}
}
- releaseDescriptor.setScmPassword( password );
- releaseDescriptor.setScmUsername( username );
+ releaseDescriptor.setScmPassword(password);
+ releaseDescriptor.setScmUsername(username);
- releaseDescriptor.setWorkingDirectory( basedir.getAbsolutePath() );
- releaseDescriptor.setLocalCheckout( localCheckout );
- releaseDescriptor.setScmSourceUrl( pubScmUrl );
+ releaseDescriptor.setWorkingDirectory(basedir.getAbsolutePath());
+ releaseDescriptor.setLocalCheckout(localCheckout);
+ releaseDescriptor.setScmSourceUrl(pubScmUrl);
- if ( providerImplementations != null )
- {
- for ( Map.Entry<String, String> providerEntry : providerImplementations.entrySet() )
- {
- logInfo( "Changing the default '%s' provider implementation to '%s'.", providerEntry.getKey(),
- providerEntry.getValue() );
- scmManager.setScmProviderImplementation( providerEntry.getKey(), providerEntry.getValue() );
+ if (providerImplementations != null) {
+ for (Map.Entry<String, String> providerEntry : providerImplementations.entrySet()) {
+ logInfo(
+ "Changing the default '%s' provider implementation to '%s'.",
+ providerEntry.getKey(), providerEntry.getValue());
+ scmManager.setScmProviderImplementation(providerEntry.getKey(), providerEntry.getValue());
}
}
- scmRepository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, settings );
+ scmRepository = scmRepositoryConfigurator.getConfiguredRepository(releaseDescriptor, settings);
- scmProvider = scmRepositoryConfigurator.getRepositoryProvider( scmRepository );
+ scmProvider = scmRepositoryConfigurator.getRepositoryProvider(scmRepository);
return releaseDescriptor;
}
- protected void checkoutExisting()
- throws MojoExecutionException
- {
+ protected void checkoutExisting() throws MojoExecutionException {
- if ( scmProvider instanceof AbstractSvnScmProvider )
- {
+ if (scmProvider instanceof AbstractSvnScmProvider) {
checkCreateRemoteSvnPath();
}
- logInfo( MessageUtils.buffer().strong( "%s" ) + " the pub tree from " + MessageUtils.buffer().strong( "%s" )
- + " into %s", ( tryUpdate ? "Updating" : "Checking out" ), pubScmUrl, checkoutDirectory );
+ logInfo(
+ MessageUtils.buffer().strong("%s") + " the pub tree from "
+ + MessageUtils.buffer().strong("%s") + " into %s",
+ (tryUpdate ? "Updating" : "Checking out"),
+ pubScmUrl,
+ checkoutDirectory);
- if ( checkoutDirectory.exists() && !tryUpdate )
+ if (checkoutDirectory.exists() && !tryUpdate) {
- {
- try
- {
- FileUtils.deleteDirectory( checkoutDirectory );
- }
- catch ( IOException e )
- {
- logError( e.getMessage() );
+ try {
+ FileUtils.deleteDirectory(checkoutDirectory);
+ } catch (IOException e) {
+ logError(e.getMessage());
- throw new MojoExecutionException( "Unable to remove old checkout directory: " + e.getMessage(), e );
+ throw new MojoExecutionException("Unable to remove old checkout directory: " + e.getMessage(), e);
}
}
boolean forceCheckout = false;
- if ( !checkoutDirectory.exists() )
+ if (!checkoutDirectory.exists()) {
- {
- if ( tryUpdate )
- {
- logInfo( "TryUpdate is configured but no local copy currently available: forcing checkout." );
+ if (tryUpdate) {
+ logInfo("TryUpdate is configured but no local copy currently available: forcing checkout.");
}
checkoutDirectory.mkdirs();
forceCheckout = true;
}
- try
- {
- ScmFileSet fileSet = new ScmFileSet( checkoutDirectory, includes, excludes );
+ try {
+ ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, includes, excludes);
- ScmBranch branch = ( scmBranch == null ) ? null : new ScmBranch( scmBranch );
+ ScmBranch branch = (scmBranch == null) ? null : new ScmBranch(scmBranch);
ScmResult scmResult = null;
- if ( tryUpdate && !forceCheckout )
- {
- scmResult = scmProvider.update( scmRepository, fileSet, branch );
- }
- else
- {
+ if (tryUpdate && !forceCheckout) {
+ scmResult = scmProvider.update(scmRepository, fileSet, branch);
+ } else {
int attempt = 0;
- while ( scmResult == null )
- {
- try
- {
- scmResult = scmProvider.checkOut( scmRepository, fileSet, branch );
- }
- catch ( ScmException e )
- {
+ while (scmResult == null) {
+ try {
+ scmResult = scmProvider.checkOut(scmRepository, fileSet, branch);
+ } catch (ScmException e) {
// give it max 2 times to retry
- if ( attempt++ < 2 )
- {
- try
- {
+ if (attempt++ < 2) {
+ try {
// wait 3 seconds
- Thread.sleep( 3 * 1000 );
- }
- catch ( InterruptedException ie )
- {
+ Thread.sleep(3 * 1000);
+ } catch (InterruptedException ie) {
// noop
}
- }
- else
- {
+ } else {
throw e;
}
}
}
}
- checkScmResult( scmResult, "check out from SCM" );
- }
- catch ( ScmException | IOException e )
- {
- logError( e.getMessage() );
+ checkScmResult(scmResult, "check out from SCM");
+ } catch (ScmException | IOException e) {
+ logError(e.getMessage());
- throw new MojoExecutionException( "An error occurred during the checkout process: " + e.getMessage(), e );
+ throw new MojoExecutionException("An error occurred during the checkout process: " + e.getMessage(), e);
}
}
- private void checkCreateRemoteSvnPath()
- throws MojoExecutionException
- {
- getLog().debug( "AbstractSvnScmProvider used, so we can check if remote url exists and eventually create it." );
+ private void checkCreateRemoteSvnPath() throws MojoExecutionException {
+ getLog().debug("AbstractSvnScmProvider used, so we can check if remote url exists and eventually create it.");
AbstractSvnScmProvider svnScmProvider = (AbstractSvnScmProvider) scmProvider;
- try
- {
- boolean remoteExists = svnScmProvider.remoteUrlExist( scmRepository.getProviderRepository(), null );
+ try {
+ boolean remoteExists = svnScmProvider.remoteUrlExist(scmRepository.getProviderRepository(), null);
- if ( remoteExists )
- {
+ if (remoteExists) {
return;
}
- }
- catch ( ScmException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
+ } catch (ScmException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
- String remoteUrl = ( (SvnScmProviderRepository) scmRepository.getProviderRepository() ).getUrl();
+ String remoteUrl = ((SvnScmProviderRepository) scmRepository.getProviderRepository()).getUrl();
- if ( !automaticRemotePathCreation )
- {
+ if (!automaticRemotePathCreation) {
// olamy: return ?? that will fail during checkout IMHO :-)
- logWarn( "Remote svn url %s does not exist and automatic remote path creation disabled.",
- remoteUrl );
+ logWarn("Remote svn url %s does not exist and automatic remote path creation disabled.", remoteUrl);
return;
}
- logInfo( "Remote svn url %s does not exist: creating.", remoteUrl );
+ logInfo("Remote svn url %s does not exist: creating.", remoteUrl);
File baseDir = null;
- try
- {
+ try {
// create a temporary directory for svnexec
- baseDir = Files.createTempDirectory( "scm" ).toFile();
+ baseDir = Files.createTempDirectory("scm").toFile();
// to prevent fileSet cannot be empty
- ScmFileSet scmFileSet = new ScmFileSet( baseDir, new File( "" ) );
+ ScmFileSet scmFileSet = new ScmFileSet(baseDir, new File(""));
CommandParameters commandParameters = new CommandParameters();
- commandParameters.setString( CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.FALSE.toString() );
- commandParameters.setString( CommandParameter.MESSAGE, "Automatic svn path creation: " + remoteUrl );
- svnScmProvider.mkdir( scmRepository.getProviderRepository(), scmFileSet, commandParameters );
+ commandParameters.setString(CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.FALSE.toString());
+ commandParameters.setString(CommandParameter.MESSAGE, "Automatic svn path creation: " + remoteUrl);
+ svnScmProvider.mkdir(scmRepository.getProviderRepository(), scmFileSet, commandParameters);
// new remote url so force checkout!
- if ( checkoutDirectory.exists() )
- {
- FileUtils.deleteDirectory( checkoutDirectory );
+ if (checkoutDirectory.exists()) {
+ FileUtils.deleteDirectory(checkoutDirectory);
}
- }
- catch ( IOException | ScmException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- finally
- {
- if ( baseDir != null )
- {
- try
- {
- FileUtils.forceDeleteOnExit( baseDir );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
+ } catch (IOException | ScmException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ } finally {
+ if (baseDir != null) {
+ try {
+ FileUtils.forceDeleteOnExit(baseDir);
+ } catch (IOException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
}
}
}
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
- if ( skipDeployment || skipDeployement )
- {
- getLog().info( "scmpublish.skipDeploy = true: Skipping site deployment" );
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (skipDeployment || skipDeployement) {
+ getLog().info("scmpublish.skipDeploy = true: Skipping site deployment");
return;
}
// setup the scm plugin with help from release plugin utilities
- try
- {
+ try {
setupScm();
- }
- catch ( ScmRepositoryException | NoSuchScmProviderException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
+ } catch (ScmRepositoryException | NoSuchScmProviderException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
boolean tmpCheckout = false;
- if ( checkoutDirectory.getPath().contains( "${project." ) )
- {
- try
- {
+ if (checkoutDirectory.getPath().contains("${project.")) {
+ try {
tmpCheckout = true;
- checkoutDirectory = Files.createTempDirectory( "maven-scm-publish" + ".checkout" ).toFile();
- }
- catch ( IOException ioe )
- {
- throw new MojoExecutionException( ioe.getMessage(), ioe );
+ checkoutDirectory = Files.createTempDirectory("maven-scm-publish" + ".checkout")
+ .toFile();
+ } catch (IOException ioe) {
+ throw new MojoExecutionException(ioe.getMessage(), ioe);
}
}
- try
- {
+ try {
scmPublishExecute();
- }
- finally
- {
- if ( tmpCheckout )
- {
- FileUtils.deleteQuietly( checkoutDirectory );
+ } finally {
+ if (tmpCheckout) {
+ FileUtils.deleteQuietly(checkoutDirectory);
}
}
}
@@ -604,57 +533,47 @@ public abstract class AbstractScmPublishMojo
*
* @throws MojoExecutionException in case of issue
*/
- protected void checkinFiles()
- throws MojoExecutionException
- {
- if ( skipCheckin )
- {
+ protected void checkinFiles() throws MojoExecutionException {
+ if (skipCheckin) {
return;
}
- ScmFileSet updatedFileSet = new ScmFileSet( checkoutDirectory );
- try
- {
+ ScmFileSet updatedFileSet = new ScmFileSet(checkoutDirectory);
+ try {
long start = System.currentTimeMillis();
- CheckInScmResult checkinResult =
- checkScmResult( scmProvider.checkIn( scmRepository, updatedFileSet, new ScmBranch( scmBranch ),
- checkinComment ), "check-in files to SCM" );
+ CheckInScmResult checkinResult = checkScmResult(
+ scmProvider.checkIn(scmRepository, updatedFileSet, new ScmBranch(scmBranch), checkinComment),
+ "check-in files to SCM");
- logInfo( "Checked in %d file(s) to revision %s in %s", checkinResult.getCheckedInFiles().size(),
- checkinResult.getScmRevision(),
- DurationFormatUtils.formatPeriod( start, System.currentTimeMillis(), "H' h 'm' m 's' s'" ) );
- }
- catch ( ScmException e )
- {
- throw new MojoExecutionException( "Failed to perform SCM checkin", e );
+ logInfo(
+ "Checked in %d file(s) to revision %s in %s",
+ checkinResult.getCheckedInFiles().size(),
+ checkinResult.getScmRevision(),
+ DurationFormatUtils.formatPeriod(start, System.currentTimeMillis(), "H' h 'm' m 's' s'"));
+ } catch (ScmException e) {
+ throw new MojoExecutionException("Failed to perform SCM checkin", e);
}
}
- protected void deleteFiles( Collection<File> deleted )
- throws MojoExecutionException
- {
- if ( skipDeletedFiles )
- {
- logInfo( "Deleting files is skipped." );
+ protected void deleteFiles(Collection<File> deleted) throws MojoExecutionException {
+ if (skipDeletedFiles) {
+ logInfo("Deleting files is skipped.");
return;
}
List<File> deletedList = new ArrayList<>();
- for ( File f : deleted )
- {
- deletedList.add( relativize( checkoutDirectory, f ) );
+ for (File f : deleted) {
+ deletedList.add(relativize(checkoutDirectory, f));
}
- ScmFileSet deletedFileSet = new ScmFileSet( checkoutDirectory, deletedList );
- try
- {
- getLog().info( "Deleting files: " + deletedList );
+ ScmFileSet deletedFileSet = new ScmFileSet(checkoutDirectory, deletedList);
+ try {
+ getLog().info("Deleting files: " + deletedList);
- checkScmResult( scmProvider.remove( scmRepository, deletedFileSet, "Deleting obsolete site files." ),
- "delete files from SCM" );
- }
- catch ( ScmException e )
- {
- throw new MojoExecutionException( "Failed to delete removed files to SCM", e );
+ checkScmResult(
+ scmProvider.remove(scmRepository, deletedFileSet, "Deleting obsolete site files."),
+ "delete files from SCM");
+ } catch (ScmException e) {
+ throw new MojoExecutionException("Failed to delete removed files to SCM", e);
}
}
@@ -665,121 +584,90 @@ public abstract class AbstractScmPublishMojo
* @throws MojoFailureException in case of issue
* @throws MojoExecutionException in case of issue
*/
- protected void addFiles( Collection<File> added )
- throws MojoFailureException, MojoExecutionException
- {
+ protected void addFiles(Collection<File> added) throws MojoFailureException, MojoExecutionException {
List<File> addedList = new ArrayList<>();
Set<File> createdDirs = new HashSet<>();
Set<File> dirsToAdd = new TreeSet<>();
- createdDirs.add( relativize( checkoutDirectory, checkoutDirectory ) );
+ createdDirs.add(relativize(checkoutDirectory, checkoutDirectory));
- for ( File f : added )
- {
- for ( File dir = f.getParentFile(); !dir.equals( checkoutDirectory ); dir = dir.getParentFile() )
- {
- File relativized = relativize( checkoutDirectory, dir );
+ for (File f : added) {
+ for (File dir = f.getParentFile(); !dir.equals(checkoutDirectory); dir = dir.getParentFile()) {
+ File relativized = relativize(checkoutDirectory, dir);
// we do the best we can with the directories
- if ( createdDirs.add( relativized ) )
- {
- dirsToAdd.add( relativized );
- }
- else
- {
+ if (createdDirs.add(relativized)) {
+ dirsToAdd.add(relativized);
+ } else {
break;
}
}
- addedList.add( relativize( checkoutDirectory, f ) );
- }
-
- if ( addUniqueDirectory )
- { // add one directory at a time
- for ( File relativized : dirsToAdd )
- {
- try
- {
- ScmFileSet fileSet = new ScmFileSet( checkoutDirectory, relativized );
- getLog().info( "scm add directory: " + relativized );
- AddScmResult addDirResult = scmProvider.add( scmRepository, fileSet, "Adding directory" );
- if ( !addDirResult.isSuccess() )
- {
- getLog().warn( " Error adding directory " + relativized + ": "
- + addDirResult.getCommandOutput() );
+ addedList.add(relativize(checkoutDirectory, f));
+ }
+
+ if (addUniqueDirectory) { // add one directory at a time
+ for (File relativized : dirsToAdd) {
+ try {
+ ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, relativized);
+ getLog().info("scm add directory: " + relativized);
+ AddScmResult addDirResult = scmProvider.add(scmRepository, fileSet, "Adding directory");
+ if (!addDirResult.isSuccess()) {
+ getLog().warn(" Error adding directory " + relativized + ": "
+ + addDirResult.getCommandOutput());
}
- }
- catch ( ScmException e )
- {
+ } catch (ScmException e) {
//
}
}
- }
- else
- { // add all directories in one command
- try
- {
- 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" );
- if ( !addDirResult.isSuccess() )
- {
- getLog().warn( " Error adding directories " + dirs + ": " + addDirResult.getCommandOutput() );
+ } else { // add all directories in one command
+ try {
+ 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");
+ if (!addDirResult.isSuccess()) {
+ getLog().warn(" Error adding directories " + dirs + ": " + addDirResult.getCommandOutput());
}
- }
- catch ( ScmException e )
- {
+ } catch (ScmException e) {
//
}
}
// remove directories already added !
- addedList.removeAll( dirsToAdd );
-
- ScmFileSet addedFileSet = new ScmFileSet( checkoutDirectory, addedList );
- getLog().info( "scm add files: " + addedList );
- try
- {
- CommandParameters commandParameters = new CommandParameters();
- commandParameters.setString( CommandParameter.MESSAGE, "Adding new site files." );
- commandParameters.setString( CommandParameter.FORCE_ADD, Boolean.TRUE.toString() );
- checkScmResult( scmProvider.add( scmRepository, addedFileSet, commandParameters ),
- "add new files to SCM" );
- }
- catch ( ScmException e )
- {
- throw new MojoExecutionException( "Failed to add new files to SCM", e );
+ addedList.removeAll(dirsToAdd);
+
+ ScmFileSet addedFileSet = new ScmFileSet(checkoutDirectory, addedList);
+ getLog().info("scm add files: " + addedList);
+ try {
+ CommandParameters commandParameters = new CommandParameters();
+ commandParameters.setString(CommandParameter.MESSAGE, "Adding new site files.");
+ commandParameters.setString(CommandParameter.FORCE_ADD, Boolean.TRUE.toString());
+ checkScmResult(scmProvider.add(scmRepository, addedFileSet, commandParameters), "add new files to SCM");
+ } catch (ScmException e) {
+ throw new MojoExecutionException("Failed to add new files to SCM", e);
}
}
- private <T extends ScmResult> T checkScmResult( T result, String failure )
- throws MojoExecutionException
- {
- if ( !result.isSuccess() )
- {
+ private <T extends ScmResult> T checkScmResult(T result, String failure) throws MojoExecutionException {
+ if (!result.isSuccess()) {
String msg = "Failed to " + failure + ": " + result.getProviderMessage() + " " + result.getCommandOutput();
- logError( msg );
- throw new MojoExecutionException( msg );
+ logError(msg);
+ throw new MojoExecutionException(msg);
}
return result;
}
- public boolean isDryRun()
- {
+ public boolean isDryRun() {
return dryRun;
}
- public abstract void scmPublishExecute()
- throws MojoExecutionException, MojoFailureException;
+ public abstract void scmPublishExecute() throws MojoExecutionException, MojoFailureException;
- public void setPubScmUrl( String pubScmUrl )
- {
+ public void setPubScmUrl(String pubScmUrl) {
// Fix required for Windows, which fit other OS as well
- if ( pubScmUrl.startsWith( "scm:svn:" ) )
- {
- pubScmUrl = pubScmUrl.replaceFirst( "file:/[/]*", "file:///" );
+ if (pubScmUrl.startsWith("scm:svn:")) {
+ pubScmUrl = pubScmUrl.replaceFirst("file:/[/]*", "file:///");
}
this.pubScmUrl = pubScmUrl;
}
-
}
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 265d65a..36de21a 100644
--- a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
+++ b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.scmpublish;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.plugins.scmpublish;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.plugins.scmpublish;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.plugins.scmpublish;
import java.io.BufferedReader;
import java.io.File;
@@ -53,19 +52,17 @@ import org.codehaus.plexus.util.MatchPatterns;
* <code>${project.build.directory}/staging</code>.
* Can be used without project, so usable to update any SCM with any content.
*/
-@Mojo ( name = "publish-scm", aggregator = true, requiresProject = false )
-public class ScmPublishPublishScmMojo
- extends AbstractScmPublishMojo
-{
+@Mojo(name = "publish-scm", aggregator = true, requiresProject = false)
+public class ScmPublishPublishScmMojo extends AbstractScmPublishMojo {
/**
* The content to be published.
*/
- @Parameter ( property = "scmpublish.content", defaultValue = "${project.build.directory}/staging" )
+ @Parameter(property = "scmpublish.content", defaultValue = "${project.build.directory}/staging")
private File content;
/**
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;
private List<File> deleted = new ArrayList<>();
@@ -87,90 +84,71 @@ public class ScmPublishPublishScmMojo
* used for modules, which content is available only when staging
* @throws IOException
*/
- private void update( File checkout, File dir, List<String> doNotDeleteDirs )
- throws IOException
- {
+ private void update(File checkout, File dir, List<String> doNotDeleteDirs) throws IOException {
String scmSpecificFilename = scmProvider.getScmSpecificFilename();
String[] files = scmSpecificFilename != null
- ? checkout.list( new NotFileFilter( new NameFileFilter( scmSpecificFilename ) ) )
- : checkout.list();
+ ? checkout.list(new NotFileFilter(new NameFileFilter(scmSpecificFilename)))
+ : checkout.list();
- Set<String> checkoutContent = new HashSet<>( Arrays.asList( files ) ) ;
- List<String> dirContent = ( dir != null ) ? Arrays.asList( dir.list() ) : Collections.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<>( checkoutContent );
- deleted.removeAll( dirContent );
+ Set<String> deleted = new HashSet<>(checkoutContent);
+ deleted.removeAll(dirContent);
MatchPatterns ignoreDeleteMatchPatterns = null;
- List<String> pathsAsList = new ArrayList<>( 0 );
- if ( ignorePathsToDelete != null && ignorePathsToDelete.length > 0 )
- {
- ignoreDeleteMatchPatterns = MatchPatterns.from( ignorePathsToDelete );
- pathsAsList = Arrays.asList( ignorePathsToDelete );
+ List<String> pathsAsList = new ArrayList<>(0);
+ if (ignorePathsToDelete != null && ignorePathsToDelete.length > 0) {
+ ignoreDeleteMatchPatterns = MatchPatterns.from(ignorePathsToDelete);
+ pathsAsList = Arrays.asList(ignorePathsToDelete);
}
- for ( String name : deleted )
- {
- if ( ignoreDeleteMatchPatterns != null && ignoreDeleteMatchPatterns.matches( name, true ) )
- {
- getLog().debug(
- name + " match one of the patterns '" + pathsAsList + "': do not add to deleted files" );
+ for (String name : deleted) {
+ if (ignoreDeleteMatchPatterns != null && ignoreDeleteMatchPatterns.matches(name, true)) {
+ getLog().debug(name + " match one of the patterns '" + pathsAsList + "': do not add to deleted files");
continue;
}
- getLog().debug( "file marked for deletion: " + name );
- File file = new File( checkout, name );
+ getLog().debug("file marked for deletion: " + name);
+ File file = new File(checkout, name);
- if ( ( doNotDeleteDirs != null ) && file.isDirectory() && ( doNotDeleteDirs.contains( name ) ) )
- {
+ if ((doNotDeleteDirs != null) && file.isDirectory() && (doNotDeleteDirs.contains(name))) {
// ignore directory not available
continue;
}
- if ( file.isDirectory() )
- {
- update( file, null, null );
+ if (file.isDirectory()) {
+ update(file, null, null);
}
- this.deleted.add( file );
+ this.deleted.add(file);
}
- for ( String name : dirContent )
- {
- File file = new File( checkout, name );
- File source = new File( dir, name );
+ for (String name : dirContent) {
+ File file = new File(checkout, name);
+ File source = new File(dir, name);
- if ( Files.isSymbolicLink( source.toPath() ) )
- {
- if ( !checkoutContent.contains( name ) )
- {
- this.added.add( file );
+ if (Files.isSymbolicLink(source.toPath())) {
+ if (!checkoutContent.contains(name)) {
+ this.added.add(file);
}
// copy symbolic link (Java 7 only)
- copySymLink( source, file );
- }
- else if ( source.isDirectory() )
- {
+ copySymLink(source, file);
+ } else if (source.isDirectory()) {
directories++;
- if ( !checkoutContent.contains( name ) )
- {
- this.added.add( file );
+ if (!checkoutContent.contains(name)) {
+ this.added.add(file);
file.mkdir();
}
- update( file, source, null );
- }
- else
- {
- if ( checkoutContent.contains( name ) )
- {
- this.updated.add( file );
- }
- else
- {
- this.added.add( file );
+ update(file, source, null);
+ } else {
+ if (checkoutContent.contains(name)) {
+ this.updated.add(file);
+ } else {
+ this.added.add(file);
}
- copyFile( source, file );
+ copyFile(source, file);
}
}
}
@@ -180,13 +158,15 @@ public class ScmPublishPublishScmMojo
*
* @param srcFile the source file (expected to be a symbolic link)
* @param destFile the destination file (which will be a symbolic link)
- * @throws IOException
+ * @throws IOException
*/
- private void copySymLink( File srcFile, File destFile )
- throws IOException
- {
- Files.copy( srcFile.toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING,
- StandardCopyOption.COPY_ATTRIBUTES, LinkOption.NOFOLLOW_LINKS );
+ private void copySymLink(File srcFile, File destFile) throws IOException {
+ Files.copy(
+ srcFile.toPath(),
+ destFile.toPath(),
+ StandardCopyOption.REPLACE_EXISTING,
+ StandardCopyOption.COPY_ATTRIBUTES,
+ LinkOption.NOFOLLOW_LINKS);
}
/**
@@ -197,16 +177,11 @@ public class ScmPublishPublishScmMojo
* @throws IOException
* @see #requireNormalizeNewlines(File)
*/
- private void copyFile( File srcFile, File destFile )
- throws IOException
- {
- if ( requireNormalizeNewlines( srcFile ) )
- {
- copyAndNormalizeNewlines( srcFile, destFile );
- }
- else
- {
- FileUtils.copyFile( srcFile, destFile );
+ private void copyFile(File srcFile, File destFile) throws IOException {
+ if (requireNormalizeNewlines(srcFile)) {
+ copyAndNormalizeNewlines(srcFile, destFile);
+ } else {
+ FileUtils.copyFile(srcFile, destFile);
}
files++;
size += destFile.length();
@@ -219,27 +194,18 @@ public class ScmPublishPublishScmMojo
* @param destFile the destination file
* @throws IOException
*/
- private void copyAndNormalizeNewlines( File srcFile, File destFile )
- throws IOException
- {
+ private void copyAndNormalizeNewlines(File srcFile, File destFile) throws IOException {
BufferedReader in = null;
PrintWriter out = null;
- try
- {
- 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() )
- {
- if ( in.ready() )
- {
- out.println( line );
- }
- else
- {
- out.print( line );
+ try {
+ 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()) {
+ if (in.ready()) {
+ out.println(line);
+ } else {
+ out.print(line);
}
}
@@ -247,105 +213,96 @@ public class ScmPublishPublishScmMojo
out = null;
in.close();
in = null;
- }
- finally
- {
- IOUtils.closeQuietly( out );
- IOUtils.closeQuietly( in );
+ } finally {
+ IOUtils.closeQuietly(out);
+ IOUtils.closeQuietly(in);
}
}
- public void scmPublishExecute()
- throws MojoExecutionException, MojoFailureException
- {
- if ( siteOutputEncoding == null )
- {
- getLog().warn( "No output encoding, defaulting to UTF-8." );
+ public void scmPublishExecute() throws MojoExecutionException, MojoFailureException {
+ if (siteOutputEncoding == null) {
+ getLog().warn("No output encoding, defaulting to UTF-8.");
siteOutputEncoding = "utf-8";
}
- if ( !content.exists() )
- {
- throw new MojoExecutionException( "Configured content directory does not exist: " + content );
+ if (!content.exists()) {
+ throw new MojoExecutionException("Configured content directory does not exist: " + content);
}
- if ( !content.canRead() )
- {
- throw new MojoExecutionException( "Can't read content directory: " + content );
+ if (!content.canRead()) {
+ throw new MojoExecutionException("Can't read content directory: " + content);
}
checkoutExisting();
final File updateDirectory;
- if ( subDirectory == null )
- {
+ if (subDirectory == null) {
updateDirectory = checkoutDirectory;
- }
- else
- {
- updateDirectory = new File( checkoutDirectory, subDirectory );
+ } else {
+ updateDirectory = new File(checkoutDirectory, subDirectory);
// Security check for subDirectory with .. inside
- if ( !updateDirectory.toPath().normalize().startsWith( checkoutDirectory.toPath().normalize() ) )
- {
- logError( "Try to acces outside of the checkout directory with sub-directory: %s", subDirectory );
+ if (!updateDirectory
+ .toPath()
+ .normalize()
+ .startsWith(checkoutDirectory.toPath().normalize())) {
+ logError("Try to acces outside of the checkout directory with sub-directory: %s", subDirectory);
return;
}
- if ( !updateDirectory.exists() )
- {
+ if (!updateDirectory.exists()) {
updateDirectory.mkdirs();
}
- logInfo( "Will copy content in sub-directory: %s", subDirectory );
+ logInfo("Will copy content in sub-directory: %s", subDirectory);
}
- try
- {
- logInfo( "Updating checkout directory with actual content in %s", content );
- update( updateDirectory, content, ( project == null ) ? null : project.getModel().getModules() );
- String displaySize = org.apache.commons.io.FileUtils.byteCountToDisplaySize( size );
- logInfo( "Content consists of " + MessageUtils.buffer().strong( "%d directories and %d files = %s" ),
- directories, files, displaySize );
- }
- catch ( IOException ioe )
- {
- throw new MojoExecutionException( "Could not copy content to SCM checkout", ioe );
+ try {
+ logInfo("Updating checkout directory with actual content in %s", content);
+ update(
+ updateDirectory,
+ content,
+ (project == null) ? null : project.getModel().getModules());
+ String displaySize = org.apache.commons.io.FileUtils.byteCountToDisplaySize(size);
+ logInfo(
+ "Content consists of " + MessageUtils.buffer().strong("%d directories and %d files = %s"),
+ directories,
+ files,
+ displaySize);
+ } catch (IOException ioe) {
+ throw new MojoExecutionException("Could not copy content to SCM checkout", ioe);
}
- logInfo( "Publishing content to SCM will result in "
- + MessageUtils.buffer().strong( "%d addition(s), %d update(s), %d delete(s)" ), added.size(),
- updated.size(), deleted.size() );
+ logInfo(
+ "Publishing content to SCM will result in "
+ + MessageUtils.buffer().strong("%d addition(s), %d update(s), %d delete(s)"),
+ added.size(),
+ updated.size(),
+ deleted.size());
- if ( isDryRun() )
- {
+ if (isDryRun()) {
int pos = checkoutDirectory.getAbsolutePath().length() + 1;
- for ( File addedFile : added )
- {
- logInfo( "- addition %s", addedFile.getAbsolutePath().substring( pos ) );
+ for (File addedFile : added) {
+ logInfo("- addition %s", addedFile.getAbsolutePath().substring(pos));
}
- for ( File updatedFile : updated )
- {
- logInfo( "- update %s", updatedFile.getAbsolutePath().substring( pos ) );
+ for (File updatedFile : updated) {
+ logInfo("- update %s", updatedFile.getAbsolutePath().substring(pos));
}
- for ( File deletedFile : deleted )
- {
- logInfo( "- delete %s", deletedFile.getAbsolutePath().substring( pos ) );
+ for (File deletedFile : deleted) {
+ logInfo("- delete %s", deletedFile.getAbsolutePath().substring(pos));
}
return;
}
- if ( !added.isEmpty() )
- {
- addFiles( added );
+ if (!added.isEmpty()) {
+ addFiles(added);
}
- if ( !deleted.isEmpty() )
- {
- deleteFiles( deleted );
+ if (!deleted.isEmpty()) {
+ deleteFiles(deleted);
}
- logInfo( "Checking in SCM, starting at " + new Date() + "..." );
+ logInfo("Checking in SCM, starting at " + new Date() + "...");
checkinFiles();
}
}
[maven-scm-publish-plugin] 03/03: [MSCMPUB-57] Upgrade misc deps maven-shared-utils to 3.3.4 commons-land to 3.12.0 maven-release-manager to 3.0.0-M7 org.apache.maven.scm:* to 2.0.0-M3
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
commit c8b0849bad958bcc8d3c372c0968c52baa738319
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Mar 4 17:39:14 2023 +0100
[MSCMPUB-57] Upgrade misc deps
maven-shared-utils to 3.3.4
commons-land to 3.12.0
maven-release-manager to 3.0.0-M7
org.apache.maven.scm:* to 2.0.0-M3
---
pom.xml | 30 +++++++++++++++++++---
.../plugins/scmpublish/AbstractScmPublishMojo.java | 16 +++++++-----
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5c2fcb9..33b006b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@ under the License.
</distributionManagement>
<properties>
- <scmVersion>1.11.2</scmVersion>
+ <scmVersion>2.0.0-M3</scmVersion>
<mavenVersion>3.2.5</mavenVersion>
<javaVersion>8</javaVersion>
@@ -79,7 +79,23 @@ under the License.
<dependency>
<groupId>org.apache.maven.release</groupId>
<artifactId>maven-release-manager</artifactId>
- <version>2.5.3</version>
+ <version>3.0.0-M7</version>
+ </dependency>
+ <!-- remove with maven-release-manager upgrade -->
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>2.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-common</artifactId>
+ <version>2.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-osgi</artifactId>
+ <version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -104,12 +120,18 @@ under the License.
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
- <version>3.3.3</version>
+ <version>3.3.4</version>
+ </dependency>
+ <!-- remove with maven-shared-utils upgrade -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
- <version>3.1</version>
+ <version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
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 d4689f9..4230b7e 100644
--- a/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
+++ b/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
@@ -61,6 +61,7 @@ import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.apache.maven.settings.crypto.SettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.apache.maven.shared.release.config.ReleaseDescriptor;
+import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
import org.apache.maven.shared.utils.logging.MessageUtils;
@@ -318,8 +319,8 @@ public abstract class AbstractScmPublishMojo extends AbstractMojo {
logInfo("Performing a LOCAL checkout from " + scmUrl);
}
- ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
- releaseDescriptor.setInteractive(settings.isInteractiveMode());
+ ReleaseDescriptorBuilder descriptorBuilder = new ReleaseDescriptorBuilder();
+ descriptorBuilder.setInteractive(settings.isInteractiveMode());
if (username == null || password == null) {
for (Server server : settings.getServers()) {
@@ -345,12 +346,12 @@ public abstract class AbstractScmPublishMojo extends AbstractMojo {
}
}
- releaseDescriptor.setScmPassword(password);
- releaseDescriptor.setScmUsername(username);
+ descriptorBuilder.setScmPassword(password);
+ descriptorBuilder.setScmUsername(username);
- releaseDescriptor.setWorkingDirectory(basedir.getAbsolutePath());
- releaseDescriptor.setLocalCheckout(localCheckout);
- releaseDescriptor.setScmSourceUrl(pubScmUrl);
+ descriptorBuilder.setWorkingDirectory(basedir.getAbsolutePath());
+ descriptorBuilder.setLocalCheckout(localCheckout);
+ descriptorBuilder.setScmSourceUrl(pubScmUrl);
if (providerImplementations != null) {
for (Map.Entry<String, String> providerEntry : providerImplementations.entrySet()) {
@@ -361,6 +362,7 @@ public abstract class AbstractScmPublishMojo extends AbstractMojo {
}
}
+ ReleaseDescriptor releaseDescriptor = descriptorBuilder.build();
scmRepository = scmRepositoryConfigurator.getConfiguredRepository(releaseDescriptor, settings);
scmProvider = scmRepositoryConfigurator.getRepositoryProvider(scmRepository);
[maven-scm-publish-plugin] 01/03: [MSCMPUB-57] Upgrade parent pom to 39
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
commit b96e65d8e2b610c2a595542df7f75ba8fd9e0c94
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Mar 4 17:17:39 2023 +0100
[MSCMPUB-57] Upgrade parent pom to 39
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index acdd375..e3b620a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
- <version>34</version>
+ <version>39</version>
<relativePath />
</parent>