hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1560620 - in /httpcomponents/httpclient-android/branches/test-branch: build.gradle gradle.properties
Date Thu, 23 Jan 2014 10:25:53 GMT
Author: olegk
Date: Thu Jan 23 10:25:52 2014
New Revision: 1560620

URL: http://svn.apache.org/r1560620
Log:
Migrated from Gradle 'maven-publish' to 'maven' plugin due to latter not supporting artifact
signing

Modified:
    httpcomponents/httpclient-android/branches/test-branch/build.gradle
    httpcomponents/httpclient-android/branches/test-branch/gradle.properties

Modified: httpcomponents/httpclient-android/branches/test-branch/build.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/test-branch/build.gradle?rev=1560620&r1=1560619&r2=1560620&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/test-branch/build.gradle (original)
+++ httpcomponents/httpclient-android/branches/test-branch/build.gradle Thu Jan 23 10:25:52
2014
@@ -8,7 +8,7 @@ buildscript {
 }
 
 apply plugin: 'android-library'
-apply plugin: 'maven-publish'
+apply plugin: 'maven'
 apply plugin: 'signing'
 
 repositories {
@@ -18,6 +18,8 @@ repositories {
 group = 'org.apache.httpcomponents'
 version = HC_VER
 
+ext.isRelease = !version.endsWith('-SNAPSHOT')
+
 android {
 
     compileSdkVersion 18
@@ -34,6 +36,14 @@ android {
     }
 }
 
+configurations {
+    dist
+}
+
+signing {
+    required { isRelease }
+}
+
 ext.sharedManifest = manifest {
     attributes (
             'Specification-Title': "HttpComponents HttpClient for Android",
@@ -47,45 +57,6 @@ ext.sharedManifest = manifest {
     )
 }
 
-def pomDetails = {
-
-    name 'HttpComponents Client for Android'
-    url 'http://hc.apache.org/httpcomponents-client/'
-    organization {
-        name 'The Apache Software Foundation'
-        url 'http://www.apache.org/'
-    }
-    licenses {
-        license {
-            name 'Apache License, Version 2.0'
-            url 'LICENSE.txt'
-            distribution 'repo'
-        }
-    }
-    issueManagement {
-        system 'Jira'
-        url 'http://issues.apache.org/jira/browse/HTTPCLIENT'
-    }
-
-}
-
-publishing {
-    publications {
-        asf (MavenPublication) {
-            pom.withXml {
-                asNode().children().last() + pomDetails
-            }
-        }
-        repositories {
-            maven {
-                name 'ASF snapshots'
-                url ASF_SNAPSHOT_REPO
-            }
-        }
-    }
-}
-
-
 android.libraryVariants.all { variant ->
     def name = variant.buildType.name
     if (name == 'release') {
@@ -135,35 +106,121 @@ android.libraryVariants.all { variant ->
         }
 
         artifacts {
-            archives createAndroidJar
-            archives createAndroidSrcJar
-            archives createAndroidJavadocJar
+            dist createAndroidJar
+            dist createAndroidSrcJar
+            dist createAndroidJavadocJar
+        }
+
+        signing {
+            sign createAndroidJar
+            sign createAndroidSrcJar
+            sign createAndroidJavadocJar
         }
 
-        publishing.publications.asf.artifacts = [createAndroidJar, createAndroidSrcJar, createAndroidJavadocJar]
+        artifacts {
+            tasks.withType(Sign) { Sign task ->
+                task.signatures.each { PublishArtifact artifact ->
+                    dist artifact
+                }
+            }
+        }
+    }
+}
+
+// Deployment tasks
+
+def askPassphrase = {
+    Console console = System.console()
+    if (console) {
+        String password = project.ext.has('signing.password') ? project.ext.'signing.password'
: null
+        String keyId = project.ext.has('signing.keyId') ? project.ext.'signing.keyId' : null
+        if (keyId && !password) {
+            char[] raw = console.readPassword("\n> Please provide password for PGP key
${keyId}: ")
+            project.ext.'signing.password' = new String(raw)
+        }
+    }
+}
+
+def askCredentials(MavenDeployer mavenDeployer) {
+    Console console = System.console()
+    if (console) {
+        URL url = new URL(mavenDeployer.repository.url)
+        def auth = mavenDeployer.repository.authentication
+        if (auth) {
+            if (!auth.userName || auth.userName == '') {
+                String username = console.readLine("\n> Please enter user name for repository
'${url}': ")
+                auth.userName = username
+            }
+            if (!auth.password || auth.password == '') {
+                char[] raw = console.readPassword("\n> Please enter password for repository
'${url}': ")
+                auth.password = new String(raw)
+            }
+        }
+    }
+}
+
+task uploadDist(type: Upload) {
+    configuration = configurations.dist
+    repositories {
+        mavenDeployer {
+            def creds = [
+                userName: project.ext.has('asf.username') ? project.ext.'asf.username' :
null,
+                password: project.ext.has('asf.password') ? project.ext.'asf.password' :
null ]
+
+            if (System.properties['localRepo']) {
+                repository(url: "file:${buildDir.absolutePath}/repo")
+            } else {
+                if (version.endsWith('-SNAPSHOT')) {
+                    repository(url: ASF_SNAPSHOT_REPO) {
+                        authentication(creds)
+                    }
+                } else {
+                    repository(url: ASF_NEXUS_STAGE) {
+                        authentication(creds)
+                    }
+                }
+            }
+            pom.project {
+                name 'HttpComponents Client for Android'
+                url 'http://hc.apache.org/httpcomponents-client/'
+                organization {
+                    name 'The Apache Software Foundation'
+                    url 'http://www.apache.org/'
+                }
+                licenses {
+                    license {
+                        name 'Apache License, Version 2.0'
+                        url 'LICENSE.txt'
+                        distribution 'repo'
+                    }
+                }
+                issueManagement {
+                    system 'Jira'
+                    url 'http://issues.apache.org/jira/browse/HTTPCLIENT'
+                }
+            }
+            if (isRelease) {
+                beforeDeployment { MavenDeployment deployment ->
+                    askPassphrase()
+                    signing.signPom(deployment)
+                }
+            }
+        }
     }
 }
 
 gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
     taskGraph.allTasks.findAll { Task task ->
-        task instanceof PublishToMavenRepository }.each { Task task ->
+        task instanceof Upload }.each { Upload task ->
             task.doFirst {
-                MavenArtifactRepository repo = task.repository
-                if (repo.url.scheme && repo.url.scheme != 'file') {
-                    Console console = System.console()
-                    if (console) {
-                        console.println("Publishing to repository \'${repo.name}\': ${repo.url}")
-                        PasswordCredentials creds = repo.credentials
-                        if (!creds.username) {
-                            creds.username = console.readLine("> Please enter user name:
")
-                        }
-                        if (!creds.password) {
-                            char[] raw = console.readPassword("> Please enter password:
")
-                            creds.password = new String(raw)
-                        }
-                    }
+                task.repositories.each { MavenDeployer mavenDeployer ->
+                    askCredentials(mavenDeployer)
                 }
             }
     }
-}
 
+    taskGraph.allTasks.findAll { Task task ->
+        task instanceof Sign }.each { Sign task ->
+            task.doFirst { askPassphrase() }
+    }
+}

Modified: httpcomponents/httpclient-android/branches/test-branch/gradle.properties
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/test-branch/gradle.properties?rev=1560620&r1=1560619&r2=1560620&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/test-branch/gradle.properties (original)
+++ httpcomponents/httpclient-android/branches/test-branch/gradle.properties Thu Jan 23 10:25:52
2014
@@ -1,2 +1,3 @@
 HC_VER=4.3.1-SNAPSHOT
-ASF_SNAPSHOT_REPO=https://repository.apache.org/content/repositories/snapshots
\ No newline at end of file
+ASF_SNAPSHOT_REPO=https://repository.apache.org/content/repositories/snapshots
+ASF_NEXUS_STAGE=https://repository.apache.org/service/local/staging/deploy/maven2



Mime
View raw message