-
Notifications
You must be signed in to change notification settings - Fork 39
/
publish.gradle
120 lines (110 loc) · 3.11 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
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
def buildDirectory = "$buildDir/libs"
def pomFilePath = "$buildDirectory/$project.artifact-$project.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 "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
name "$project.fullname"
email "$project.email"
organization "$project.organization"
organizationUrl "$project.organizationUrl"
}
}
scm {
connection "$project.website"
developerConnection "$project.userwebsite"
url "$project.website"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId "$project.group"
artifactId "$project.artifact"
version "$project.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', "$project.name")
pomNode.appendNode('description', "$project.description")
pomNode.appendNode('url', "$project.website")
pomNode.children().last() + pomConfig
}
artifact "$pomFilePath"
}
}
}
bintray {
user = System.getenv('BINTRAY_USERNAME')
key = System.getenv('BINTRAY_KEY')
publications = ['mavenJava']
pkg {
repo = "$project.repository"
name = "$project.codename"
desc = "$project.description"
websiteUrl = "$project.website"
issueTrackerUrl = "$project.issues"
licenses = ["$project.license"]
vcsUrl = "$project.website"
labels = ['android', 'java', 'arrow']
//noinspection GroovyAssignabilityCheck
version {
name = "$project.version"
desc = "$project.description"
released = new Date()
vcsTag = "$project.website"
mavenCentralSync {
sync = true
user = System.getenv('OSS_USERNAME')
password = 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")
}
}