@@ -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 {
@@ -48,8 +50,7 @@ def pomConfig = {
4850publishing {
4951
5052 publications {
51-
52- maven(MavenPublication ) {
53+ maven(MavenPublication ) {
5354
5455 groupId ' com.microsoft.graph'
5556
@@ -68,9 +69,51 @@ publishing {
6869 }
6970
7071 }
71-
72+
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 " https://oss.sonatype.org/content/repositories/snapshots"
111+ credentials {
112+ username = project. property(' sonatypeUsername' )
113+ password = project. property(' sonatypePassword' )
114+ }
115+ }
72116 }
73-
74117}
75118
76119task sourceJar (type : Jar ) {
@@ -147,6 +190,66 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
147190}
148191
149192artifacts {
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+ root. dependencies. removeAll { dep ->
207+ dep. scope == " test"
208+ }
209+
210+ root. children(). last() + {
211+ resolveStrategy = Closure . DELEGATE_FIRST
212+
213+ description ' Microsoft Graph SDK'
214+ name ' Microsoft Graph Java SDK'
215+ url ' https://github.com/microsoftgraph/msgraph-sdk-java'
216+ organization {
217+ name ' Microsoft'
218+ url ' https://github.com/microsoftgraph/msgraph-sdk-java'
219+ }
220+ issueManagement {
221+ system ' GitHub'
222+ url ' https://github.com/microsoftgraph/msgraph-sdk-java/issues'
223+ }
224+ licenses {
225+ license {
226+ name " MIT License"
227+ url " http://opensource.org/licenses/MIT"
228+ distribution " repo"
229+ }
230+ }
231+ scm {
232+ url ' https://github.com/microsoftgraph/msgraph-sdk-java'
233+ connection ' scm:git:git://github.com/microsoftgraph/msgraph-sdk-java.git'
234+ developerConnection
' scm:git:ssh://[email protected] :microsoftgraph/msgraph-sdk-java.git' 235+ }
236+ developers {
237+ developer {
238+ name ' Microsoft'
239+ }
240+ }
241+ }
242+ }
243+ }
244+
245+ model {
246+ tasks. generatePomFileForMavenJavaPublication {
247+ destination = file(" $buildDir /generated-pom.xml" )
248+ }
249+ tasks. publishMavenJavaPublicationToMavenLocal {
250+ dependsOn project. tasks. signArchives
251+ }
252+ tasks. publishMavenJavaPublicationToMavenRepository {
253+ dependsOn project. tasks. signArchives
254+ }
255+ }
0 commit comments