Skip to content

Commit 996e925

Browse files
feat(gradle): publishing to sonatype
1 parent 641b283 commit 996e925

3 files changed

Lines changed: 93 additions & 8 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# sc-file
2+
3+
A library for parsing Supercell compressed file format.
4+
5+
## Publishing
6+
7+
Don't forget to add those properties to your `~/.gradle/gradle.properties`:
8+
9+
```properties
10+
gpr.user=YOUR_GITHUB_USERNAME
11+
gpr.key=YOUR_GITHUB_PUBLISHING_TOKEN
12+
13+
# username and token from https://central.sonatype.com/usertoken
14+
sonatype.username=SONATYPE_USERNAME
15+
sonatype.password=SONATYPE_PASSWORD
16+
17+
# GPG/PGP key
18+
signing.key=-----BEGIN PGP PRIVATE KEY BLOCK----- -----END PGP PRIVATE KEY BLOCK-----\n
19+
signing.password=KEY_PASSWORD
20+
```

build.gradle

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
plugins {
2-
id 'java'
3-
id("maven-publish")
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'signing'
5+
6+
// https://github.com/yananhub/flying-gradle-plugin
7+
id "tech.yanand.maven-central-publish" version "1.3.0"
48
}
59

610
group = 'dev.donutquine'
@@ -21,20 +25,81 @@ test {
2125
useJUnitPlatform()
2226
}
2327

28+
tasks.register("sourcesJar", Jar) {
29+
archiveClassifier.set("sources")
30+
from(sourceSets.main.allSource)
31+
32+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
33+
}
34+
35+
tasks.register("javadocJar", Jar) {
36+
archiveClassifier.set("javadoc")
37+
from(tasks.javadoc)
38+
}
39+
2440
publishing {
2541
repositories {
42+
// GitHub Packages
2643
maven {
27-
name = "GitHubPackages"
44+
name = "github"
2845
url = uri("https://maven.pkg.github.com/danila-schelkov/sc-file")
2946
credentials {
30-
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
31-
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
47+
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME")
48+
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
3249
}
3350
}
3451
}
3552
publications {
36-
gpr(MavenPublication) {
37-
from(components.java)
53+
mavenJava(MavenPublication) {
54+
from components.java
55+
artifact(tasks.named("sourcesJar").get())
56+
artifact(tasks.named("javadocJar").get())
57+
58+
pom {
59+
name = "sc-file"
60+
description = "A library for parsing Supercell compressed file format"
61+
url = "https://github.com/danila-schelkov/sc-file"
62+
63+
licenses {
64+
license {
65+
name = "MIT License"
66+
url = "https://opensource.org/licenses/MIT"
67+
distribution = "repo"
68+
}
69+
}
70+
71+
developers {
72+
developer {
73+
id = "danila-schelkov"
74+
name = "Danila Schelkov"
75+
email = "me@donutquine.dev"
76+
}
77+
}
78+
79+
scm {
80+
url = "https://github.com/danila-schelkov/sc-file"
81+
connection = "scm:git:https://github.com/danila-schelkov/sc-file.git"
82+
developerConnection = "scm:git:ssh://git@github.com/danila-schelkov/sc-file.git"
83+
}
84+
}
3885
}
3986
}
40-
}
87+
}
88+
89+
signing {
90+
useInMemoryPgpKeys(
91+
findProperty("signing.key") as String,
92+
findProperty("signing.password") as String
93+
)
94+
sign publishing.publications.mavenJava
95+
}
96+
97+
import java.nio.charset.StandardCharsets
98+
99+
mavenCentral {
100+
def username = findProperty("sonatype.username") ?: System.getenv("SONATYPE_USERNAME")
101+
def password = findProperty("sonatype.password") ?: System.getenv("SONATYPE_PASSWORD")
102+
103+
def credentials = "${username}:${password}"
104+
authToken = credentials.getBytes(StandardCharsets.UTF_8).encodeBase64().toString()
105+
}

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)