You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2018/01/07 18:21:57 UTC
[13/26] commons-release-plugin git commit: Svn checkout of dist
working properly
Svn checkout of dist working properly
Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/d365f0b0
Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/d365f0b0
Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/d365f0b0
Branch: refs/heads/master
Commit: d365f0b08d6e01664b3164bf9e48bdb0aba87dd0
Parents: 2a3a882
Author: Rob Tompkins <ch...@apache.org>
Authored: Tue Jan 2 14:22:50 2018 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Tue Jan 2 14:22:50 2018 -0500
----------------------------------------------------------------------
.../plugin/handler/DistributionScmHandler.java | 131 -------------------
.../release/plugin/handler/package-info.java | 17 ---
.../mojos/CommonsDistributionStagingMojo.java | 35 ++---
3 files changed, 12 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/d365f0b0/src/main/java/org/apache/commons/release/plugin/handler/DistributionScmHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/handler/DistributionScmHandler.java b/src/main/java/org/apache/commons/release/plugin/handler/DistributionScmHandler.java
deleted file mode 100644
index 4762dae..0000000
--- a/src/main/java/org/apache/commons/release/plugin/handler/DistributionScmHandler.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.release.plugin.handler;
-
-import org.apache.maven.scm.manager.NoSuchScmProviderException;
-import org.apache.maven.scm.manager.ScmManager;
-import org.apache.maven.scm.provider.ScmProviderRepository;
-import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
-import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
-import org.apache.maven.scm.repository.ScmRepository;
-import org.apache.maven.scm.repository.ScmRepositoryException;
-import org.apache.maven.settings.Server;
-import org.apache.maven.settings.Settings;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.StringUtils;
-import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
-import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
-
-import java.io.File;
-
-@Component(role= DistributionScmHandler.class, instantiationStrategy = "singleton" )
-public class DistributionScmHandler extends AbstractLogEnabled {
-
- /**
- * The SCM manager.
- */
- @Requirement
- private ScmManager scmManager;
-
- /**
- * When this plugin requires Maven 3.0 as minimum, this component can be removed and o.a.m.s.c.SettingsDecrypter be
- * used instead.
- */
- @Requirement(hint = "mng-4384")
- private SecDispatcher secDispatcher;
-
- public void checkoutDirectory(String scmUrl, File checkoutRootDirectory) {
-
- }
-
- public ScmRepository getConfiguredRepository(String url,
- String username,
- String password,
- String privateKey,
- String passphrase,
- Settings settings)
- throws ScmRepositoryException, NoSuchScmProviderException {
- ScmRepository repository = scmManager.makeScmRepository(url);
- ScmProviderRepository scmRepo = repository.getProviderRepository();
- //MRELEASE-76
- scmRepo.setPersistCheckout(false);
- if (settings != null) {
- Server server = null;
- if (server == null && repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost) {
- ScmProviderRepositoryWithHost repositoryWithHost =
- (ScmProviderRepositoryWithHost) repository.getProviderRepository();
- String host = repositoryWithHost.getHost();
- int port = repositoryWithHost.getPort();
- if (port > 0) {
- host += ":" + port;
- }
- // TODO: this is a bit dodgy - id is not host, but since we don't have a <host> field we make an assumption
- server = settings.getServer(host);
- }
-
- if (server != null) {
- if (username == null) {
- username = server.getUsername();
- }
- if (password == null) {
- password = decrypt(server.getPassword(), server.getId());
- }
- if (privateKey == null) {
- privateKey = server.getPrivateKey();
- }
- if (passphrase == null) {
- passphrase = decrypt(server.getPassphrase(), server.getId());
- }
- }
- }
- if (!StringUtils.isEmpty(username)) {
- scmRepo.setUser(username);
- }
- if (!StringUtils.isEmpty(password)) {
- scmRepo.setPassword(password);
- }
- if (scmRepo instanceof ScmProviderRepositoryWithHost) {
- ScmProviderRepositoryWithHost repositoryWithHost = (ScmProviderRepositoryWithHost) scmRepo;
- if (!StringUtils.isEmpty(privateKey)) {
- repositoryWithHost.setPrivateKey(privateKey);
- }
- if (!StringUtils.isEmpty(passphrase)) {
- repositoryWithHost.setPassphrase(passphrase);
- }
- }
- return repository;
- }
-
- private String decrypt(String str, String server) {
- try {
- return secDispatcher.decrypt(str);
- } catch (SecDispatcherException e) {
- String msg =
- "Failed to decrypt password/passphrase for server " + server + ", using auth token as is: "
- + e.getMessage();
- if (getLogger().isDebugEnabled()) {
- getLogger().warn(msg, e);
- } else {
- getLogger().warn(msg);
- }
- return str;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/d365f0b0/src/main/java/org/apache/commons/release/plugin/handler/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/handler/package-info.java b/src/main/java/org/apache/commons/release/plugin/handler/package-info.java
deleted file mode 100644
index 6f97164..0000000
--- a/src/main/java/org/apache/commons/release/plugin/handler/package-info.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.release.plugin.handler;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/d365f0b0/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
----------------------------------------------------------------------
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 327d8c5..6fa1a52 100644
--- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
+++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
@@ -23,9 +23,13 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.manager.BasicScmManager;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
@@ -38,11 +42,6 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
/**
*/
- @Parameter( defaultValue = "${settings}", readonly = true, required = true )
- private Settings settings;
-
- /**
- */
@Parameter( defaultValue = "${project.build.directory}/commons-release-plugin", alias = "outputDirectory" )
private File workingDirectory;
@@ -56,36 +55,26 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
@Parameter ( required = true )
private String distSvnStagingUrl;
- /**
- * The SCM username to use.
- */
- @Parameter( property = "username" )
- private String username;
-
- /**
- * The SCM password to use.
- */
- @Parameter( property = "password" )
- private String password;
-
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
ScmManager scmManager = new BasicScmManager();
scmManager.setScmProvider("svn", new SvnExeScmProvider());
ScmRepository repository = scmManager.makeScmRepository(distSvnStagingUrl);
+ ScmProvider provider = scmManager.getProviderByRepository(repository);
+ ScmProviderRepository providerRepository = repository.getProviderRepository();
if (!workingDirectory.exists()) {
SharedFunctions.initDirectory(getLog(), workingDirectory);
}
if (!distCheckoutDirectory.exists()) {
SharedFunctions.initDirectory(getLog(), distCheckoutDirectory);
}
- } catch (ScmRepositoryException e) {
- getLog().error("Failed getting scm repository: " + distSvnStagingUrl, e);
- throw new MojoExecutionException("Failed getting scm repository: " + distSvnStagingUrl, e);
- } catch (NoSuchScmProviderException e) {
- getLog().error("No Scm Provider For: " + distSvnStagingUrl, e);
- throw new MojoExecutionException("No Scm Provider For: " + distSvnStagingUrl, e);
+ ScmFileSet scmFileSet = new ScmFileSet(distCheckoutDirectory);
+ getLog().info("Checking out dist from: " + distSvnStagingUrl);
+ provider.checkOut(repository, scmFileSet);
+ } catch (ScmException e) {
+ getLog().error("Could not commit files to dist: " + distSvnStagingUrl, e);
+ throw new MojoExecutionException("Could not commit files to dist: " + distSvnStagingUrl, e);
}
}
}