1
+ apply plugin : ' maven-publish'
2
+ apply plugin : ' com.jfrog.bintray'
3
+
4
+ /*
5
+ * Gets the version name from the latest Git tag
6
+ */
7
+ def getVersionName = { ->
8
+ try {
9
+ def stdout = new ByteArrayOutputStream ()
10
+ exec {
11
+ commandLine ' git' , ' describe' , ' --abbrev=0' , ' --tags'
12
+ standardOutput = stdout
13
+ }
14
+ return stdout. toString(). trim()
15
+ } catch (ignored) {
16
+ return null
17
+ }
18
+ }
19
+
20
+ publishing {
21
+ publications {
22
+ mavenJava(MavenPublication ) {
23
+ groupId GROUP
24
+
25
+ def versionFromTag = getVersionName()
26
+ if (versionFromTag != null ) {
27
+ // There is a tag existing on the current commit - we can upload to Bintray
28
+ version versionFromTag
29
+
30
+ artifactId ARTIFACT_ID
31
+ artifact " build/outputs/aar/" + project. name + " -release.aar"
32
+ artifact androidJavadocsJar
33
+ artifact androidSourcesJar
34
+ pom. withXml {
35
+ Node root = asNode()
36
+ root. appendNode(' name' , ARTIFACT_ID )
37
+ root. appendNode(' description' , POM_DESCRIPTION )
38
+ root. appendNode(' url' , POM_URL )
39
+
40
+ def issues = root. appendNode(' issueManagement' )
41
+ issues. appendNode(' system' , ' github' )
42
+ issues. appendNode(' url' , ISSUE_URL )
43
+
44
+ def scm = root. appendNode(' scm' )
45
+ scm. appendNode(' url' , POM_SCM_URL )
46
+ scm. appendNode(' connection' , POM_SCM_CONNECTION )
47
+ scm. appendNode(' developerConnection' , POM_SCM_DEV_CONNECTION )
48
+
49
+ def license = root. appendNode(' licenses' ). appendNode(' license' )
50
+ license. appendNode(' name' , POM_LICENCE_NAME )
51
+ license. appendNode(' url' , POM_LICENCE_URL )
52
+ license. appendNode(' distribution' , POM_LICENCE_DIST )
53
+
54
+ def developer = root. appendNode(' developers' ). appendNode(' developer' )
55
+ developer. appendNode(' id' , POM_DEVELOPER_ID )
56
+ developer. appendNode(' name' , POM_DEVELOPER_NAME )
57
+ developer. appendNode(' email' , POM_DEVELOPER_EMAIL )
58
+
59
+ def dependenciesNode = asNode(). appendNode(' dependencies' )
60
+ configurations. compile. allDependencies. each {
61
+ if (! it. name. is(' unspecified' )) {
62
+ def dependencyNode = dependenciesNode. appendNode(' dependency' )
63
+ dependencyNode. appendNode(' groupId' , it. group)
64
+ dependencyNode. appendNode(' artifactId' , it. name)
65
+ dependencyNode. appendNode(' version' , it. version)
66
+ }
67
+ }
68
+ configurations. api. allDependencies. each {
69
+ if (! it. name. is(' unspecified' )) {
70
+ def dependencyNode = dependenciesNode. appendNode(' dependency' )
71
+ dependencyNode. appendNode(' groupId' , it. group)
72
+ dependencyNode. appendNode(' artifactId' , it. name)
73
+ dependencyNode. appendNode(' version' , it. version)
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ bintray {
83
+ user = ' sarevd'
84
+ key = ' c257e694aab9d1d39431ccc70b37ebf149074c93'
85
+ publications = [' mavenJava' ]
86
+
87
+ dryRun = false
88
+ publish = GROUP
89
+ pkg {
90
+ repo = ' inplayer-org'
91
+ name = ARTIFACT_ID
92
+ userOrg = ' inplayer-org'
93
+ websiteUrl = POM_URL
94
+ issueTrackerUrl = ISSUE_URL
95
+ vcsUrl = POM_SCM_URL
96
+ licenses = [' Apache-2.0' ]
97
+ labels = [' aar' , ' android' ]
98
+ version {
99
+ name = getVersionName()
100
+ vcsTag = ' v' + getVersionName()
101
+ }
102
+ }
103
+ }
104
+
105
+ task androidJavadocs (type : Javadoc ) {
106
+ source = android. sourceSets. main. java. srcDirs
107
+ classpath + = project. files(android. getBootClasspath(). join(File . pathSeparator))
108
+ failOnError false
109
+ }
110
+
111
+ task androidJavadocsJar (type : Jar , dependsOn : androidJavadocs) {
112
+ classifier = ' javadoc'
113
+ from androidJavadocs. destinationDir
114
+ }
115
+
116
+ task androidSourcesJar (type : Jar ) {
117
+ classifier = ' sources'
118
+ from android. sourceSets. main. java. sourceFiles
119
+ }
120
+
121
+ task androidJar (type : Jar ) {
122
+ from ' build/intermediates/classes/release'
123
+ }
124
+
125
+ artifacts {
126
+ archives androidSourcesJar
127
+ archives androidJavadocsJar
128
+ archives androidJar
129
+ }
0 commit comments