-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpublish.gradle
More file actions
147 lines (126 loc) · 4.46 KB
/
publish.gradle
File metadata and controls
147 lines (126 loc) · 4.46 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
apply plugin: 'maven-publish'
apply plugin: 'signing'
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
group = POM_GROUP_ID
version = POM_VERSION
def getSonatypeUserName() {
return hasProperty('SONATYPE_USERNAME') ? SONATYPE_USERNAME : ''
}
def getSonatypePassword() {
return hasProperty('SONATYPE_PASSWORD') ? SONATYPE_PASSWORD : ''
}
def plugins = project.getPlugins()
if (plugins.hasPlugin('com.android.library')) {
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from android.sourceSets.main.java.source
}
} else if (plugins.hasPlugin('java')) {
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
} else if (plugins.hasPlugin('java-library')) {
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
afterEvaluate {
def cleanTask = project.tasks.findByName('clean')
def assembleTask = project.tasks.findByName('assemble')
def publishTask = project.tasks.findByName('publish')
if (cleanTask && assembleTask && publishTask) {
assembleTask.dependsOn(cleanTask)
publishTask.dependsOn(assembleTask)
def publishLocalTask = project.tasks.findByName('publishToMavenLocal')
if (publishLocalTask) {
publishLocalTask.dependsOn(assembleTask)
}
}
publishing {
publications {
uploadArchives(MavenPublication) {
artifacts = [javadocJar, sourcesJar]
if (components.hasWithName('java')) {
from components.java
} else if (components.hasWithName('java-library')) {
from components.java
} else if (components.hasWithName('release')) {
from components.release
}
groupId = POM_GROUP_ID
artifactId = POM_ARTIFACT_ID
version = POM_VERSION
pom {
name = POM_NAME
packaging = POM_PACKAGING
url = POM_URL
description = POM_PACKAGING
scm {
url = POM_URL
connection = POM_GIT_URL
developerConnection = POM_GIT_URL
}
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
email = POM_DEVELOPER_EMAIL
}
}
}
}
}
repositories {
maven {
name 'MavenCentral'
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username getSonatypeUserName()
password getSonatypePassword()
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
sign publishing.publications.uploadArchives
}
}