@@ -11,24 +11,21 @@ buildscript {
1111 }
1212 dependencies {
1313 classpath " gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8"
14- classpath ' com.bmuschko:gradle-nexus-plugin:2.3.1'
1514 }
1615}
1716
1817plugins {
1918 id ' java'
19+ id ' maven-publish'
20+ id ' signing'
2021}
2122
2223apply plugin : ' com.github.sherter.google-java-format'
23- apply plugin : ' com.bmuschko.nexus'
2424
2525repositories {
2626 mavenCentral()
27- }
28-
29- project. configurations. configure {
30- " sonatype" () {
31- extendsFrom archives
27+ maven {
28+ url ' https://oss.sonatype.org/content/repositories/snapshots'
3229 }
3330}
3431
@@ -64,72 +61,60 @@ jar {
6461 }
6562}
6663
67- task uploadSonatype (type : Upload ) {
68- configuration = configurations. sonatype
69- uploadDescriptor = true
70- }
71-
72- task customSourcesJar (type : Jar ) {
73- classifier = ' sources'
74- from(projectDir) { include " README.md" }
75- from(sourceSets. main. allSource)
76-
77- manifest {
78- attributes ' Implementation-Title' : ' AWS Lambda OpenTracing Java SDK Sources' ,
79- ' Implementation-Version' : project. version,
80- ' Created-By' : ' New Relic, Inc' ,
81- ' Built-Date' : new Date (),
82- ' Specification-Version' : project. version,
83- ' Build-Id' : System . getProperty(' BUILD_ID' ) || " None"
84- }
85- }
86-
87- artifacts {
88- archives customSourcesJar
89- }
90-
91- extraArchive {
92- sources = false
93- }
94-
95- nexus {
96- sign = true
97- configuration = " sonatype"
98- }
99-
100- uploadSonatype. doFirst {
101- configuration. artifacts. each {
102- println (project. name + " uploading: " + it)
103- }
104- }
105-
106- def customizePom (pom , nameIn , descriptionIn ) {
107- pom. project {
108- url ' https://newrelic.com/'
109- name nameIn
110- description descriptionIn
111-
112- licenses {
113- license { url ' https://github.com/newrelic/java-aws-lambda/blob/master/LICENSE' }
64+ publishing {
65+ repositories {
66+ maven {
67+ def releasesRepoUrl = uri(" https://oss.sonatype.org/service/local/staging/deploy/maven2/" )
68+ def snapshotsRepoUrl = uri(" https://oss.sonatype.org/content/repositories/snapshots/" )
69+ if (version. toString(). endsWith(" SNAPSHOT" )) {
70+ url = snapshotsRepoUrl
71+ } else {
72+ url = releasesRepoUrl
73+ }
74+ credentials {
75+ username = System . getenv(" SONATYPE_USERNAME" )
76+ password = System . getenv(" SONATYPE_PASSWORD" )
77+ }
11478 }
115-
116- scm {
117- url " git@github.com:newrelic/java-aws-lambda.git "
118- connection " scm:git:git@github.com:newrelic/ java-aws-lambda.git "
79+ }
80+ publications {
81+ register( " mavenJava " , MavenPublication . class) {
82+ from(components[ " java" ])
11983 }
120-
121- developers {
122- developer {
123- id ' newrelic'
124- name ' New Relic'
125- email ' support@newrelic.com'
84+ // customize all publications here
85+ withType(MavenPublication . class) {
86+ pom {
87+ name. set(project. name)
88+ description. set(" SDK that provides open tracing instrumentation for AWS Lambda" )
89+ url. set(" https://github.com/newrelic/java-aws-lambda" )
90+ licenses {
91+ license {
92+ name. set(" The Apache License, Version 2.0" )
93+ url. set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
94+ distribution. set(" repo" )
95+ }
96+ }
97+ developers {
98+ developer {
99+ id. set(" newrelic" )
100+ name. set(" New Relic" )
101+ email. set(" opensource@newrelic.com" )
102+ }
103+ }
104+ scm {
105+ url. set(" git@github.com:newrelic/java-aws-lambda.git" )
106+ connection. set(" scm:git@github.com:newrelic/java-aws-lambda.git" )
107+ }
126108 }
127109 }
128110 }
129111}
130112
131- // For external deploys (e.g. - release)
132- modifyPom { pom ->
133- customizePom(pom, ' AWS Lambda OpenTracing Java SDK' ,
134- ' OpenTracing Java SDK for instrumenting AWS Lambda functions.' )
135- }
113+ signing {
114+ def signingKeyId = findProperty(" signingKeyId" )
115+ def signingKey = findProperty(" signingKey" )
116+ def signingPassword = findProperty(" signingPassword" )
117+ useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
118+ setRequired({ gradle. taskGraph. hasTask(" uploadArchives" ) })
119+ sign publishing. publications[" mavenJava" ]
120+ }
0 commit comments