@@ -12,12 +12,14 @@ apply plugin: 'java'
1212apply plugin : ' eclipse'
1313apply plugin : ' maven'
1414apply plugin : ' maven-publish'
15+ apply plugin : ' signing'
1516
1617// In this section you declare where to find the dependencies of your project
1718repositories {
1819 // Use jcenter for resolving your dependencies.
1920 // You can declare any Maven/Ivy/file repository here.
2021 jcenter()
22+ mavenCentral()
2123}
2224
2325dependencies {
@@ -68,7 +70,49 @@ publishing {
6870 }
6971
7072 }
71-
73+ mavenJava(MavenPublication ) {
74+ customizePom(pom)
75+ groupId ' com.microsoft.graph'
76+ artifactId ' microsoft-graph'
77+ version " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion}${ mavenArtifactSuffix} "
78+ from components. java
79+ pom. withXml {
80+ def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
81+ writeTo(pomFile)
82+ def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
83+ artifact(pomAscFile) {
84+ classifier = null
85+ extension = ' pom.asc'
86+ }
87+ }
88+ artifact(sourceJar) {
89+ classifier = ' sources'
90+ }
91+ artifact(javadocJar) {
92+ classifier = ' javadoc'
93+ }
94+ project. tasks. signArchives. signatureFiles. each {
95+ artifact(it) {
96+ def matcher = it. file =~ / -(sources|javadoc)\. jar\. asc$/
97+ if (matcher. find()){
98+ classifier = matcher. group(1 )
99+ }
100+ else {
101+ classifier = null
102+ }
103+ extension = ' jar.asc'
104+ }
105+ }
106+ }
107+ }
108+ repositories {
109+ maven {
110+ url = project. property(' mavenCentralUploadUrl' )
111+ credentials {
112+ username = project. property(' sonatypeUsername' )
113+ password = project. property(' sonatypePassword' )
114+ }
115+ }
72116 }
73117
74118}
@@ -147,6 +191,67 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
147191}
148192
149193artifacts {
194+ archives jar
150195 archives sourceJar
151196 archives javadocJar
152197}
198+
199+ signing {
200+ sign configurations. archives
201+ }
202+ tasks. withType(Sign )* . enabled = mavenCentralPublishingEnabled. toBoolean()
203+
204+ def customizePom (pom ) {
205+ pom. withXml {
206+ def root = asNode()
207+
208+ root. dependencies. removeAll { dep ->
209+ dep. scope == " test"
210+ }
211+
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:git://github.com/microsoftgraph/msgraph-sdk-java.git'
236+ developerConnection
' scm:git:ssh://[email protected] :microsoftgraph/msgraph-sdk-java.git' 237+ }
238+ developers {
239+ developer {
240+ name ' Microsoft'
241+ }
242+ }
243+ }
244+ }
245+ }
246+
247+ model {
248+ tasks. generatePomFileForMavenJavaPublication {
249+ destination = file(" $buildDir /generated-pom.xml" )
250+ }
251+ tasks. publishMavenJavaPublicationToMavenLocal {
252+ dependsOn project. tasks. signArchives
253+ }
254+ tasks. publishMavenJavaPublicationToMavenRepository {
255+ dependsOn project. tasks. signArchives
256+ }
257+ }
0 commit comments