@@ -11,24 +11,21 @@ buildscript {
11
11
}
12
12
dependencies {
13
13
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'
15
14
}
16
15
}
17
16
18
17
plugins {
19
18
id ' java'
19
+ id ' maven-publish'
20
+ id ' signing'
20
21
}
21
22
22
23
apply plugin : ' com.github.sherter.google-java-format'
23
- apply plugin : ' com.bmuschko.nexus'
24
24
25
25
repositories {
26
26
mavenCentral()
27
- }
28
-
29
- project. configurations. configure {
30
- " sonatype" () {
31
- extendsFrom archives
27
+ maven {
28
+ url ' https://oss.sonatype.org/content/repositories/snapshots'
32
29
}
33
30
}
34
31
@@ -64,72 +61,60 @@ jar {
64
61
}
65
62
}
66
63
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
+ }
114
78
}
115
-
116
- scm {
117
- url " [email protected] :newrelic/java-aws-lambda.git"
118
- connection " scm:git:[email protected] :newrelic/ java-aws-lambda.git "
79
+ }
80
+ publications {
81
+ register( " mavenJava " , MavenPublication . class) {
82
+ from(components[ " java" ])
119
83
}
120
-
121
- developers {
122
- developer {
123
- id ' newrelic'
124
- name ' New Relic'
125
-
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
+
102
+ }
103
+ }
104
+ scm {
105
+ url
. set(
" [email protected] :newrelic/java-aws-lambda.git" )
106
+ connection
. set(
" scm:[email protected] :newrelic/java-aws-lambda.git" )
107
+ }
126
108
}
127
109
}
128
110
}
129
111
}
130
112
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