-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle
122 lines (111 loc) · 3.66 KB
/
publish.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
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
import java.text.SimpleDateFormat
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
def buildDirectory = "$buildDir/libs"
def pomFilePath = "$buildDirectory/$APP_ARTIFACT-$APP_VERSION" + ".pom"
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
//https://maven.apache.org/guides/mini/guide-central-repository-upload.html
//http://central.sonatype.org/pages/requirements.html#a-complete-example-pom
//https://medium.com/@vyarus/the-hard-way-to-maven-central-c9e16d163acc#.t0evkiaet
def pomConfig = {
licenses {
license {
name "$LICENSE_NAME"
url "$LICENSE_URL"
distribution "repo"
}
}
developers {
developer {
name "$DEVELOPER_NAME"
email "$DEVELOPER_EMAIL"
organization "$APP_GROUP"
organizationUrl "$DEVELOPER_URL"
}
}
scm {
connection "$APP_WEBSITE"
developerConnection "$DEVELOPER_URL"
url "$APP_WEBSITE"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId "$APP_GROUP"
artifactId "$APP_ARTIFACT"
version "$APP_VERSION"
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def pomNode = asNode()
//Clean up useless stuff in order to organize it
pomNode.remove(pomNode.get("packaging"))
//Add the information
pomNode.appendNode('packaging', 'jar')
pomNode.appendNode('name', "$APP_ARTIFACT")
pomNode.appendNode('description', "$APP_DESCRIPTION")
pomNode.appendNode('url', "$APP_WEBSITE")
pomNode.children().last() + pomConfig
}
artifact "$pomFilePath"
}
}
}
bintray {
user = hasProperty('BINTRAY_USER') ? getProperty('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = hasProperty('BINTRAY_KEY') ? getProperty('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
publications = ['mavenJava']
pkg {
repo = "$APP_REPOSITORY"
name = "$APP_ARTIFACT"
desc = "$APP_DESCRIPTION"
websiteUrl = "$APP_WEBSITE"
issueTrackerUrl = "$APP_ISSUES"
licenses = ["$LICENSE"]
vcsUrl = "$APP_WEBSITE"
labels = ['android', 'java', 'toolbelt']
//noinspection GroovyAssignabilityCheck
version {
name = "$APP_VERSION"
desc = "$APP_DESCRIPTION"
released = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ", Locale.ENGLISH).format(new Date())
vcsTag = "$APP_WEBSITE"
mavenCentralSync {
sync = true
user = hasProperty('OSS_USERNAME') ? getProperty('OSS_USERNAME') : System.getenv('OSS_USERNAME')
password = hasProperty('OSS_KEY') ? getProperty('OSS_KEY') : System.getenv('OSS_KEY')
close = '1'
}
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
//noinspection GrUnresolvedAccess
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
task installToLocalRepo(dependsOn: ['publishMavenJavaPublicationToMavenLocal']) {}
model {
tasks.generatePomFileForMavenJavaPublication {
pomDir = file("$pomFilePath")
destination = file("$pomFilePath")
}
}