diff --git a/.azure-pipelines/buildAndPackage.yml b/.azure-pipelines/buildAndPackage.yml index ad8e81eea..d398126dc 100644 --- a/.azure-pipelines/buildAndPackage.yml +++ b/.azure-pipelines/buildAndPackage.yml @@ -23,6 +23,7 @@ trigger: - gradlew.bat - readme.md - settings.gradle + - Scripts/* pr: none @@ -82,6 +83,7 @@ steps: settings.gradle gradle.properties **/gradle/wrapper/* + Scripts/getLatestVersion.ps1 TargetFolder: '$(Build.ArtifactStagingDirectory)/' - task: PublishBuildArtifacts@1 diff --git a/.azure-pipelines/prValidate.yml b/.azure-pipelines/prValidate.yml index cdd049d0e..64bbf4c0b 100644 --- a/.azure-pipelines/prValidate.yml +++ b/.azure-pipelines/prValidate.yml @@ -1,4 +1,8 @@ -# Build and test Java Core to make sure a valid pull request is being made +#Copyright (c) Microsoft Corporation. All rights reserved. +#Licensed under the MIT License. +#Build and test Java Core to make sure a valid pull request is being made +#Validate that the versions dont conflict with those online in case a pull request is made to main or master + pr: branches: include: @@ -18,6 +22,7 @@ pr: - gradlew.bat - readme.md - settings.gradle + - Scripts/* trigger: none # disable triggers based on commits. @@ -62,4 +67,4 @@ steps: title: '$(Build.DefinitionName) failure notification' text: 'This pipeline has failed. View the build details for further information. This is a blocking failure. ' condition: and(failed(), ne(variables['Build.Reason'], 'Manual')) - enabled: true \ No newline at end of file + enabled: true diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..8f1d6965c --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,37 @@ + + +### Expected behavior + + + + +### Actual behavior + + + + +### Steps to reproduce the behavior + + + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..cc5edb2ef --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ + + + +Fixes # + + +### Changes proposed in this pull request +- + + +### Other links +- diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..767270516 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: gradle + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 +- package-ecosystem: maven + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..acbe219cf --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,54 @@ +name: "CodeQL" + +on: + push: + branches: [dev, master] + pull_request: + # The branches below must be a subset of the branches above + branches: [dev] + schedule: + - cron: '0 1 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + with: + languages: java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/conflicting-pr-label.yml b/.github/workflows/conflicting-pr-label.yml new file mode 100644 index 000000000..135603af1 --- /dev/null +++ b/.github/workflows/conflicting-pr-label.yml @@ -0,0 +1,34 @@ +# This is a basic workflow to help you get started with Actions + +name: PullRequestConflicting + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master, dev ] + pull_request: + types: [synchronize] + branches: [ master, dev ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: check if prs are dirty + uses: eps1lon/actions-label-merge-conflict@releases/2.x + if: env.LABELING_TOKEN != '' && env.LABELING_TOKEN != null + id: check + with: + dirtyLabel: "conflicting" + repoToken: "${{ secrets.GITHUB_TOKEN }}" + continueOnMissingPermissions: true + commentOnDirty: 'This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.' + commentOnClean: 'Conflicts have been resolved. A maintainer will take a look shortly.' + env: + LABELING_TOKEN: ${{secrets.GITHUB_TOKEN }} diff --git a/Scripts/getLatestVersion.ps1 b/Scripts/getLatestVersion.ps1 new file mode 100644 index 000000000..4e935336b --- /dev/null +++ b/Scripts/getLatestVersion.ps1 @@ -0,0 +1,31 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +<# +.Synopsis + Retrieve the latest version of the library +.Description + Retrieves the latest version specified in the Gradle.Properties file + Uses the retrieved values to update the enviornment variable VERSION_STRING +.Parameter propertiesPath +#> +Param( + [string]$propertiesPath +) + +#Retrieve the current version from the Gradle.Properties file given the specified path +if($propertiesPath -eq "" -or $null -eq $propertiesPath) { + $propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties" +} +$file = get-item $propertiesPath +$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2 +$findVersions = $findVersions -split "`r`n" + +$majorVersion = $findVersions[0].Substring($findVersions[0].Length-1) +$minorVersion = $findVersions[1].Substring($findVersions[1].Length-1) +$patchVersion = $findVersions[2].Substring($findVersions[2].Length-1) +$version = "$majorVersion.$minorVersion.$patchVersion" + +#Update the VERSION_STRING env variable and inform the user +Write-Host "##vso[task.setVariable variable=VERSION_STRING]$($version)"; +Write-Host "Updated the VERSION_STRING enviornment variable with the current Gradle.Properties, $version" \ No newline at end of file diff --git a/Scripts/validateMavenVersion.ps1 b/Scripts/validateMavenVersion.ps1 index 282567a45..da1742bd2 100644 --- a/Scripts/validateMavenVersion.ps1 +++ b/Scripts/validateMavenVersion.ps1 @@ -9,23 +9,22 @@ Retrieves the local, Maven, and Bintray versions of the Java-Core build. Checks that the Maven and Bintray versions are aligned, trigger warning if not. Checks that the current local version is greater than those currently deployed. +.Parameter propertiesPath #> -.Parameter packageName -.Parameter propertiesPath Param( - [parameter(Mandatory = $true)] - [string]$packageName, - - [parameter(Mandatory = $true)] [string]$propertiesPath ) #Find the local version from the Gradle.Properties file +if($propertiesPath -eq "" -or $null -eq $propertiesPath) { + $propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties" +} $file = get-item $propertiesPath $findLocalVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2 $findLocalVersions = $findLocalVersions -split "`r`n" +$packageName = ($file | Select-String -Pattern "mavenArtifactId").Line.Split("=")[1].Trim() $localMajor = $findLocalVersions[0].Substring($findLocalVersions[0].Length-1) $localMinor = $findLocalVersions[1].Substring($findLocalVersions[1].Length-1) @@ -43,18 +42,26 @@ $bintrayAPIurl = "https://api.bintray.com/search/packages?name=$packageName" $jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json $bintrayVersion = [version]$jsonResult.latest_version +#If the api calls return empty then this library cannot be compared to the online versions +#may proceed with the pull request +if(($mavenVersion -eq $null) -and ($bintrayVersion -eq $null)) +{ + Write-Information "This package does not exist yet in the online repository, therefore there are no versions to compare." + return +} + #Inform host of current Maven and Bintray versions -write-host 'The current version in the Maven central repository is:' $mavenVersion -write-host 'The current version in the Bintray central repository is:' $bintrayVersion +Write-Host 'The current version in the Maven central repository is:' $mavenVersion +Write-Host 'The current version in the Bintray central repository is:' $bintrayVersion #Warn in case Maven and Bintray versions are not the same. if($mavenVersion -ne $bintrayVersion){ Write-Warning "The current Maven and Bintray versions are not the same" } #Success if Local version has been updated, Error otherwise. -if($localVersion -gt $bintrayVersion){ +if($localVersion -gt $bintrayVersion -and $localVersion -gt $mavenVersion){ Write-Host "The current pull request is of a greater version" } else{ Write-Error "The current local version is not updated. Please update the local version in the Gradle.Properties file." -} \ No newline at end of file +} diff --git a/build.gradle b/build.gradle index 261f884bc..ff7a71387 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,19 @@ /* - * This build file was generated by the Gradle 'init' task. + * This file was generated by the Gradle 'init' task. * * This generated file contains a sample Java Library project to get you started. * For more details take a look at the Java Libraries chapter in the Gradle - * user guide available at https://docs.gradle.org/4.5/userguide/java_library_plugin.html + * User Manual available at https://docs.gradle.org/6.6/userguide/java_library_plugin.html */ -// Apply the java-library plugin to add support for Java Library -apply plugin: 'java-library' -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'maven' -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'jacoco' +plugins { + // Apply the java-library plugin to add support for Java Library + id 'java-library' + id 'java' + id 'eclipse' + id 'maven-publish' + id 'signing' +} // In this section you declare where to find the dependencies of your project repositories { @@ -24,19 +24,13 @@ repositories { } dependencies { - // This dependency is exported to consumers, that is to say found on their compile classpath. - api 'org.apache.commons:commons-math3:3.6.1' - - // This dependency is used internally, and not exposed to consumers on their own compile classpath. - implementation 'com.google.guava:guava:20.0' - // Use JUnit test framework - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' api 'com.squareup.okhttp3:okhttp:3.12.1' // https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple - compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1' + implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1' } def pomConfig = { @@ -53,23 +47,33 @@ def pomConfig = { //Maven Central Snapshot: publishSnapshotPublicationToMavenRepository //Maven Central Release: publishMavenCentralReleasePublicationToMaven2Repository //Bintray Snapshot: publishSnapshotPublicationToMaven3Repository -//Bintray Release: uploadArchives -publishing { +task sourceJar(type: Jar) { + from sourceSets.main.allJava + archiveClassifier = 'sources' +} - publications { +task javadocJar(type: Jar, dependsOn: javadoc) { + from javadoc.destinationDir + archiveClassifier = 'javadoc' +} - maven(MavenPublication) { +signing { + sign configurations.archives +} +tasks.withType(Sign)*.enabled = mavenCentralPublishingEnabled.toBoolean() - groupId 'com.microsoft.graph' +publishing { - artifactId 'microsoft-graph-core' + publications { + maven(MavenPublication) { + groupId project.property('mavenGroupId') + artifactId project.property('mavenArtifactId') version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}" - from components.java - artifact sourceJar + artifact javadocJar pom.withXml { def root = asNode() root.appendNode('name', 'Microsoft Graph Core SDK for Java') @@ -82,26 +86,22 @@ publishing { } Snapshot(MavenPublication) { customizePom(pom) - groupId 'com.microsoft.graph' - artifactId 'microsoft-graph-core' + groupId project.property('mavenGroupId') + artifactId project.property('mavenArtifactId') version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenCentralSnapshotArtifactSuffix}" from components.java pom.withXml { def pomFile = file("${project.buildDir}/generated-pom.xml") writeTo(pomFile) } - artifact(sourceJar) { - classifier = 'sources' - } - artifact(javadocJar) { - classifier = 'javadoc' - } + artifact sourceJar + artifact javadocJar } mavenCentralRelease(MavenPublication) { customizePom(pom) - groupId 'com.microsoft.graph' - artifactId 'microsoft-graph-core' + groupId project.property('mavenGroupId') + artifactId project.property('mavenArtifactId') version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}" from components.java pom.withXml { @@ -113,12 +113,8 @@ publishing { extension = 'pom.asc' } } - artifact(sourceJar) { - classifier = 'sources' - } - artifact(javadocJar) { - classifier = 'javadoc' - } + artifact sourceJar + artifact javadocJar project.tasks.signArchives.signatureFiles.each { artifact(it) { def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/ @@ -135,55 +131,71 @@ publishing { } repositories { maven { - url = project.property('mavenCentralSnapshotUrl') + url = 'https://oss.sonatype.org/content/repositories/snapshots' + name = 'sonatypeSnapshot' credentials { if (project.rootProject.file('local.properties').exists()) { - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - username = properties.getProperty('sonatypeUsername') - password = properties.getProperty('sonatypePassword') - } } } maven { - url = project.property('mavenCentralReleaseUrl') + url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2' + name = 'sonatype' credentials { if (project.rootProject.file('local.properties').exists()) { - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - username = properties.getProperty('sonatypeUsername') - password = properties.getProperty('sonatypePassword') - } } } maven { - url = project.property('mavenBintraySnapshotUrl') + url = 'http://oss.jfrog.org/artifactory/oss-snapshot-local' + name = 'jfrogSnapshot' credentials { if (project.rootProject.file('local.properties').exists()) { - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - username = (properties.containsKey('bintray.user')) ? properties.getProperty('bintray.user').toLowerCase() : "BINTRAY_USERNAME" + password = properties.getProperty('bintray.apikey') + } + } + } + maven { + url = 'https://oss.jfrog.org/artifactory/libs-release' + name = 'jfrog' + + credentials { + if (project.rootProject.file('local.properties').exists()) { + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + username = (properties.containsKey('bintray.user')) ? properties.getProperty('bintray.user').toLowerCase() : "BINTRAY_USERNAME" password = properties.getProperty('bintray.apikey') + } + } + } + maven { + url = 'https://api.bintray.com/content/microsoftgraph/Maven/microsoft-graph-core' + name = 'bintray' + + credentials { + if (project.rootProject.file('local.properties').exists()) { + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + username = (properties.containsKey('bintray.user')) ? properties.getProperty('bintray.user').toLowerCase() : "BINTRAY_USERNAME" + password = properties.getProperty('bintray.apikey') } } } @@ -191,11 +203,6 @@ publishing { } -task sourceJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allJava -} - compileJava { sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -209,74 +216,12 @@ def getVersionName() { return "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}" } -uploadArchives { - - def bintrayUsername = "" - - def bintrayApikey = "" - - if (project.rootProject.file('local.properties').exists()) { - - Properties properties = new Properties() - - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - - bintrayUsername = properties.getProperty('bintray.user') - - bintrayApikey = properties.getProperty('bintray.apikey') - - } - - configuration = configurations.archives - - repositories.mavenDeployer { - - pom { - - setGroupId project.mavenGroupId - - setArtifactId project.mavenArtifactId - - setVersion getVersionName() - - } - - repository (url: project.mavenRepoUrl) { - - url = url + "/" + getVersionName() - - authentication( - - // put these values in local file ~/.gradle/gradle.properties - - userName: project.hasProperty("bintrayUsername") ? project.bintrayUsername : bintrayUsername, - - password: project.hasProperty("bintrayApikey") ? project.bintrayApikey : bintrayApikey - - ) - - } - - } - -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - artifacts { archives jar archives sourceJar archives javadocJar } -signing { - sign configurations.archives -} -tasks.withType(Sign)*.enabled = mavenCentralPublishingEnabled.toBoolean() - def customizePom(pom) { pom.withXml { def root = asNode() @@ -338,7 +283,7 @@ model { tasks.publishMavenCentralReleasePublicationToMavenLocal { dependsOn project.tasks.signArchives } - tasks.publishMavenCentralReleasePublicationToMaven2Repository { + tasks.publishMavenCentralReleasePublicationToSonatypeRepository { dependsOn project.tasks.signArchives } } diff --git a/gradle.properties b/gradle.properties index 5203616e8..d4a173553 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,13 +21,11 @@ ## linux requires 10G, OSX requires 11G org.gradle.jvmargs=-XX:MaxPermSize=512m -Xmx2g -mavenRepoUrl = https://api.bintray.com/content/microsoftgraph/Maven/microsoft-graph-core -mavenBintraySnapshotUrl = http://oss.jfrog.org/artifactory/oss-snapshot-local mavenGroupId = com.microsoft.graph mavenArtifactId = microsoft-graph-core mavenMajorVersion = 1 mavenMinorVersion = 0 -mavenPatchVersion = 1 +mavenPatchVersion = 2 mavenArtifactSuffix = nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven @@ -40,7 +38,5 @@ Username="USERNAME" Password="PASSWORD" #enable mavenCentralPublishingEnabled to publish to maven central -mavenCentralSnapshotUrl=https://oss.sonatype.org/content/repositories/snapshots -mavenCentralReleaseUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2 mavenCentralSnapshotArtifactSuffix = -SNAPSHOT mavenCentralPublishingEnabled=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e28513376..e708b1c02 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92165eede..6c9a22477 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip diff --git a/gradlew b/gradlew index cccdd3d51..4f906e0c8 100644 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162f..107acd32c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/readme.md b/readme.md index d16859cdd..76cb5137f 100644 --- a/readme.md +++ b/readme.md @@ -3,8 +3,9 @@ Get started with the Microsoft Graph Core SDK for Java by integrating the [Microsoft Graph API](https://graph.microsoft.io/en-us/getting-started) into your Java and Android application! ## Samples and usage guide -[Middleware usage](https://github.com/microsoftgraph/msgraph-sdk-java-core/wiki)
-[Batching](https://github.com/microsoftgraph/msgraph-sdk-java-core/wiki/Batching) + +- [Middleware usage](https://github.com/microsoftgraph/msgraph-sdk-java-core/wiki) +- [Batching](https://github.com/microsoftgraph/msgraph-sdk-java-core/wiki/Batching) ## 1. Installation @@ -13,27 +14,30 @@ Get started with the Microsoft Graph Core SDK for Java by integrating the [Micro Add the repository and a compile dependency for `microsoft-graph-core` to your project's `build.gradle`: ```gradle -repository { +repositories { jcenter() } -dependency { +dependencies { // Include the sdk as a dependency - compile('com.microsoft.graph:microsoft-graph-core:1.0.1') + implementation 'com.microsoft.graph:microsoft-graph-core:1.0.2' } ``` ### 1.2 Install via Maven + Add the dependency in `dependencies` in pom.xml -```dependency + +```xml com.microsoft.graph microsoft-graph-core - 1.0.1 + 1.0.2 ``` ### 1.3 Enable ProGuard (Android) + 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). ## 2. Getting started @@ -44,13 +48,16 @@ Register your application by following the steps at [Register your app with the ### 2.2 Create an IAuthenticationProvider object -An instance of the **HttpClients** class handles building client. To create a new instance of this class, you need to provide an instance of `ICoreAuthenticationProvider`, which can authenticate requests to Microsoft Graph. -### To get instance of HttpClients +An instance of the **HttpClients** class handles building client. To create a new instance of this class, you need to provide an instance of `ICoreAuthenticationProvider`, which can authenticate requests to Microsoft Graph. + +### To get instance of HttpClients + Auth in Java app [here](https://github.com/microsoftgraph/msgraph-sdk-java-auth) Auth in Android app [here](https://github.com/microsoftgraph/msgraph-sdk-android-auth) ### 2.3 Get a HttpClients object + You must get a **HttpClients** object to make requests against the service. ```java diff --git a/settings.gradle b/settings.gradle index 2b04dfc4e..ab8f7824a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,18 +1,10 @@ /* - * This settings file was generated by the Gradle 'init' task. + * This file was generated by the Gradle 'init' task. * * The settings file is used to specify which projects to include in your build. - * In a single project build this file can be empty or even removed. * * Detailed information about configuring a multi-project build in Gradle can be found - * in the user guide at https://docs.gradle.org/4.3/userguide/multi_project_builds.html + * in the user manual at https://docs.gradle.org/6.6/userguide/multi_project_builds.html */ -/* -// To declare projects as part of a multi-project build use the 'include' method -include 'shared' -include 'api' -include 'services:webservice' -*/ - rootProject.name = 'msgraph-sdk-java-core' diff --git a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java index e9a84bbc4..37bbd7ac4 100644 --- a/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java +++ b/src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java @@ -11,7 +11,7 @@ public class TelemetryHandler implements Interceptor{ public static final String SDK_VERSION = "SdkVersion"; - public static final String VERSION = "v1.0.1"; + public static final String VERSION = "v1.0.2"; public static final String GRAPH_VERSION_PREFIX = "graph-java-core"; public static final String JAVA_VERSION_PREFIX = "java"; public static final String CLIENT_REQUEST_ID = "client-request-id";