Xavier Ducrohet | 1584794 | 2013-12-04 10:34:40 -0800 | [diff] [blame] | 1 | apply plugin: 'signing' |
| 2 | |
| 3 | def getVersion() { |
| 4 | if (project.has("release")) { |
| 5 | return project.ext.baseVersion |
| 6 | } |
| 7 | |
| 8 | return project.ext.baseVersion + '-SNAPSHOT' |
| 9 | } |
| 10 | |
| 11 | version = getVersion() |
| 12 | |
| 13 | task publishLocal(type: Upload) { |
| 14 | configuration = configurations.archives |
| 15 | repositories { |
| 16 | mavenDeployer { |
| 17 | repository(url: uri("$rootProject.ext.androidHostOut/repo")) |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | project.ext.sonatypeUsername = hasProperty('sonatypeUsername') ? sonatypeUsername : "" |
| 23 | project.ext.sonatypePassword = hasProperty('sonatypePassword') ? sonatypePassword : "" |
| 24 | |
| 25 | uploadArchives { |
| 26 | repositories { |
| 27 | mavenDeployer { |
| 28 | beforeDeployment { MavenDeployment deployment -> |
| 29 | if (!project.has("release")) { |
| 30 | throw new StopExecutionException("uploadArchives must be called with the release.gradle init script") |
| 31 | } |
| 32 | |
| 33 | if (project.ext.sonatypeUsername.length() == 0 || project.ext.sonatypePassword.length() == 0) { |
| 34 | throw new StopExecutionException("uploadArchives cannot be called without sonatype username and password") |
| 35 | } |
| 36 | |
| 37 | signing.signPom(deployment) |
| 38 | } |
| 39 | |
| 40 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { |
| 41 | authentication(userName: project.ext.sonatypeUsername, password: project.ext.sonatypePassword) |
| 42 | } |
| 43 | |
| 44 | pom.project { |
| 45 | name project.ext.pomName |
| 46 | description project.ext.pomDesc |
| 47 | url 'http://tools.android.com' |
| 48 | inceptionYear '2007' |
| 49 | |
| 50 | licenses { |
| 51 | license { |
| 52 | name 'The Apache Software License, Version 2.0' |
| 53 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 54 | distribution 'repo' |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | scm { |
| 59 | url 'https://android.googlesource.com/platform/tools/build' |
| 60 | connection 'git://android.googlesource.com/platform/tools/build.git' |
| 61 | } |
| 62 | developers { |
| 63 | developer { |
| 64 | name 'The Android Open Source Project' |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // custom tasks for creating source/javadoc jars |
| 73 | task sourcesJar(type: Jar, dependsOn:classes) { |
| 74 | classifier = 'sources' |
| 75 | from sourceSets.main.allSource |
| 76 | } |
| 77 | |
| 78 | // add source jar tasks as artifacts |
| 79 | artifacts { |
| 80 | archives jar |
| 81 | archives sourcesJar |
| 82 | } |
| 83 | |
| 84 | signing { |
| 85 | required { project.has("release") && gradle.taskGraph.hasTask("uploadArchives") } |
| 86 | sign configurations.archives |
| 87 | } |