Skip to content

Commit 73976c3

Browse files
committed
feat: migrate to codeartifact
1 parent 6822535 commit 73976c3

2 files changed

Lines changed: 31 additions & 99 deletions

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@ jobs:
1818
with:
1919
java-version: '11'
2020
distribution: 'zulu'
21+
- name: Login to CodeArtifact
22+
run: |
23+
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \
24+
--domain ${{ vars.CODEARTIFACT_DOMAIN }} \
25+
--domain-owner ${{ vars.CODEARTIFACT_DOMAIN_OWNER }} \
26+
--region ${{ env.AWS_REGION }} \
27+
--query authorizationToken \
28+
--output text)
29+
cat <<EOS > gradle.properties
30+
mavenUrl=${{ vars.CODEARTIFACT_DOMAIN }}-${{ vars.CODEARTIFACT_DOMAIN_OWNER }}.d.codeartifact.${{ env.AWS_REGION }}.amazonaws.com/maven/java
31+
mavenUser=aws
32+
mavenPassword=$CODEARTIFACT_AUTH_TOKEN
33+
EOS
2134
- name: Grant execute permission for gradlew
2235
run: chmod +x gradlew
2336
- name: Build with Gradle
2437
run: ./gradlew build
2538
- name: Publish with Gradle
26-
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
27-
env:
28-
MAVEN_CENTRAL_USERTOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERTOKEN_USERNAME }}
29-
MAVEN_CENTRAL_USERTOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_USERTOKEN_PASSWORD }}
30-
MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }}
39+
run: ./gradlew publish
40+

build.gradle

Lines changed: 16 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,23 @@
1-
import aQute.bnd.gradle.Bundle
2-
import io.github.gradlenexus.publishplugin.NexusRepository
3-
4-
buildscript {
5-
repositories {
6-
mavenCentral()
7-
}
8-
dependencies {
9-
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:6.4.0'
10-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
11-
}
12-
}
131
plugins {
14-
id 'net.researchgate.release' version '3.0.2'
15-
id 'com.github.hierynomus.license' version '0.16.1'
2+
id 'java-library'
163
id 'maven-publish'
17-
id 'signing'
18-
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
194
}
205

21-
apply plugin: 'java'
22-
apply plugin: 'idea'
23-
apply plugin: 'biz.aQute.bnd.builder'
24-
apply plugin: 'maven-publish'
25-
26-
276
// The upstream project build releases seem to be compiled with Java 11 so keeping compatibility so that our changes can be applied to the upstream project
28-
compileJava {
7+
tasks.named('compileJava', JavaCompile) {
298
options.release = 11
309
}
31-
compileTestJava {
10+
tasks.named('compileTestJava', JavaCompile) {
3211
options.release = 11
3312
}
3413

35-
// custom tasks for creating source/javadoc jars
36-
tasks.register('sourcesJar', Jar) {
37-
dependsOn classes
38-
archiveClassifier = 'sources'
39-
from sourceSets.main.allSource
40-
}
41-
42-
tasks.register('javadocJar', Jar) {
43-
dependsOn javadoc
44-
archiveClassifier = 'javadoc'
45-
from javadoc.destinationDir
46-
}
47-
48-
release {
49-
tagTemplate = 'v${version}'
50-
failOnPublishNeeded = false
51-
failOnCommitNeeded = false
52-
}
53-
5414
repositories {
55-
mavenCentral()
56-
}
57-
58-
gradle.projectsEvaluated {
59-
tasks.withType(JavaCompile).tap {
60-
configureEach {
61-
doLast {
62-
options.compilerArgs += "-parameters"
63-
}
15+
maven {
16+
name = 'codeartifact'
17+
url = uri("$mavenUrl")
18+
credentials {
19+
username = "$mavenUser"
20+
password = "$mavenPassword"
6421
}
6522
}
6623
}
@@ -82,7 +39,9 @@ dependencies {
8239
testImplementation 'org.mockito:mockito-core:2.+'
8340
}
8441

85-
test.useTestNG()
42+
tasks.named('test') {
43+
useTestNG()
44+
}
8645

8746
publishing {
8847
publications {
@@ -92,9 +51,6 @@ publishing {
9251
artifactId project.name
9352
version project.version
9453

95-
artifact sourcesJar
96-
artifact javadocJar
97-
9854
pom.withXml {
9955
asNode().children().last() + {
10056
resolveStrategy = Closure.DELEGATE_FIRST
@@ -154,50 +110,16 @@ publishing {
154110

155111
repositories {
156112
maven {
157-
url 'https://repo.nos.to/content/repositories/NostoDependencies/'
113+
name = 'codeartifact'
114+
url = uri("$mavenUrl")
158115
credentials {
159-
username = project.hasProperty('mavenUser') ? project.mavenUser : ""
160-
password = project.hasProperty('mavenPassword') ? project.mavenPassword : ""
116+
username = "$mavenUser"
117+
password = "$mavenPassword"
161118
}
162119
}
163120
}
164121
}
165122

166-
tasks.register('publishToNostoRepo') {
167-
dependsOn 'publishMavenPublicationToMavenRepository'
168-
}
169-
gradle.taskGraph.whenReady { taskGraph ->
170-
if (taskGraph.hasTask(':publishToNostoRepo')) {
171-
if (!project.hasProperty('mavenUser') || !project.hasProperty('mavenPassword')) {
172-
throw new GradleException("mavenUser and mavenPassword must be defined for publishToNostoRepo task")
173-
}
174-
}
175-
}
176-
177-
178-
afterReleaseBuild.dependsOn nexusPublishing
179-
180-
nexusPublishing {
181-
repositories {
182-
sonatype {
183-
username = System.getenv("MAVEN_CENTRAL_USERTOKEN_USERNAME")
184-
password = System.getenv("MAVEN_CENTRAL_USERTOKEN_PASSWORD")
185-
}
186-
}
187-
}
188-
189-
// to publish to local maven repo skip signing: ./gradlew publishToMavenLocal -x signGraphqlJavaPublication
190-
signing {
191-
required = { !version.endsWith("nosto") }
192-
def signingKey = System.getenv("MAVEN_CENTRAL_PGP_KEY")
193-
useInMemoryPgpKeys(signingKey, "")
194-
sign publishing.publications
195-
}
196-
197-
tasks.register('bundle', Bundle) {
198-
from sourceSets.main.output
199-
}
200-
201123
wrapper {
202124
gradleVersion = '8.3'
203125
}

0 commit comments

Comments
 (0)