Skip to content

Commit ee830c6

Browse files
authored
Merge pull request #128 from microsoftgraph/maven-central
Changes to publish to maven central and readme edit.
2 parents bffb322 + d6a24f7 commit ee830c6

File tree

3 files changed

+149
-2
lines changed

3 files changed

+149
-2
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,40 @@ dependency {
2525
}
2626
```
2727

28-
### 1.2 Enable ProGuard (Android)
28+
### 1.2 Install via Maven
29+
Add the dependency in `dependencies` and profiles in `project` in pom.xml
30+
```dependency
31+
<dependency>
32+
<groupId>com.microsoft.graph</groupId>
33+
<artifactId>microsoft-graph</artifactId>
34+
<version>0.3.0-SNAPSHOT</version>
35+
</dependency>
36+
```
37+
38+
```profiles
39+
<profiles>
40+
<profile>
41+
<id>allow-snapshots</id>
42+
<activation>
43+
<activeByDefault>true</activeByDefault>
44+
</activation>
45+
<repositories>
46+
<repository>
47+
<id>snapshots-repo</id>
48+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
49+
<releases>
50+
<enabled>false</enabled>
51+
</releases>
52+
<snapshots>
53+
<enabled>true</enabled>
54+
</snapshots>
55+
</repository>
56+
</repositories>
57+
</profile>
58+
</profiles>
59+
```
60+
61+
### 1.3 Enable ProGuard (Android)
2962
The nature of the Graph API is such that the SDK needs quite a large set of classes to describe its functionality. You need to ensure that [ProGuard](https://developer.android.com/studio/build/shrink-code.html) is enabled on your project. Otherwise, you will incur long build times for functionality that is not necessarily relevant to your particular application. If you are still hitting the 64K method limit, you can also enable [multidexing](https://developer.android.com/studio/build/multidex.html).
3063

3164
## 2. Getting started

build.gradle

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ 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 {
1819
// Use jcenter for resolving your dependencies.
1920
// You can declare any Maven/Ivy/file repository here.
2021
jcenter()
22+
mavenCentral()
2123
}
2224

2325
dependencies {
@@ -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

149193
artifacts {
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+
}

gradle.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven
3737
ClientId="CLIENT_ID"
3838
Username="USERNAME"
3939
Password="PASSWORD"
40+
41+
#enter below credentials and enable mavenCentralPublishingEnabled to publish to maven central
42+
signing.keyId="keyId"
43+
signing.secretKeyRingFile="fileLocation"
44+
signing.password="passphrase"
45+
sonatypeUsername="USERNAME"
46+
sonatypePassword="PASSWORD"
47+
mavenCentralUploadUrl=https://oss.sonatype.org/content/repositories/snapshots
48+
mavenCentralPublishingEnabled=false

0 commit comments

Comments
 (0)