forked from karottenreibe/assertk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.gradle
More file actions
142 lines (123 loc) · 3.52 KB
/
publish.gradle
File metadata and controls
142 lines (123 loc) · 3.52 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
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'me.tatarka.gradle.pom'
def isAndroid = plugins.hasPlugin('com.android.library')
ext {
pomFile = file("${project.buildDir}/generated-pom.xml")
isReleaseVersion = !(project.version =~ /-SNAPSHOT$/)
}
if (isAndroid) {
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
}
}
task javadocsJar(type: Jar) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
if (isAndroid) {
from android.sourceSets.main.java.srcDirs
} else {
from sourceSets.main.allSource
}
}
artifacts {
archives sourcesJar
archives javadocsJar
}
signing {
required { signatory != null && project.ext.isReleaseVersion }
sign configurations.archives
}
def siteUrl = 'https://github.com/evant/assertk'
def gitUrl = 'https://github.com/evant/assertk.git'
pom {
name project.name
if (isAndroid) {
packaging 'aar'
}
description 'assertions for kotlin inspired by assertj'
url siteUrl
scm {
url siteUrl
connection gitUrl
developerConnection gitUrl
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'evant'
name 'Evan Tatarka'
}
}
}
publishing {
repositories {
maven {
if (project.ext.isReleaseVersion) {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
} else {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
credentials {
username = project.findProperty('sonatype.username')
password = project.findProperty('sonatype.password')
}
}
}
publications {
lib(MavenPublication) {
if (isAndroid) {
artifact "$buildDir/outputs/aar/${project.name}-release.aar"
} else {
from components.java
}
artifact sourcesJar
artifact javadocsJar
if (signing.required) {
// Sign the artifacts.
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-?(?<classifier>sources|javadoc)?\.(?<extension>jar|aar)\.asc$/
if (matcher.find()) {
classifier = matcher.group('classifier')
extension = matcher.group('extension') + '.asc'
}
}
}
}
}
}
}
if (signing.required) {
project.afterEvaluate {
// Sign the pom.xml.
publishing.publications.lib(MavenPublication) {
pom.withXml {
writeTo(project.ext.pomFile)
def pomAscFile = signing.sign(project.ext.pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
project.ext.pomFile.delete()
}
}
}
}
model {
tasks.publishLibPublicationToMavenLocal {
dependsOn(project.tasks.signArchives)
}
tasks.publishLibPublicationToMavenRepository {
dependsOn(project.tasks.signArchives)
}
}