Commits

shemnon committed 9177c4e

build file tweaks

Comments (0)

Files changed (2)

-import groovyx.net.http.HTTPBuilder
-
-import static groovyx.net.http.ContentType.JSON
-import static groovyx.net.http.Method.GET
-import static groovyx.net.http.Method.POST
-
-buildscript {
-    repositories {
-        mavenRepo(url: 'http://dl.bintray.com/content/bintray/jcenter')
-    }
-    dependencies {
-        classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
-        classpath 'commons-collections:commons-collections:3.2.1'
-    }
-}
-
 apply plugin: 'java'
 apply plugin: 'maven'
+apply from: 'mavenPublish.gradle'
 
 sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
 group = 'org.bitbucket.shemnon.deckcontrol'
-version = '0.1.1-SNAPSHOT'
+version = '0.1.0'
 
 repositories {
     mavenCentral()
 
 repositories {
     mavenRepo(url: 'http://dl.bintray.com/content/bintray/jcenter')
-}
-
-task createBintrayPackage << {
-    def http = getHttpBuilder()
-    http.request(GET, JSON) {
-        uri.path = '/packages/' + bintray_username + '/' + bintray_repo + '/' + bintray_package
-        response.'404' = {
-            http = getHttpBuilder()
-            http.request(POST, JSON) {
-                uri.path = '/packages/' + bintray_username + '/' + bintray_repo
-                body = [name: bintray_package, desc: 'auto', desc_url: 'auto', labels: ['gradle', 'example']]
-
-                response.success = { resp ->
-                    println 'Created!!!'
-                }
-            }
-        }
-    }
-}
-
-uploadArchives() {
-    repositories {
-        maven {
-            url = bintray_api_base_url + '/content/' + bintray_username + '/' + bintray_repo + '/' + bintray_package + '/' + version
-            credentials {
-                username bintray_username
-                password bintray_api_key
-            }
-        }
-    }
-}
-
-uploadArchives.dependsOn createBintrayPackage
-
-def getHttpBuilder() {
-    def http = new HTTPBuilder(bintray_api_base_url)
-    http.auth.basic bintray_username, bintray_api_key
-    return http
 }

mavenPublish.gradle

+import groovyx.net.http.HTTPBuilder
+
+import static groovyx.net.http.ContentType.JSON
+import static groovyx.net.http.Method.GET
+import static groovyx.net.http.Method.POST
+
+buildscript {
+    repositories {
+        mavenRepo(url: 'http://dl.bintray.com/content/bintray/jcenter')
+    }
+    dependencies {
+        classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
+        classpath 'commons-collections:commons-collections:3.2.1'
+    }
+}
+
+apply plugin: 'signing'
+apply plugin: 'maven'
+
+configurations {
+    samples.extendsFrom mainRuntime
+    jdk
+    maven { extendsFrom archives }
+    published { extendsFrom archives, signatures}
+}
+
+signing {
+    required = { gradle.taskGraph.hasTask(uploadPublished) && !version.endsWith("SNAPSHOT") }
+    sign configurations.archives
+}
+
+repositories {
+    mavenRepo url: 'http://dl.bintray.com/shemnon/javafx/'
+    mavenLocal()
+    mavenCentral()
+}
+
+uploadPublished {
+
+    doFirst {
+        // configure repositories in a doFirst so we can late bind the properties
+        checkPasswords()
+        repositories {
+            mavenDeployer {
+                configurePOM(pom)
+                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+                snapshotRepository(url: bintray_api_base_url + '/maven/' + bintray_username + '/' + bintray_repo + '/' + bintray_package ) {
+                    authentication userName: bintray_username, password: bintray_api_key
+                }
+                repository(url: bintray_api_base_url + '/maven/' + bintray_username + '/' + bintray_repo + '/' + bintray_package ) {
+                    authentication userName: bintray_username, password: bintray_api_key
+                }
+            }
+        }
+    }
+    configuration = configurations.published
+}
+
+install {
+    doFirst {
+        configurePOM(repositories.mavenInstaller.pom)
+    }
+    configuration = configurations.published
+}
+
+private configurePOM(def pom) {
+    pom.project {
+        name 'Deck Control'
+        description 'A Node that simpulates a slide deck'
+        url 'https://bitbucket.org/shemnon/deckcontrol'
+        modelVersion '4.0.0'
+        packaging 'jar'
+        scm {
+            connection 'scm:git:https://bitbucket.org/shemnon/deckcontrol.git'
+            developerConnection 'scm:git:git@bitbucket.org:shemnon/deckcontrol.git'
+            url 'https://bitbucket.org/shemnon/deckcontrol'
+        }
+        developers {
+            developer {
+                name 'Danno Ferrin'
+                email 'danno.ferrin@shemnon.com'
+                roles {
+                    role 'author'
+                    role 'developer'
+                }
+            }
+        }
+        licenses {
+            license {
+                name 'The 3-Clause BSD License'
+                url 'http://www.opensource.org/licenses/bsd-license.php'
+                distribution 'repo'
+            }
+        }
+    }
+}
+
+
+
+
+task createBintrayPackage << {
+    def http = getHttpBuilder()
+    http.request(GET, JSON) {
+        uri.path = '/packages/' + bintray_username + '/' + bintray_repo + '/' + bintray_package
+        response.'404' = {
+            http = getHttpBuilder()
+            http.request(POST, JSON) {
+                uri.path = '/packages/' + bintray_username + '/' + bintray_repo
+                body = [name: bintray_package, desc: 'auto', desc_url: 'auto', labels: ['gradle', 'example']]
+
+                response.success = { resp ->
+                    println 'Created!!!'
+                }
+            }
+        }
+    }
+}
+
+
+uploadPublished.dependsOn createBintrayPackage
+
+def getHttpBuilder() {
+    def http = new HTTPBuilder(bintray_api_base_url)
+    http.auth.basic bintray_username, bintray_api_key
+    return http
+}
+
+
+checkPasswords =  {
+    try {
+        def check = [sonatypeUsername, sonatypePassword]
+        println "Using sonatype user $sonatypeUsername"
+    } catch (MissingPropertyException e) {
+        e.printStackTrace()
+        Console console = System.console()
+        console.printf "\n\nIn order to upload to Sonatype we need your username and password.\nEnter a blank username or password to skip upload\n\n"
+        ext.sonatypeUsername = console.readLine("Sonatype Username: ")
+        ext.sonatypePassword = new String(console.readPassword("Sonatype Password: "))
+        if (!sonatypePassword || !sonatypeUsername) {
+            console.printf("\n\nSonatype upload aborted")
+            subprojects {
+                signing {
+                    enabled = false
+                }
+                uploadPublished {
+                    enabled = false
+                }
+            }
+            throw new StopExecutionException()
+        }
+    }
+}