Skip to content

Commit a252ef2

Browse files
committed
Checking in changes to publish to maven central
1 parent b4e92cb commit a252ef2

File tree

2 files changed

+106
-5
lines changed

2 files changed

+106
-5
lines changed

build.gradle

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ apply plugin: 'java'
1212
apply plugin: 'eclipse'
1313
apply plugin: 'maven'
1414
apply plugin: 'maven-publish'
15+
apply plugin: 'signing'
1516

1617
// In this section you declare where to find the dependencies of your project
1718
repositories {
@@ -48,8 +49,7 @@ def pomConfig = {
4849
publishing {
4950

5051
publications {
51-
52-
maven(MavenPublication) {
52+
maven(MavenPublication) {
5353

5454
groupId 'com.microsoft.graph'
5555

@@ -68,10 +68,53 @@ publishing {
6868
}
6969

7070
}
71-
71+
72+
mavenJava(MavenPublication) {
73+
customizePom(pom)
74+
groupId 'com.microsoft.graph'
75+
artifactId 'microsoft-graph'
76+
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"
77+
from components.java
78+
pom.withXml {
79+
def pomFile = file("${project.buildDir}/generated-pom.xml")
80+
writeTo(pomFile)
81+
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
82+
artifact(pomAscFile) {
83+
classifier = null
84+
extension = 'pom.asc'
85+
}
86+
}//pom.withXml
87+
artifact(sourceJar) {
88+
classifier = 'sources'
89+
}
90+
artifact(javadocJar) {
91+
classifier = 'javadoc'
92+
}
93+
project.tasks.signArchives.signatureFiles.each {
94+
artifact(it) {
95+
def matcher = it.file =~/-(sources|javadoc)\.jar\.asc$/
96+
if(matcher.find()){
97+
classifier = matcher.group(1)
98+
}
99+
else{
100+
classifier = null
101+
}
102+
extension = 'jar.asc'
103+
}//artifact
104+
}
105+
}//mavenJava
106+
107+
}//publications
108+
repositories {
109+
maven {
110+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
111+
credentials {
112+
username sonatypeUsername
113+
password sonatypePassword
114+
}
115+
}
72116
}
73-
74-
}
117+
}//publishing
75118

76119
task sourceJar(type: Jar) {
77120
classifier = 'sources'
@@ -147,6 +190,56 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
147190
}
148191

149192
artifacts {
193+
archives jar
150194
archives sourceJar
151195
archives javadocJar
152196
}
197+
198+
signing {
199+
sign configurations.archives
200+
}
201+
202+
def customizePom(pom) {
203+
pom.withXml {
204+
def root = asNode()
205+
206+
// eliminate test-scoped dependencies (no need in maven central POMs)
207+
root.dependencies.removeAll { dep ->
208+
dep.scope == "test"
209+
}
210+
211+
// add all items necessary for maven central publication
212+
root.children().last() + {
213+
resolveStrategy = Closure.DELEGATE_FIRST
214+
215+
description 'Microsoft Graph SDK'
216+
name 'Microsoft Graph Java SDK'
217+
url 'https://github.com/microsoftgraph/msgraph-sdk-java'
218+
organization {
219+
name 'Microsoft'
220+
url 'https://github.com/microsoftgraph/msgraph-sdk-java'
221+
}
222+
issueManagement {
223+
system 'GitHub'
224+
url 'https://github.com/microsoftgraph/msgraph-sdk-java/issues'
225+
}
226+
licenses {
227+
license {
228+
name "MIT License"
229+
url "http://opensource.org/licenses/MIT"
230+
distribution "repo"
231+
}
232+
}
233+
scm {
234+
url 'https://github.com/microsoftgraph/msgraph-sdk-java'
235+
connection 'scm:git:[email protected]:microsoftgraph/msgraph-sdk-java.git'
236+
developerConnection 'scm:git:ssh://[email protected]:microsoftgraph/msgraph-sdk-java.git'
237+
}
238+
developers {
239+
developer {
240+
name 'Mautini'
241+
}
242+
}
243+
}
244+
}
245+
}

gradle.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven
3737
ClientId="CLIENT_ID"
3838
Username="USERNAME"
3939
Password="PASSWORD"
40+
41+
//enter below credentials to publish to maven central
42+
signing.keyId="keyId"
43+
signing.secretKeyRingFile="fileLocation"
44+
signing.password="passphrase"
45+
sonatypeUsername="USERNAME"
46+
sonatypePassword="PASSWORD"
47+

0 commit comments

Comments
 (0)