11/*
2- * This build file was generated by the Gradle 'init' task.
2+ * This file was generated by the Gradle 'init' task.
33 *
44 * This generated file contains a sample Java Library project to get you started.
55 * For more details take a look at the Java Libraries chapter in the Gradle
6- * user guide available at https://docs.gradle.org/4.5 /userguide/java_library_plugin.html
6+ * User Manual available at https://docs.gradle.org/6.6 /userguide/java_library_plugin.html
77 */
88
9- // Apply the java-library plugin to add support for Java Library
10- apply plugin : ' java-library'
11- apply plugin : ' java'
12- apply plugin : ' eclipse'
13- apply plugin : ' maven'
14- apply plugin : ' maven-publish'
15- apply plugin : ' signing'
9+ plugins {
10+ // Apply the java-library plugin to add support for Java Library
11+ id ' java-library'
12+ id ' java'
13+ id ' eclipse'
14+ id ' maven-publish'
15+ id ' signing'
16+ id ' com.jfrog.bintray' version ' 1.8.5'
17+ }
1618
1719// In this section you declare where to find the dependencies of your project
1820repositories {
@@ -23,21 +25,18 @@ repositories {
2325}
2426
2527dependencies {
26- // This dependency is exported to consumers, that is to say found on their compile classpath.
27- api ' org.apache.commons:commons-math3:3.6.1'
28-
2928 // This dependency is used internally, and not exposed to consumers on their own compile classpath.
3029 implementation ' com.google.guava:guava:20.0'
3130
3231 // Use JUnit test framework
3332 testImplementation ' junit:junit:4.13'
3433
35- compile ' com.google.code.gson:gson:2.8.6'
34+ implementation ' com.google.code.gson:gson:2.8.6'
3635
37- compile ' com.sun.jersey:jersey-server:1.19.4'
36+ implementation ' com.sun.jersey:jersey-server:1.19.4'
3837
3938 // Core Http library
40- compile( ' com.microsoft.graph:microsoft-graph-core:1.0.2' )
39+ implementation ' com.microsoft.graph:microsoft-graph-core:1.0.2'
4140}
4241
4342def pomConfig = {
@@ -54,23 +53,28 @@ def pomConfig = {
5453// Maven Central Snapshot: publishSnapshotPublicationToMavenRepository
5554// Maven Central Release: publishMavenCentralReleasePublicationToMaven2Repository
5655// Bintray Snapshot: publishSnapshotPublicationToMaven3Repository
57- // Bintray Release: uploadArchives
56+
57+ task sourceJar (type : Jar ) {
58+ from sourceSets. main. allJava
59+ archiveClassifier = ' sources'
60+ }
61+
62+ task javadocJar (type : Jar , dependsOn : javadoc) {
63+ from javadoc. destinationDir
64+ archiveClassifier = ' javadoc'
65+ }
5866
5967publishing {
6068
6169 publications {
6270
6371 maven(MavenPublication ) {
64-
65- groupId ' com.microsoft.graph'
66-
67- artifactId ' microsoft-graph'
68-
72+ groupId project. property(' mavenGroupId' )
73+ artifactId project. property(' mavenArtifactId' )
6974 version " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion}${ mavenArtifactSuffix} "
70-
7175 from components. java
72-
7376 artifact sourceJar
77+ artifact javadocJar
7478 pom. withXml {
7579 def root = asNode()
7680 root. appendNode(' name' , ' Microsoft Graph SDK for Java' )
@@ -83,118 +87,134 @@ publishing {
8387 }
8488 Snapshot (MavenPublication ) {
8589 customizePom(pom)
86- groupId ' com.microsoft.graph '
87- artifactId ' microsoft-graph '
90+ groupId project . property( ' mavenGroupId ' )
91+ artifactId project . property( ' mavenArtifactId ' )
8892 version " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion}${ mavenCentralSnapshotArtifactSuffix} "
8993 from components. java
9094 pom. withXml {
9195 def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
9296 writeTo(pomFile)
9397 }
94- artifact(sourceJar) {
95- classifier = ' sources'
96- }
97- artifact(javadocJar) {
98- classifier = ' javadoc'
99- }
98+ artifact sourceJar
99+ artifact javadocJar
100100 }
101101
102102 mavenCentralRelease(MavenPublication ) {
103103 customizePom(pom)
104- groupId ' com.microsoft.graph '
105- artifactId ' microsoft-graph '
104+ groupId project . property( ' mavenGroupId ' )
105+ artifactId project . property( ' mavenArtifactId ' )
106106 version " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion} "
107107 from components. java
108108 pom. withXml {
109109 def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
110110 writeTo(pomFile)
111- def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
112- artifact(pomAscFile) {
113- classifier = null
114- extension = ' pom.asc'
115- }
116- }
117- artifact(sourceJar) {
118- classifier = ' sources'
119- }
120- artifact(javadocJar) {
121- classifier = ' javadoc'
122111 }
123- project. tasks. signArchives. signatureFiles. each {
124- artifact(it) {
125- def matcher = it. file =~ / -(sources|javadoc)\. jar\. asc$/
126- if (matcher. find()){
127- classifier = matcher. group(1 )
128- }
129- else {
130- classifier = null
131- }
132- extension = ' jar.asc'
133- }
134- }
112+ artifact sourceJar
113+ artifact javadocJar
135114 }
136115 }
137116 repositories {
138117 maven {
139- url = project. property(' mavenCentralSnapshotUrl' )
118+ url = ' https://oss.sonatype.org/content/repositories/snapshots'
119+ name = ' sonatypeSnapshot'
140120
141121 credentials {
142122 if (project. rootProject. file(' local.properties' ). exists()) {
143-
144123 Properties properties = new Properties ()
145-
146124 properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
147-
148125 username = properties. getProperty(' sonatypeUsername' )
149-
150126 password = properties. getProperty(' sonatypePassword' )
151-
152127 }
153128 }
154129 }
155130
156131 maven {
157- url = project. property(' mavenCentralReleaseUrl' )
132+ url = ' https://oss.sonatype.org/service/local/staging/deploy/maven2'
133+ name = ' sonatype'
158134
159135 credentials {
160136 if (project. rootProject. file(' local.properties' ). exists()) {
161-
162137 Properties properties = new Properties ()
163-
164138 properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
165-
166139 username = properties. getProperty(' sonatypeUsername' )
167-
168140 password = properties. getProperty(' sonatypePassword' )
169-
170141 }
171142 }
172143 }
173144
174145 maven {
175- url = project. property(' mavenBintraySnapshotUrl' )
146+ url = ' http://oss.jfrog.org/artifactory/oss-snapshot-local'
147+ name = ' jfrogSnapshot'
176148
177149 credentials {
178150 if (project. rootProject. file(' local.properties' ). exists()) {
179-
180151 Properties properties = new Properties ()
181-
182152 properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
183-
184153 username = (properties. containsKey(' bintray.user' )) ? properties. getProperty(' bintray.user' ). toLowerCase() : " BINTRAY_USERNAME"
185-
186154 password = properties. getProperty(' bintray.apikey' )
155+ }
156+ }
157+ }
187158
159+ maven {
160+ url = ' https://oss.jfrog.org/artifactory/libs-release'
161+ name = ' jfrog'
162+
163+ credentials {
164+ if (project. rootProject. file(' local.properties' ). exists()) {
165+ Properties properties = new Properties ()
166+ properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
167+ username = (properties. containsKey(' bintray.user' )) ? properties. getProperty(' bintray.user' ). toLowerCase() : " BINTRAY_USERNAME"
168+ password = properties. getProperty(' bintray.apikey' )
188169 }
189170 }
190171 }
191172 }
173+ }
192174
175+ signing {
176+ sign publishing. publications. mavenCentralRelease
193177}
178+ tasks. withType(Sign )* . enabled = mavenCentralPublishingEnabled. toBoolean()
194179
195- task sourceJar (type : Jar ) {
196- classifier = ' sources'
197- from sourceSets. main. allJava
180+ def fixAscNames = { name ->
181+ if (name. contains(' pom' )) {
182+ " ${ project.property('mavenArtifactId')} -${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion} .pom.asc"
183+ } else {
184+ name. replace(' msgraph-sdk-java' , " ${ project.property('mavenArtifactId')} -${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion} " )
185+ }
186+ }
187+ bintray {
188+ if (project. rootProject. file(' local.properties' ). exists()) {
189+ Properties properties = new Properties ()
190+ properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
191+ user = (properties. containsKey(' bintray.user' )) ? properties. getProperty(' bintray.user' ). toLowerCase() : " BINTRAY_USERNAME"
192+ key = properties. getProperty(' bintray.apikey' )
193+ }
194+ publications = [' mavenCentralRelease' ]
195+ filesSpec {
196+ from (' build/libs' ) {
197+ include ' msgraph-sdk-java*.jar.asc'
198+ rename fixAscNames
199+ }
200+ from (' build' ) {
201+ include ' generated-pom.xml.asc'
202+ rename fixAscNames
203+ }
204+ into " com/microsoft/graph/${ project.property('mavenArtifactId')} /${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion} /"
205+ }
206+ pkg {
207+ repo = ' Maven'
208+ name = project. property(' mavenArtifactId' )
209+ userOrg = ' microsoftgraph'
210+ licenses = [' MIT' ]
211+ vcsUrl = ' https://github.com/microsoftgraph/msgraph-sdk-java.git'
212+ publicDownloadNumbers = true
213+ version {
214+ name = " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion} "
215+ vcsTag = " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion} "
216+ }
217+ }
198218}
199219
200220compileJava {
@@ -210,74 +230,12 @@ def getVersionName() {
210230 return " ${ mavenMajorVersion} .${ mavenMinorVersion} .${ mavenPatchVersion}${ mavenArtifactSuffix} "
211231}
212232
213- uploadArchives {
214-
215- def bintrayUsername = " "
216-
217- def bintrayApikey = " "
218-
219- if (project. rootProject. file(' local.properties' ). exists()) {
220-
221- Properties properties = new Properties ()
222-
223- properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
224-
225- bintrayUsername = properties. getProperty(' bintray.user' )
226-
227- bintrayApikey = properties. getProperty(' bintray.apikey' )
228-
229- }
230-
231- configuration = configurations. archives
232-
233- repositories. mavenDeployer {
234-
235- pom {
236-
237- setGroupId project. mavenGroupId
238-
239- setArtifactId project. mavenArtifactId
240-
241- setVersion getVersionName()
242-
243- }
244-
245- repository (url : project. mavenRepoUrl) {
246-
247- url = url + " /" + getVersionName()
248-
249- authentication(
250-
251- // put these values in local file ~/.gradle/gradle.properties
252-
253- userName : project. hasProperty(" bintrayUsername" ) ? project. bintrayUsername : bintrayUsername,
254-
255- password : project. hasProperty(" bintrayApikey" ) ? project. bintrayApikey : bintrayApikey
256-
257- )
258-
259- }
260-
261- }
262-
263- }
264-
265- task javadocJar (type : Jar , dependsOn : javadoc) {
266- classifier = ' javadoc'
267- from javadoc. destinationDir
268- }
269-
270233artifacts {
271234 archives jar
272235 archives sourceJar
273236 archives javadocJar
274237}
275238
276- signing {
277- sign configurations. archives
278- }
279- tasks. withType(Sign )* . enabled = mavenCentralPublishingEnabled. toBoolean()
280-
281239def customizePom (pom ) {
282240 pom. withXml {
283241 def root = asNode()
@@ -334,12 +292,12 @@ gradle.taskGraph.whenReady { taskGraph ->
334292
335293model {
336294 tasks. generatePomFileForMavenCentralReleasePublication {
337- destination = file(" $buildDir /generated-pom.xml" )
295+ destination = file(" ${ project. buildDir} /generated-pom.xml" )
338296 }
339297 tasks. publishMavenCentralReleasePublicationToMavenLocal {
340298 dependsOn project. tasks. signArchives
341299 }
342- tasks. publishMavenCentralReleasePublicationToMaven2Repository {
300+ tasks. publishMavenCentralReleasePublicationToSonatypeRepository {
343301 dependsOn project. tasks. signArchives
344302 }
345303}
0 commit comments