11plugins {
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
610group = ' 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+
2440publishing {
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+ }
0 commit comments