1
1
plugins {
2
2
id ' kotlin-multiplatform'
3
3
id ' maven-publish'
4
- id ' com.jfrog.bintray ' version ' 1.8.4 '
4
+ id ' signing '
5
5
}
6
6
7
- def GROUP_ID = " com.github.netomi.sudoku"
8
- def ARTIFACT_ID = " sudoku-solver "
7
+ group = " com.github.netomi.sudoku"
8
+ version = " 0.2-SNAPSHOT "
9
9
10
- def BINTRAY_REPOSITORY = " sudoku"
11
- def BINTRAY_ORGANIZATION = " netomi"
12
-
13
- def ISSUE_URL = " https://github.com/netomi/sudoku-solver/issues"
14
- def SITE_URL = " https://github.com/netomi/sudoku-solver"
15
- def VCS_URL = " https://github.com/netomi/sudoku-solver.git"
16
- def LIBRARY_VERSION_NAME = " 0.2-SNAPSHOT"
17
-
18
- group = GROUP_ID
19
- version = LIBRARY_VERSION_NAME
20
- description = ' Sudoku solver library'
10
+ repositories {
11
+ mavenCentral()
12
+ jcenter()
13
+ }
21
14
22
15
ext {
23
16
junitVersion = ' 5.3.2'
@@ -127,52 +120,67 @@ tasks.withType(AbstractTestTask) {
127
120
}
128
121
}
129
122
130
- repositories {
131
- mavenCentral()
132
- jcenter()
133
- }
134
-
135
- afterEvaluate {
136
- project. publishing. publications. all {
137
- // rename artifacts
138
- groupId = GROUP_ID
139
- if (it. name. contains(' metadata' )) {
140
- artifactId = " $ARTIFACT_ID "
141
- } else {
142
- artifactId = " $ARTIFACT_ID -$name "
123
+ // publishing configuration
124
+
125
+ def isSnapshot = version. toString(). endsWith(" SNAPSHOT" )
126
+ def signingKey = project. hasProperty(' signingKey' ) ? project. property(' signingKey' ) : System . getenv(' SIGNING_KEY' )
127
+ def SONATYPE_USERNAME = project. hasProperty(' sonatypeUsername' ) ? project. property(' sonatypeUsername' ) : System . getenv(' SONATYPE_USERNAME' )
128
+ def SONATYPE_PASSWORD = project. hasProperty(' sonatypePassword' ) ? project. property(' sonatypePassword' ) : System . getenv(' SONATYPE_PASSWORD' )
129
+
130
+ publishing {
131
+ publications {
132
+ maven(MavenPublication ) {
133
+ pom {
134
+ description = " Multiplatform sudoku hint solver"
135
+ name = " sudoku-solver"
136
+ url = " https://github.com/netomi/sudoku-solver"
137
+ scm {
138
+ url = " https://github.com/netomi/sudoku-solver"
139
+ connection = " scm:git:git://github.com/netomi/sudoku-solver.git"
140
+ developerConnection = " scm:git:ssh://git@github.com/netomi/sudoku-solver.git"
141
+ }
142
+ licenses {
143
+ license {
144
+ name = ' GNU General Public License, Version 2'
145
+ url = ' https://www.gnu.org/licenses/gpl-2.0.txt'
146
+ distribution = ' repo'
147
+ }
148
+ }
149
+ developers {
150
+ developer {
151
+ id = " netomi"
152
+ name = " Thomas Neidhart"
153
+ url = " https://github.com/netomi"
154
+ }
155
+ }
156
+ }
143
157
}
144
158
}
145
- }
146
159
147
- bintray {
148
- user = project. hasProperty(' bintrayUser' ) ? project. property(' bintrayUser' ) : System . getenv(' BINTRAY_USER' )
149
- key = project. hasProperty(' bintrayApiKey' ) ? project. property(' bintrayApiKey' ) : System . getenv(' BINTRAY_API_KEY' )
150
-
151
- publish = false
152
-
153
- pkg {
154
- repo = BINTRAY_REPOSITORY
155
- name = " $GROUP_ID :$ARTIFACT_ID "
156
- userOrg = BINTRAY_ORGANIZATION
157
- licenses = [' GPL-2.0' ]
158
- vcsUrl = VCS_URL
159
- websiteUrl = SITE_URL
160
- issueTrackerUrl = ISSUE_URL
161
-
162
- version {
163
- name = LIBRARY_VERSION_NAME
164
- vcsTag = LIBRARY_VERSION_NAME
165
- released = new Date ()
160
+ repositories {
161
+ def releaseUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
162
+ def snapshotUrl = " https://oss.sonatype.org/content/repositories/snapshots"
163
+
164
+ maven {
165
+ if (isSnapshot) {
166
+ url = snapshotUrl
167
+ } else {
168
+ url = releaseUrl
169
+ }
170
+
171
+ credentials {
172
+ username = SONATYPE_USERNAME
173
+ password = SONATYPE_PASSWORD
174
+ }
166
175
}
167
176
}
168
177
}
169
178
170
- bintrayUpload. doFirst {
171
- publications = publishing. publications. collect {
172
- it. name
173
- }. findAll {
174
- it != " kotlinMultiplatform"
179
+ signing {
180
+ def isRequired = ! isSnapshot
181
+
182
+ if (isRequired) {
183
+ useInMemoryPgpKeys(signingKey, " " )
184
+ sign(publishing. publications)
175
185
}
176
186
}
177
-
178
- bintrayUpload. dependsOn publishToMavenLocal
0 commit comments