/
publish-mavencentral.gradle
94 lines (78 loc) 路 2.83 KB
/
publish-mavencentral.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
apply plugin: 'maven-publish'
apply plugin: 'signing'
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
properties.each { name, value -> ext[name] = value }
group = publishedGroupId
version = libraryVersion
task sourcesJar(type: Jar) {
from sourceSets.main.kotlin.srcDirs
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
publishing {
publications {
release(MavenPublication) {
groupId = publishedGroupId
artifactId = artifact
version = libraryVersion
artifact("$buildDir/libs/${artifact}-${version}.jar")
artifact sourcesJar
artifact javadocJar
pom {
name = artifact
description = 'Cicerone is a lightweight library that makes the navigation in an Android app easy.'
url = 'https://github.com/terrakok/Cicerone'
licenses {
license {
name = "MIT"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
id = 'terrakok'
name = 'Konstantin Tskhovrebov'
email = 'terrakok@gmail.com'
}
}
scm {
developerConnection = 'scm:git:ssh://github.com/terrakok/Cicerone.git'
url = 'https://github.com/terrakok/Cicerone'
}
// A slightly hacky fix so that your POM will include any transitive dependencies
// that your library builds upon
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
project.configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
maven {
name = "sonatype"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
signing {
sign publishing.publications
}
tasks.getByName("publishReleasePublicationToSonatypeRepository").dependsOn("assemble", "sourcesJar", "javadocJar")