Commits

David Carr committed 6e70412

build: extract most of the gradle logic into scripts

Comments (0)

Files changed (4)

     bintray.jcenter()
 }
 
-apply plugin: 'groovy'
-apply plugin: 'maven'
-apply plugin: 'signing'
-
-group = 'us.carrclan.david.gradle'
-version = '0.2.0-SNAPSHOT'
-ext.isReleaseVersion = !version.endsWith('SNAPSHOT')
-
-sourceCompatibility = 1.6
+apply from: 'gradle/coordinates.gradle'
+apply from: 'gradle/convention.gradle'
+apply from: 'gradle/maven.gradle'
 
 dependencies {
     compile gradleApi()
     testCompile 'cglib:cglib-nodep:2.2.2'
 }
 
-def javaApiUrl = 'http://docs.oracle.com/javase/1.5.0/docs/api/'
-def groovyApiUrl = 'http://groovy.codehaus.org/gapi/'
 def wagonApiUrl = 'https://maven.apache.org/wagon/wagon-provider-api/apidocs/'
 tasks.withType(Javadoc) {
-    options.links(javaApiUrl, groovyApiUrl, wagonApiUrl)
+    options.links(wagonApiUrl)
 }
-
-tasks.withType(JavaCompile) {
-    options.compilerArgs << '-Xlint:-options'
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
-    classifier = 'javadoc'
-    from 'build/docs/javadoc'
-}
-
-task sourcesJar(type: Jar) {
-    from sourceSets.main.allSource
-    classifier = 'sources'
-}
-
-artifacts {
-    archives jar
-    archives javadocJar
-    archives sourcesJar
-}
-
-signing {
-    required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
-    sign configurations.archives
-}
-
-uploadArchives {
-    repositories {
-        mavenDeployer {
-            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-            // TODO: use bintray plugin
-            repository(url: 'https://api.bintray.com/maven/davidmc24/gradle-plugins/jayne-site/') {
-                try {
-                    authentication(userName: bintrayUserName, password: bintrayApiKey)
-                } catch (MissingPropertyException pne) {
-                    // ignore, don't authenticate
-                }
-            }
-            pom {
-                project {
-                    name 'jayne-site'
-                    description 'A Gradle plugin for publishing static HTML websites'
-                    url 'https://bitbucket.org/davidmc24/jayne-site'
-                    licenses {
-                        license {
-                            name 'Apache License, Version 2.0'
-                            url 'http://www.apache.org/licenses/LICENSE-2.0'
-                            distribution 'repo'
-                        }
-                    }
-                    developers {
-                        developer {
-                            id 'davidmc24'
-                            name 'David M. Carr'
-                            email 'david@carrclan.us'
-                            url 'http://david.carrclan.us'
-                        }
-                    }
-                    scm {
-                        connection 'scm:hg:https://bitbucket.org/davidmc24/jayne-site'
-                        url 'https://bitbucket.org/davidmc24/jayne-site'
-                    }
-                }
-            }
-            // Dirty hack for GRADLE-1285
-            pom.withXml { root ->
-                def children = root.asNode().children()
-                def versionIndex = children.indexOf(children.find {it.name().localPart == 'version'})
-                children.add(versionIndex + 1, new Node(null, 'packaging', 'jar'))
-            }
-        }
-    }
-}

gradle/convention.gradle

+ext.isReleaseVersion = !version.endsWith('SNAPSHOT')
+
+apply plugin: 'groovy'
+
+sourceCompatibility = 1.6
+
+tasks.withType(JavaCompile) {
+    options.compilerArgs << '-Xlint:-options' // Suppress warnings about setting older sourceCompatibility
+}
+
+task sourcesJar(type: Jar, description: 'Assembles a jar archive containing the main sources.') {
+    from sourceSets.main.allSource
+    classifier = 'sources'
+}
+
+task javadocJar(type: Jar, dependsOn: javadoc, description: 'Assembles a jar archive containing the javadocs.') {
+    classifier = 'javadoc'
+    from 'build/docs/javadoc'
+}
+
+artifacts {
+    archives javadocJar
+    archives sourcesJar
+}
+
+def javaApiUrl = 'http://docs.oracle.com/javase/1.5.0/docs/api/'
+def groovyApiUrl = 'http://groovy.codehaus.org/gapi/'
+def gradleApiUrl = 'http://www.gradle.org/docs/current/javadoc/'
+tasks.withType(Javadoc) {
+    options.links(javaApiUrl, groovyApiUrl, gradleApiUrl)
+}

gradle/coordinates.gradle

+group = 'us.carrclan.david.gradle'
+version = '0.2.0-SNAPSHOT'

gradle/maven.gradle

+apply plugin: 'maven'
+apply plugin: 'signing'
+
+signing {
+    required { isReleaseVersion && gradle.taskGraph.hasTask('uploadArchives') }
+    sign configurations.archives
+}
+
+uploadArchives {
+    repositories.mavenDeployer {
+        beforeDeployment { org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) }
+
+        // TODO: use bintray plugin
+        repository(url: 'https://api.bintray.com/maven/davidmc24/gradle-plugins/jayne-site/') {
+            try {
+                authentication(userName: bintrayUserName, password: bintrayApiKey)
+            } catch (MissingPropertyException ex) {
+                throw new InvalidUserDataException("Uploading to Bintray requires authentication.  Please configure the credentials with 'bintrayUserName' and 'bintrayApiKey' properties in your gradle.properties file.")
+            }
+        }
+
+        pom {
+            project {
+                name "${project.name}"
+                description 'A Gradle plugin for publishing static HTML websites'
+                url "https://bitbucket.org/davidmc24/${project.name}"
+                licenses {
+                    license {
+                        name 'Apache License, Version 2.0'
+                        url 'http://www.apache.org/licenses/LICENSE-2.0'
+                        distribution 'repo'
+                    }
+                }
+                developers {
+                    developer {
+                        id 'davidmc24'
+                        name 'David M. Carr'
+                        email 'david@carrclan.us'
+                        url 'http://david.carrclan.us'
+                    }
+                }
+                scm {
+                    connection "scm:hg:https://bitbucket.org/davidmc24/${project.name}"
+                    url "https://bitbucket.org/davidmc24/${project.name}"
+                }
+            }
+        }
+    }
+}