Skip to content

Commit b29c67f

Browse files
committed
publishing
1 parent 389e804 commit b29c67f

File tree

2 files changed

+120
-3
lines changed

2 files changed

+120
-3
lines changed

AndroidAsync/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ android {
5050
}
5151
}
5252

53-
if (System.getenv().I_AM_KOUSH == 'true') {
54-
apply from: 'https://raw.githubusercontent.com/koush/mvn-repo/master/maven.gradle'
55-
}
53+
apply from: 'maven.gradle'

AndroidAsync/maven.gradle

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// Setup
2+
3+
// 0) Setup your sonatype credentials by editing/creating ~/.gradle/gradle.properties and enter:
4+
// signing.keyId=<HEXADECIMCAL KEY ID RETRIVABLE VIA gpg --list-keys>
5+
// signing.password=<KEY PASSWORD>
6+
// signing.secretKeyRingFile=<PATH TO KEY RING, USUALLY ~/.gnupg/secring.gpg>
7+
// sonatypeUsername=<SONATYPE USERNAME OR WHATEVER YOU USE>
8+
// sonatypePassword=<CORRESPONDING PASSWORD>
9+
10+
// 1) Setup your build.gradle for your android project and add this one line of code which imports this gist:
11+
// apply from: 'https://raw.github.com/koush/mvn-repo/master/maven.gradle'
12+
13+
// 2) gradle clean && gradle build && gradle uploadArchives
14+
15+
// 3) That's it!
16+
17+
18+
apply plugin: 'maven'
19+
apply plugin: 'signing'
20+
21+
22+
afterEvaluate { project ->
23+
String user = null
24+
String repo = null
25+
'git remote -v'.execute(null, project.projectDir).getText().find('.*[email protected]/(.*?)/(.*?) .*?') {
26+
match ->
27+
user = match[1]
28+
repo = match[2]
29+
}
30+
31+
String githubUrl = 'https://api.github.com/repos/' + user + '/' + repo;
32+
if (System.getenv().GITHUB_TOKEN)
33+
githubUrl += '?access_token=' + System.getenv().GITHUB_TOKEN
34+
def repoInfo = new groovy.json.JsonSlurper().parseText(new URL(githubUrl).getText())
35+
36+
def android_manifest
37+
try {
38+
android_manifest = new XmlParser(false, false).parseText(new File(project.projectDir, 'AndroidManifest.xml').getText())
39+
}
40+
catch (e) {
41+
android_manifest = new XmlParser(false, false).parseText(new File(project.projectDir, 'src/main/AndroidManifest.xml').getText())
42+
}
43+
def versionName = android_manifest.'@android:versionName'
44+
def package_name = android_manifest.'@package'
45+
def artifact_id = project.projectDir.getName().toLowerCase()
46+
project.version = versionName
47+
project.group = package_name
48+
49+
uploadArchives {
50+
repositories {
51+
mavenDeployer {
52+
53+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
54+
pom.groupId = package_name
55+
pom.artifactId = artifact_id
56+
pom.version = versionName
57+
58+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
59+
authentication(userName: sonatypeUsername, password: sonatypePassword)
60+
}
61+
62+
pom.project {
63+
name repo
64+
packaging 'jar'
65+
description repoInfo.description
66+
url repoInfo.html_url
67+
68+
scm {
69+
url repoInfo.git_url
70+
connection repoInfo.git_url
71+
developerConnection repoInfo.ssh_url
72+
}
73+
74+
licenses {
75+
license {
76+
name 'The Apache Software License, Version 2.0'
77+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
78+
distribution 'repo'
79+
}
80+
}
81+
82+
developers {
83+
developer {
84+
id user
85+
name user
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
93+
signing {
94+
sign configurations.archives
95+
}
96+
97+
task androidJavadocs(type: Javadoc) {
98+
source = android.sourceSets.main.java.srcDirs
99+
}
100+
101+
task androidJavadocsJar(type: Jar) {
102+
classifier = 'javadoc'
103+
baseName = artifact_id
104+
from androidJavadocs.destinationDir
105+
}
106+
107+
task androidSourcesJar(type: Jar) {
108+
classifier = 'sources'
109+
baseName = artifact_id
110+
from android.sourceSets.main.java.srcDirs
111+
}
112+
113+
artifacts {
114+
// archives packageReleaseJar
115+
archives androidSourcesJar
116+
archives androidJavadocsJar
117+
}
118+
}
119+

0 commit comments

Comments
 (0)