-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpublish.gradle
111 lines (101 loc) · 3.94 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
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'maven-publish'
if (!project.tasks.findByName('sourcesJar')) {
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (pluginManager.hasPlugin('com.android.library')) {
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.kotlin.srcDirs
}
}
}
task dokkaJar(type: Jar) {
archiveClassifier.set('javadoc')
from dokkaHtml
}
artifacts {
archives dokkaJar
archives sourcesJar
}
afterEvaluate {
publishing {
repositories {
maven {
if (rootProject.file('secure.properties').exists()) {
def securePropertiesFile = rootProject.file('secure.properties')
def secureProperties = new Properties()
secureProperties.load(new FileInputStream(securePropertiesFile))
def releasesUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
def snapshotsUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = version.toString().endsWith("SNAPSHOT") ? snapshotsUrl : releasesUrl
credentials {
username = secureProperties.sonatypeUserName
password = secureProperties.sonatypeUserPassword
}
} else {
println("File secure.properties is not exist. Only local maven publishing available.")
}
}
}
if (!pluginManager.hasPlugin('org.jetbrains.kotlin.multiplatform')) {
publications {
release(MavenPublication) {
if (pluginManager.hasPlugin('com.android.library')) {
from components.release
} else {
from components.java
}
artifact sourcesJar
artifactId = project.name
}
}
}
publications.all {
artifact dokkaJar
pom.withXml {
def root = asNode()
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
description "VisualFSM - Kotlin Multiplatform library for FSM with visualization and analysis tools"
name project.name
url "https://github.com/Kontur-Mobile/visualfsm"
licenses {
license {
name "MIT License"
url "https://raw.githubusercontent.com/Kontur-Mobile/VisualFSM/main/LICENSE"
}
}
scm {
url "https://github.com/Kontur-Mobile/visualfsm"
connection "scm:git:git://github.com/Kontur-Mobile/visualfsm.git"
developerConnection "scm:git:git://github.com/Kontur-Mobile/visualfsm.git"
}
developers {
developer {
id "skbkontur"
name "SKB Kontur"
}
}
}
}
}
}
if (rootProject.file('secure.properties').exists()) {
plugins.apply('signing')
def signingTasks = tasks.withType(Sign)
// Workaround for https://github.com/gradle/gradle/issues/26091 and https://youtrack.jetbrains.com/issue/KT-46466
tasks.withType(AbstractPublishToMaven).configureEach {
dependsOn(signingTasks)
}
signing {
if (pluginManager.hasPlugin('org.jetbrains.kotlin.multiplatform')) {
publishing.publications.all {
sign it
}
} else {
sign publishing.publications.release
}
}
}
}