Skip to content

Commit 09d3e55

Browse files
committed
Update publishing to central portal
1 parent 00835bd commit 09d3e55

File tree

2 files changed

+46
-64
lines changed

2 files changed

+46
-64
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on: [push]
55
jobs:
66
compile:
77
runs-on: ubuntu-latest
8-
98
steps:
109
- name: Checkout repo
1110
uses: actions/checkout@v3
@@ -16,10 +15,6 @@ jobs:
1615
with:
1716
java-version: "11"
1817
architecture: x64
19-
20-
- name: Compile
21-
run: ./gradlew compileJava
22-
2318
test:
2419
needs: [ compile ]
2520
runs-on: ubuntu-latest
@@ -33,16 +28,15 @@ jobs:
3328
with:
3429
java-version: "11"
3530
architecture: x64
36-
3731
- name: Test
3832
run: ./gradlew test
3933
env:
4034
TEST_SQUARE_TOKEN: ${{ secrets.TEST_SQUARE_TOKEN }}
35+
4136
publish:
4237
needs: [ compile ]
4338
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
4439
runs-on: ubuntu-latest
45-
4640
steps:
4741
- name: Checkout repo
4842
uses: actions/checkout@v3
@@ -54,10 +48,10 @@ jobs:
5448
java-version: "11"
5549
architecture: x64
5650

57-
- name: Publish to maven
58-
run: |
59-
./gradlew publish
51+
- name: Publish to Maven Central
52+
run: ./gradlew publish --stacktrace
6053
env:
61-
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
62-
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
63-
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
54+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
55+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
56+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }}
57+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }}

build.gradle

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
plugins {
22
id 'java-library'
3-
id 'maven-publish'
43
id 'com.diffplug.spotless' version '6.11.0'
4+
id 'com.vanniktech.maven.publish' version '0.27.0'
55
}
66

77
repositories {
88
mavenCentral()
9-
maven {
10-
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
11-
}
129
}
1310

1411
dependencies {
@@ -20,7 +17,6 @@ dependencies {
2017
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2118
}
2219

23-
2420
sourceCompatibility = 1.8
2521
targetCompatibility = 1.8
2622

@@ -35,66 +31,58 @@ spotless {
3531
}
3632
}
3733

38-
39-
java {
40-
withSourcesJar()
41-
withJavadocJar()
42-
}
43-
44-
4534
group = 'com.squareup'
46-
4735
version = '45.0.0.20250618'
4836

49-
jar {
50-
dependsOn(":generatePomFileForMavenPublication")
51-
archiveBaseName = "square"
52-
}
53-
54-
sourcesJar {
55-
archiveBaseName = "square"
56-
}
57-
58-
javadocJar {
59-
archiveBaseName = "square"
60-
}
61-
6237
test {
6338
useJUnitPlatform()
6439
testLogging {
6540
showStandardStreams = true
6641
}
6742
}
6843

69-
publishing {
70-
publications {
71-
maven(MavenPublication) {
72-
groupId = 'com.squareup'
73-
artifactId = 'square'
74-
version = '45.0.0.20250618'
75-
from components.java
76-
pom {
77-
licenses {
78-
license {
79-
name = 'MIT'
80-
}
81-
}
82-
scm {
83-
connection = 'scm:git:git://github.com/square/square-java-sdk.git'
84-
developerConnection = 'scm:git:git://github.com/square/square-java-sdk.git'
85-
url = 'https://github.com/square/square-java-sdk'
86-
}
44+
// Configure maven publishing for Central Portal
45+
mavenPublishing {
46+
publishToMavenCentral()
47+
signAllPublications()
48+
49+
coordinates("com.squareup", "square", "$version")
50+
51+
pom {
52+
name = "Square Java SDK"
53+
description = "Official Square Java SDK"
54+
inceptionYear = "2019"
55+
url = "https://github.com/square/square-java-sdk"
56+
57+
licenses {
58+
license {
59+
name = "MIT License"
60+
url = "https://opensource.org/licenses/MIT"
61+
distribution = "repo"
8762
}
8863
}
89-
}
90-
repositories {
91-
maven {
92-
url "$System.env.MAVEN_PUBLISH_REGISTRY_URL"
93-
credentials {
94-
username "$System.env.MAVEN_USERNAME"
95-
password "$System.env.MAVEN_PASSWORD"
64+
65+
developers {
66+
developer {
67+
id = "square"
68+
name = "Square"
69+
url = "https://github.com/square"
9670
}
9771
}
72+
73+
scm {
74+
url = "https://github.com/square/square-java-sdk"
75+
connection = "scm:git:git://github.com/square/square-java-sdk.git"
76+
developerConnection = "scm:git:ssh://[email protected]/square/square-java-sdk.git"
77+
}
9878
}
9979
}
10080

81+
java {
82+
withSourcesJar()
83+
withJavadocJar()
84+
85+
toolchain {
86+
languageVersion = JavaLanguageVersion.of(8)
87+
}
88+
}

0 commit comments

Comments
 (0)