You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2019/04/26 00:24:03 UTC

[incubator-tuweni] 25/48: Read the maven credentials from the local settings file if present

This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git

commit 31653a3d176921985e904e2189cc460bb2f63a8c
Author: Antoine Toulme <to...@apache.org>
AuthorDate: Sun Apr 21 23:02:15 2019 -0700

    Read the maven credentials from the local settings file if present
---
 build.gradle | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/build.gradle b/build.gradle
index af2caa8..dfe1ba8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -281,13 +281,28 @@ allprojects {
     publishing {
       repositories {
         maven {
-          credentials {
-            username System.getenv('NEXUS_USER')
-            password System.getenv('NEXUS_PASSWORD')
-          }
+          def isRelease = buildVersion.endsWith('SNAPSHOT')
           def releasesRepoUrl = "https://repository.apache.org/service/local/staging/deploy/maven2"
           def snapshotsRepoUrl = "https://repository.apache.org/content/repositories/snapshots"
-          url = buildVersion.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
+          url = isRelease ? snapshotsRepoUrl : releasesRepoUrl
+
+          def settingsXml = new File(System.getProperty('user.home'), '.m2/settings.xml')
+          if (settingsXml.exists()) {
+            def serverId = (project.properties['distMgmtServerId'] ?: isRelease
+              ? 'apache.releases.https' : 'apache.snapshots.https')
+            def m2SettingCreds = new XmlSlurper().parse(settingsXml).servers.server.find { server -> serverId.equals(server.id.text()) }
+            if (m2SettingCreds) {
+              credentials {
+                username m2SettingCreds.username.text()
+                password m2SettingCreds.password.text()
+              }
+            }
+          } else {
+            credentials {
+              username System.getenv('NEXUS_USER')
+              password System.getenv('NEXUS_PASSWORD')
+            }
+          }
         }
       }
       publications {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org