@@ -5,7 +5,6 @@ def isReleaseBuild() {
55 return VERSION_NAME . contains(" SNAPSHOT" ) == false
66}
77
8-
98def getDestUrl () {
109 if (isReleaseBuild()) {
1110 return " s3://android-maven/releases"
@@ -14,39 +13,77 @@ def getDestUrl() {
1413 }
1514}
1615
16+ /**
17+ * 'type: Javadoc' doesn't define a parameter but rather a type of the task
18+ * There are about 40 different types available in docs.
19+ *
20+ * @see {https://docs.gradle.org/3.3/dsl/org.gradle.api.Task.html}
21+ *
22+ * @note Kotlin doesn't define javadoc but dokkaJavadoc using DokkaTask. This implementation
23+ * will probably always return empty javadoc for kotlin files.
24+ */
25+ task androidJavadocs (type : Javadoc ) {
26+ source = android. sourceSets. main. java. srcDirs
27+ }
28+ task androidJavadocsJar (type : Jar ) {
29+ classifier = ' javadoc'
30+ from androidJavadocs. destinationDir
31+ }
32+ task androidSourcesJar (type : Jar ) {
33+ classifier = ' sources'
34+ from android. sourceSets. main. java. srcDirs
35+ }
36+
37+ artifacts {
38+ archives androidSourcesJar
39+ archives androidJavadocsJar
40+ }
1741
42+
43+ // publishing part is defined in maven-publish and is run only during :publish
1844publishing {
1945 publications {
20- aar(MavenPublication ) { // Publish aar knihovnu
46+ // aar here is our custom publication name
47+ aar(MavenPublication ) {
2148 groupId GROUP
2249 version = VERSION_NAME
2350 artifactId POM_ARTIFACT_ID
2451
25- // Tell maven to prepare the generated "*.aar" file for publishing
26- artifact(" $buildDir /outputs/aar/${ project.getName()} -release.aar" )
52+ // This file is generated by previous :assemble command
53+ artifact " $buildDir /outputs/aar/${ project.getName()} -release.aar"
54+ // These files are generated by tasks defined above during :publish
55+ artifact androidSourcesJar
56+ artifact androidJavadocsJar
57+
58+ // pom.withXml lets us tweak the POM file before publishing
2759 pom. withXml {
28- // Creating additional node for dependencies
60+ // Create additional node for dependencies
2961 def dependenciesNode = asNode(). appendNode(' dependencies' )
3062
31- // Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile)
63+ // Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile)
3264 def configurationNames = [" releaseCompile" , ' compile' ]
3365
3466 configurationNames. each { configurationName ->
35- configurations[configurationName]. allDependencies. each {
36- if (it. group != null && it. name != null && it. version != null && it. version != ' unspecified' ) {
37- def dependencyNode = dependenciesNode. appendNode(' dependency' )
38- dependencyNode. appendNode(' groupId' , it. group)
39- dependencyNode. appendNode(' artifactId' , it. name)
40- dependencyNode. appendNode(' version' , it. version)
41-
42- // If there are any exclusions in dependency
43- if (it. excludeRules. size() > 0 ) {
44- def exclusionsNode = dependencyNode. appendNode(' exclusions' )
45- it. excludeRules. each { rule ->
46- def exclusionNode = exclusionsNode. appendNode(' exclusion' )
47- exclusionNode. appendNode(' groupId' , rule. group)
48- exclusionNode. appendNode(' artifactId' , rule. module)
49- }
67+ configurations[configurationName]. allDependencies. each { Dependency dependency ->
68+
69+ if (dependency. group == null ||
70+ dependency. name == null ||
71+ dependency. version == null ||
72+ dependency. version == ' unspecified' )
73+ return // ignore invalid dependencies
74+
75+ def dependencyNode = dependenciesNode. appendNode(' dependency' )
76+ dependencyNode. appendNode(' groupId' , dependency. group)
77+ dependencyNode. appendNode(' artifactId' , dependency. name)
78+ dependencyNode. appendNode(' version' , dependency. version)
79+
80+ // If there are any exclusions in dependency
81+ if (dependency. excludeRules. size() > 0 ) {
82+ def exclusionsNode = dependencyNode. appendNode(' exclusions' )
83+ dependency. excludeRules. each { rule ->
84+ def exclusionNode = exclusionsNode. appendNode(' exclusion' )
85+ exclusionNode. appendNode(' groupId' , rule. group)
86+ exclusionNode. appendNode(' artifactId' , rule. module)
5087 }
5188 }
5289 }
0 commit comments