diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 12670923c..30fdb7b9c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,8 +4,7 @@ # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax -# The @googleapis/yoshi-java is the default owner for changes in this repo -**/*.java @googleapis/yoshi-java +* @googleapis/yoshi-java # The java-samples-reviewers team is the default owner for samples changes samples/**/*.java @googleapis/java-samples-reviewers diff --git a/.github/readme/synth.py b/.github/readme/synth.py new file mode 100644 index 000000000..7b48cc28d --- /dev/null +++ b/.github/readme/synth.py @@ -0,0 +1,19 @@ +# Copyright 2020 Google LLC +# +# 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 +# +# http://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. + +"""This script is used to synthesize generated the README for this library.""" + +from synthtool.languages import java + +java.custom_templates(["java_library/README.md"]) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml new file mode 100644 index 000000000..af5dd3bd5 --- /dev/null +++ b/.github/sync-repo-settings.yaml @@ -0,0 +1,45 @@ +# Whether or not rebase-merging is enabled on this repository. +# Defaults to `true` +rebaseMergeAllowed: false + +# Whether or not squash-merging is enabled on this repository. +# Defaults to `true` +squashMergeAllowed: true + +# Whether or not PRs are merged with a merge commit on this repository. +# Defaults to `false` +mergeCommitAllowed: false + +# Rules for master branch protection +branchProtectionRules: +# Identifies the protection rule pattern. Name of the branch to be protected. +# Defaults to `master` +- pattern: master + # Can admins overwrite branch protection. + # Defaults to `true` + isAdminEnforced: true + # Number of approving reviews required to update matching branches. + # Defaults to `1` + requiredApprovingReviewCount: 1 + # Are reviews from code owners required to update matching branches. + # Defaults to `false` + requiresCodeOwnerReviews: true + # Require up to date branches + requiresStrictStatusChecks: false + # List of required status check contexts that must pass for commits to be accepted to matching branches. + requiredStatusCheckContexts: + - "Kokoro - Test: Binary Compatibility" + - "Kokoro - Test: Java 11" + - "Kokoro - Test: Java 7" + - "Kokoro - Test: Java 8" + - "Kokoro - Test: Linkage Monitor" + - "cla/google" + +# List of explicit permissions to add (additive only) +permissionRules: +- team: yoshi-admins + permission: admin +- team: yoshi-java-admins + permission: admin +- team: yoshi-java + permission: push diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml new file mode 100644 index 000000000..bc1554aec --- /dev/null +++ b/.github/workflows/auto-release.yaml @@ -0,0 +1,88 @@ +on: + pull_request: +name: auto-release +jobs: + approve: + runs-on: ubuntu-latest + if: contains(github.head_ref, 'release-v') + steps: + - uses: actions/github-script@v3.0.0 + with: + github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} + debug: true + script: | + // only approve PRs from release-please[bot] + if (context.payload.pull_request.user.login !== "release-please[bot]") { + return; + } + + // only approve PRs like "chore: release " + if ( !context.payload.pull_request.title.startsWith("chore: release") ) { + return; + } + + // only approve PRs with pom.xml and versions.txt changes + const filesPromise = github.pulls.listFiles.endpoint({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + const changed_files = await github.paginate(filesPromise) + + if ( changed_files.length < 1 ) { + console.log( "Not proceeding since PR is empty!" ) + return; + } + + if ( !changed_files.some(v => v.filename.includes("pom")) || !changed_files.some(v => v.filename.includes("versions.txt")) ) { + console.log( "PR file changes do not have pom.xml or versions.txt -- something is wrong. PTAL!" ) + return; + } + + // trigger auto-release when + // 1) it is a SNAPSHOT release (auto-generated post regular release) + // 2) there are dependency updates only + // 3) there are no open dependency update PRs in this repo (to avoid multiple releases) + if ( + context.payload.pull_request.body.includes("Fix") || + context.payload.pull_request.body.includes("Build") || + context.payload.pull_request.body.includes("Documentation") || + context.payload.pull_request.body.includes("BREAKING CHANGES") || + context.payload.pull_request.body.includes("Features") + ) { + console.log( "Not auto-releasing since it is not a dependency-update-only release." ); + return; + } + + const promise = github.pulls.list.endpoint({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + const open_pulls = await github.paginate(promise) + + if ( open_pulls.length > 1 && !context.payload.pull_request.title.includes("SNAPSHOT") ) { + for ( const pull of open_pulls ) { + if ( pull.title.startsWith("deps: update dependency") ) { + console.log( "Not auto-releasing yet since there are dependency update PRs open in this repo." ); + return; + } + } + } + + // approve release PR + await github.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Rubber stamped release!', + pull_number: context.payload.pull_request.number, + event: 'APPROVE' + }); + + // attach kokoro:force-run and automerge labels + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: ['kokoro:force-run', 'automerge'] + }); diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml new file mode 100644 index 000000000..c46230a78 --- /dev/null +++ b/.github/workflows/samples.yaml @@ -0,0 +1,14 @@ +on: + pull_request: +name: samples +jobs: + checkstyle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Run checkstyle + run: mvn -P lint --quiet --batch-mode checkstyle:check + working-directory: samples/snippets diff --git a/.kokoro/continuous/dependencies.cfg b/.kokoro/continuous/dependencies.cfg deleted file mode 100644 index b89a20740..000000000 --- a/.kokoro/continuous/dependencies.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/google-http-java-client/.kokoro/dependencies.sh" -} diff --git a/.kokoro/continuous/integration.cfg b/.kokoro/continuous/integration.cfg deleted file mode 100644 index 3b017fc80..000000000 --- a/.kokoro/continuous/integration.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} diff --git a/.kokoro/continuous/java11.cfg b/.kokoro/continuous/java11.cfg deleted file mode 100644 index 709f2b4c7..000000000 --- a/.kokoro/continuous/java11.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" -} diff --git a/.kokoro/continuous/java7.cfg b/.kokoro/continuous/java7.cfg deleted file mode 100644 index cb24f44ee..000000000 --- a/.kokoro/continuous/java7.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java7" -} diff --git a/.kokoro/continuous/java8-osx.cfg b/.kokoro/continuous/java8-osx.cfg deleted file mode 100644 index b2354168e..000000000 --- a/.kokoro/continuous/java8-osx.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "google-http-java-client/.kokoro/build.sh" diff --git a/.kokoro/continuous/java8-win.cfg b/.kokoro/continuous/java8-win.cfg deleted file mode 100644 index b44537d03..000000000 --- a/.kokoro/continuous/java8-win.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "google-http-java-client/.kokoro/build.bat" diff --git a/.kokoro/continuous/lint.cfg b/.kokoro/continuous/lint.cfg deleted file mode 100644 index 6d323c8ae..000000000 --- a/.kokoro/continuous/lint.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. - -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "lint" -} \ No newline at end of file diff --git a/.kokoro/continuous/propose_release.cfg b/.kokoro/continuous/propose_release.cfg deleted file mode 100644 index 715a53e14..000000000 --- a/.kokoro/continuous/propose_release.cfg +++ /dev/null @@ -1,53 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "google-http-java-client/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/google-http-java-client/.kokoro/continuous/propose_release.sh" -} - -# tokens used by release-please to keep an up-to-date release PR. -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "github-magic-proxy-key-release-please" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "github-magic-proxy-token-release-please" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "github-magic-proxy-url-release-please" - } - } -} diff --git a/.kokoro/continuous/readme.cfg b/.kokoro/continuous/readme.cfg new file mode 100644 index 000000000..5056c884d --- /dev/null +++ b/.kokoro/continuous/readme.cfg @@ -0,0 +1,55 @@ +# Copyright 2020 Google LLC +# +# 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 +# +# http://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. + +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/python-multi" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/google-http-java-client/.kokoro/readme.sh" +} + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.log" + } +} + +# The github token is stored here. +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "yoshi-automation-github-key" + # TODO(theacodes): remove this after secrets have globally propagated + backend_type: FASTCONFIGPUSH + } + } +} + +# Common env vars for all repositories and builds. +env_vars: { + key: "GITHUB_USER" + value: "yoshi-automation" +} +env_vars: { + key: "GITHUB_EMAIL" + value: "yoshi-automation@google.com" +} diff --git a/.kokoro/continuous/samples.cfg b/.kokoro/continuous/samples.cfg deleted file mode 100644 index fa7b493d0..000000000 --- a/.kokoro/continuous/samples.cfg +++ /dev/null @@ -1,31 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "samples" -} - -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "keystore/73713_java_it_service_account" -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "java_it_service_account" - } - } -} diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index cee4f11e7..c91e5a569 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -43,12 +43,13 @@ function completenessCheck() { # Output dep list with compile scope generated using the original pom # Running mvn dependency:list on Java versions that support modules will also include the module of the dependency. # This is stripped from the output as it is not present in the flattened pom. + # Only dependencies with 'compile' or 'runtime' scope are included from original dependency list. msg "Generating dependency list using original pom..." - mvn dependency:list -f pom.xml -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e s/\\s--\\smodule.*// | grep -v ':test$' >.org-list.txt + mvn dependency:list -f pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e s/\\s--\\smodule.*// >.org-list.txt - # Output dep list generated using the flattened pom (test scope deps are ommitted) + # Output dep list generated using the flattened pom (only 'compile' and 'runtime' scopes) msg "Generating dependency list using flattened pom..." - mvn dependency:list -f .flattened-pom.xml -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt + mvn dependency:list -f .flattened-pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt # Compare two dependency lists msg "Comparing dependency lists..." @@ -85,4 +86,4 @@ then else msg "Errors found. See log statements above." exit 1 -fi +fi \ No newline at end of file diff --git a/.kokoro/nightly/dependencies.cfg b/.kokoro/nightly/dependencies.cfg deleted file mode 100644 index b89a20740..000000000 --- a/.kokoro/nightly/dependencies.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/google-http-java-client/.kokoro/dependencies.sh" -} diff --git a/.kokoro/nightly/lint.cfg b/.kokoro/nightly/lint.cfg deleted file mode 100644 index 6d323c8ae..000000000 --- a/.kokoro/nightly/lint.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. - -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "lint" -} \ No newline at end of file diff --git a/.kokoro/readme.sh b/.kokoro/readme.sh new file mode 100755 index 000000000..0bcf9b617 --- /dev/null +++ b/.kokoro/readme.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright 2020 Google LLC +# +# 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 +# +# http://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. + +set -eo pipefail + +cd ${KOKORO_ARTIFACTS_DIR}/github/google-http-java-client + +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + +# Kokoro exposes this as a file, but the scripts expect just a plain variable. +export GITHUB_TOKEN=$(cat ${KOKORO_KEYSTORE_DIR}/73713_yoshi-automation-github-key) + +# Setup git credentials +echo "https://$%7BGITHUB_TOKEN%7D@github.com/" >> ~/.git-credentials +git config --global credential.helper 'store --file ~/.git-credentials' + +python3.6 -m pip install git+https://github.com/googleapis/synthtool.git#egg=gcp-synthtool +python3.6 -m autosynth.synth \ + --repository=googleapis/google-http-java-client \ + --synth-file-name=.github/readme/synth.py \ + --metadata-path=.github/readme/synth.metadata \ + --pr-title="chore: regenerate README" \ + --branch-suffix="readme" \ No newline at end of file diff --git a/.kokoro/release/publish_javadoc.cfg b/.kokoro/release/publish_javadoc.cfg index c5d16b787..2359ee9d6 100644 --- a/.kokoro/release/publish_javadoc.cfg +++ b/.kokoro/release/publish_javadoc.cfg @@ -1,14 +1,24 @@ # Format: //devtools/kokoro/config/proto/build.proto + +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/doc-templates/" + env_vars: { key: "STAGING_BUCKET" value: "docs-staging" } +env_vars: { + key: "STAGING_BUCKET_V2" + value: "docs-staging-v2-staging" + # Production will be at: docs-staging-v2 +} + env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/google-http-java-client/.kokoro/release/publish_javadoc.sh" } + before_action { fetch_keystore { keystore_resource { diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh index b65eb9f90..e078748a8 100755 --- a/.kokoro/release/publish_javadoc.sh +++ b/.kokoro/release/publish_javadoc.sh @@ -24,6 +24,11 @@ if [[ -z "${STAGING_BUCKET}" ]]; then exit 1 fi +if [[ -z "${STAGING_BUCKET_V2}" ]]; then + echo "Need to set STAGING_BUCKET_V2 environment variable" + exit 1 +fi + # work from the git root directory pushd $(dirname "$0")/../../ @@ -31,13 +36,13 @@ pushd $(dirname "$0")/../../ python3 -m pip install gcp-docuploader # compile all packages -mvn clean install -B -DskipTests=true +mvn clean install -B -q -DskipTests=true NAME=google-http-client VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) # build the docs -mvn site -B +mvn site -B -q pushd target/site/apidocs @@ -53,3 +58,19 @@ python3 -m docuploader upload . \ --staging-bucket ${STAGING_BUCKET} popd + +# V2 +mvn clean site -B -q -Ddevsite.template="${KOKORO_GFILE_DIR}/java/" + +pushd target/devsite + +# create metadata +python3 -m docuploader create-metadata \ + --name ${NAME} \ + --version ${VERSION} \ + --language java + +# upload docs +python3 -m docuploader upload . \ + --credentials ${CREDENTIALS} \ + --staging-bucket ${STAGING_BUCKET_V2} diff --git a/.kokoro/release/stage.cfg b/.kokoro/release/stage.cfg index 3463d3d7b..103381c4f 100644 --- a/.kokoro/release/stage.cfg +++ b/.kokoro/release/stage.cfg @@ -13,32 +13,7 @@ action { } } -# Fetch the token needed for reporting release status to GitHub -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "yoshi-automation-github-key" - } - } -} - -# Fetch magictoken to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "releasetool-magictoken" - } - } -} - -# Fetch api key to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "magic-github-proxy-api-key" - } - } +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } diff --git a/.repo-metadata.json b/.repo-metadata.json index 0cd58366d..db2d13700 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -6,6 +6,5 @@ "language": "java", "repo": "googleapis/google-http-java-client", "repo_short": "google-http-java-client", - "codeowner_team": "@googleapis/yoshi-java", "distribution_name": "com.google.http-client:google-http-client" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ea0f07a5..48cc1de3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [1.37.0](https://www.github.com/googleapis/google-http-java-client/compare/v1.36.0...v1.37.0) (2020-10-13) + + +### Features + +* add flag to allow UrlEncodedContent to use UriPath escaping ([#1100](https://www.github.com/googleapis/google-http-java-client/issues/1100)) ([9ab7016](https://www.github.com/googleapis/google-http-java-client/commit/9ab7016032327f6fb0f91970dfbd511b029dd949)), closes [#1098](https://www.github.com/googleapis/google-http-java-client/issues/1098) + + +### Bug Fixes + +* make google-http-client.properties file shading friendly ([#1046](https://www.github.com/googleapis/google-http-java-client/issues/1046)) ([860bb05](https://www.github.com/googleapis/google-http-java-client/commit/860bb0541bcd7fc516cad14dd0d52481c7c7b414)) + + +### Dependencies + +* update protobuf-java to 3.13.0 ([#1093](https://www.github.com/googleapis/google-http-java-client/issues/1093)) ([b7e9663](https://www.github.com/googleapis/google-http-java-client/commit/b7e96632234e944e0e476dedfc822333716756bb)) + + +### Documentation + +* libraries-bom 12.0.0 ([#1136](https://www.github.com/googleapis/google-http-java-client/issues/1136)) ([450fcb2](https://www.github.com/googleapis/google-http-java-client/commit/450fcb2293cf3fa7c788cf0cc8ae48e865ae8de8)) + ## [1.36.0](https://www.github.com/googleapis/google-http-java-client/compare/v1.35.0...v1.36.0) (2020-06-30) diff --git a/clirr-ignored-differences.xml b/clirr-ignored-differences.xml deleted file mode 100644 index 0f0a72edf..000000000 --- a/clirr-ignored-differences.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - 7002 - com/google/api/client/json/webtoken/* - java.lang.String getX509Certificate() - - - 7002 - com/google/api/client/json/webtoken/* - com.google.api.client.json.webtoken.JsonWebSignature$Header setX509Certificate(java.lang.String) - - - 7002 - com/google/api/client/testing/http/MockHttpTransport - com.google.api.client.testing.http.MockHttpTransport$Builder builder() - - - - 8001 - com/google/api/client/repackaged/** - - - 8001 - com/google/api/client/http/apache/** - - diff --git a/docs/setup.md b/docs/setup.md index 768236f87..9b7517bd0 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -23,7 +23,7 @@ the `dependencyManagement` section of your `pom.xml`: com.google.cloud libraries-bom - 8.0.0 + 12.0.0 pom import diff --git a/google-http-client-android-test/pom.xml b/google-http-client-android-test/pom.xml index 65f1ae753..5dd1135f0 100644 --- a/google-http-client-android-test/pom.xml +++ b/google-http-client-android-test/pom.xml @@ -4,7 +4,7 @@ google-http-client google-http-client-android-test Test project for google-http-client-android. - 1.36.0 + 1.37.0 apk @@ -53,7 +53,7 @@ com.google.http-client google-http-client-android - 1.36.0 + 1.37.0 android @@ -72,7 +72,7 @@ com.google.http-client google-http-client-test - 1.36.0 + 1.37.0 junit diff --git a/google-http-client-android/pom.xml b/google-http-client-android/pom.xml index f5e3044e2..67bd88d75 100644 --- a/google-http-client-android/pom.xml +++ b/google-http-client-android/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-android - 1.36.0 + 1.37.0 Android Platform Extensions to the Google HTTP Client Library for Java. diff --git a/google-http-client-apache-v2/pom.xml b/google-http-client-apache-v2/pom.xml index 5d3f69c26..7a2b17a73 100644 --- a/google-http-client-apache-v2/pom.xml +++ b/google-http-client-apache-v2/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-apache-v2 - 1.36.0 + 1.37.0 Apache HTTP transport v2 for the Google HTTP Client Library for Java. diff --git a/google-http-client-appengine/pom.xml b/google-http-client-appengine/pom.xml index c16736ace..d19cd74b0 100644 --- a/google-http-client-appengine/pom.xml +++ b/google-http-client-appengine/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-appengine - 1.36.0 + 1.37.0 Google App Engine extensions to the Google HTTP Client Library for Java. diff --git a/google-http-client-assembly/pom.xml b/google-http-client-assembly/pom.xml index 0fc1ef53a..568065d7c 100644 --- a/google-http-client-assembly/pom.xml +++ b/google-http-client-assembly/pom.xml @@ -4,12 +4,12 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml com.google.http-client google-http-client-assembly - 1.36.0 + 1.37.0 pom Assembly for the Google HTTP Client Library for Java diff --git a/google-http-client-bom/pom.xml b/google-http-client-bom/pom.xml index e9d3cabe0..ffecf9545 100644 --- a/google-http-client-bom/pom.xml +++ b/google-http-client-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.http-client google-http-client-bom - 1.36.0 + 1.37.0 pom Google HTTP Client Library for Java BOM @@ -63,52 +63,52 @@ com.google.http-client google-http-client - 1.36.0 + 1.37.0 com.google.http-client google-http-client-android - 1.36.0 + 1.37.0 com.google.http-client google-http-client-apache-v2 - 1.36.0 + 1.37.0 com.google.http-client google-http-client-appengine - 1.36.0 + 1.37.0 com.google.http-client google-http-client-findbugs - 1.36.0 + 1.37.0 com.google.http-client google-http-client-gson - 1.36.0 + 1.37.0 com.google.http-client google-http-client-jackson2 - 1.36.0 + 1.37.0 com.google.http-client google-http-client-protobuf - 1.36.0 + 1.37.0 com.google.http-client google-http-client-test - 1.36.0 + 1.37.0 com.google.http-client google-http-client-xml - 1.36.0 + 1.37.0 diff --git a/google-http-client-findbugs/pom.xml b/google-http-client-findbugs/pom.xml index b794551f1..82e8fdd57 100644 --- a/google-http-client-findbugs/pom.xml +++ b/google-http-client-findbugs/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-findbugs - 1.36.0 + 1.37.0 Google APIs Client Library Findbugs custom plugin. diff --git a/google-http-client-gson/pom.xml b/google-http-client-gson/pom.xml index 540ec9c3a..9b8c64d26 100644 --- a/google-http-client-gson/pom.xml +++ b/google-http-client-gson/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-gson - 1.36.0 + 1.37.0 GSON extensions to the Google HTTP Client Library for Java. diff --git a/google-http-client-jackson2/pom.xml b/google-http-client-jackson2/pom.xml index 7f175f1a1..442b530b1 100644 --- a/google-http-client-jackson2/pom.xml +++ b/google-http-client-jackson2/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-jackson2 - 1.36.0 + 1.37.0 Jackson 2 extensions to the Google HTTP Client Library for Java. diff --git a/google-http-client-protobuf/pom.xml b/google-http-client-protobuf/pom.xml index 85f496ca6..c9b1c8cc4 100644 --- a/google-http-client-protobuf/pom.xml +++ b/google-http-client-protobuf/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-protobuf - 1.36.0 + 1.37.0 Protocol Buffer extensions to the Google HTTP Client Library for Java. diff --git a/google-http-client-test/pom.xml b/google-http-client-test/pom.xml index 74153df1a..13e6458fe 100644 --- a/google-http-client-test/pom.xml +++ b/google-http-client-test/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-test - 1.36.0 + 1.37.0 Shared classes used for testing of artifacts in the Google HTTP Client Library for Java. diff --git a/google-http-client-xml/pom.xml b/google-http-client-xml/pom.xml index 641b74637..735f3d251 100644 --- a/google-http-client-xml/pom.xml +++ b/google-http-client-xml/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client-xml - 1.36.0 + 1.37.0 XML extensions to the Google HTTP Client Library for Java. diff --git a/google-http-client/pom.xml b/google-http-client/pom.xml index a710e427b..b6a12a096 100644 --- a/google-http-client/pom.xml +++ b/google-http-client/pom.xml @@ -4,11 +4,11 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../pom.xml google-http-client - 1.36.0 + 1.37.0 Google HTTP Client Library for Java Google HTTP Client Library for Java. Functionality that works on all supported Java platforms, diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java b/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java index a521c5397..0b9b2abbb 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java @@ -1224,7 +1224,8 @@ private static String getVersion() { // this value should be read and cached for later use String version = "unknown-version"; try (InputStream inputStream = - HttpRequest.class.getResourceAsStream("/google-http-client.properties")) { + HttpRequest.class.getResourceAsStream( + "/com/google/api/client/http/google-http-client.properties")) { if (inputStream != null) { final Properties properties = new Properties(); properties.load(inputStream); diff --git a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedContent.java b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedContent.java index eb6428b18..ea08b1e18 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedContent.java +++ b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedContent.java @@ -42,20 +42,43 @@ * *

Implementation is not thread-safe. * - * @since 1.0 * @author Yaniv Inbar + * @since 1.0 */ public class UrlEncodedContent extends AbstractHttpContent { /** Key name/value data. */ private Object data; - /** @param data key name/value data */ + /** Use URI Path encoder flag. False by default (use legacy and deprecated escapeUri) */ + private boolean uriPathEncodingFlag; + + /** + * Initialize the UrlEncodedContent with the legacy and deprecated escapeUri encoder + * + * @param data key name/value data + */ public UrlEncodedContent(Object data) { super(UrlEncodedParser.MEDIA_TYPE); setData(data); + this.uriPathEncodingFlag = false; } + /** + * Initialize the UrlEncodedContent with or without the legacy and deprecated escapeUri encoder + * + * @param data key name/value data + * @param useUriPathEncoding escapes the string value so it can be safely included in URI path + * segments. For details on escaping URIs, see RFC 3986 - section 2.4 + */ + public UrlEncodedContent(Object data, boolean useUriPathEncoding) { + super(UrlEncodedParser.MEDIA_TYPE); + setData(data); + this.uriPathEncodingFlag = useUriPathEncoding; + } + + @Override public void writeTo(OutputStream out) throws IOException { Writer writer = new BufferedWriter(new OutputStreamWriter(out, getCharset())); boolean first = true; @@ -66,10 +89,10 @@ public void writeTo(OutputStream out) throws IOException { Class valueClass = value.getClass(); if (value instanceof Iterable || valueClass.isArray()) { for (Object repeatedValue : Types.iterableOf(value)) { - first = appendParam(first, writer, name, repeatedValue); + first = appendParam(first, writer, name, repeatedValue, this.uriPathEncodingFlag); } } else { - first = appendParam(first, writer, name, value); + first = appendParam(first, writer, name, value, this.uriPathEncodingFlag); } } } @@ -125,7 +148,8 @@ public static UrlEncodedContent getContent(HttpRequest request) { return result; } - private static boolean appendParam(boolean first, Writer writer, String name, Object value) + private static boolean appendParam( + boolean first, Writer writer, String name, Object value, boolean uriPathEncodingFlag) throws IOException { // ignore nulls if (value == null || Data.isNull(value)) { @@ -139,8 +163,13 @@ private static boolean appendParam(boolean first, Writer writer, String name, Ob } writer.write(name); String stringValue = - CharEscapers.escapeUri( - value instanceof Enum ? FieldInfo.of((Enum) value).getName() : value.toString()); + value instanceof Enum ? FieldInfo.of((Enum) value).getName() : value.toString(); + + if (uriPathEncodingFlag) { + stringValue = CharEscapers.escapeUriPath(stringValue); + } else { + stringValue = CharEscapers.escapeUri(stringValue); + } if (stringValue.length() != 0) { writer.write("="); writer.write(stringValue); diff --git a/google-http-client/src/main/resources/google-http-client.properties b/google-http-client/src/main/resources/com/google/api/client/http/google-http-client.properties similarity index 100% rename from google-http-client/src/main/resources/google-http-client.properties rename to google-http-client/src/main/resources/com/google/api/client/http/google-http-client.properties diff --git a/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedContentTest.java b/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedContentTest.java index f0e0768a9..059d9e2c9 100644 --- a/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedContentTest.java +++ b/google-http-client/src/test/java/com/google/api/client/http/UrlEncodedContentTest.java @@ -33,19 +33,32 @@ public class UrlEncodedContentTest extends TestCase { public void testWriteTo() throws IOException { - subtestWriteTo("a=x", ArrayMap.of("a", "x")); - subtestWriteTo("noval", ArrayMap.of("noval", "")); - subtestWriteTo("multi=a&multi=b&multi=c", ArrayMap.of("multi", Arrays.asList("a", "b", "c"))); - subtestWriteTo("multi=a&multi=b&multi=c", ArrayMap.of("multi", new String[] {"a", "b", "c"})); + subtestWriteTo("a=x", ArrayMap.of("a", "x"), false); + subtestWriteTo("noval", ArrayMap.of("noval", ""), false); + subtestWriteTo( + "multi=a&multi=b&multi=c", ArrayMap.of("multi", Arrays.asList("a", "b", "c")), false); + subtestWriteTo( + "multi=a&multi=b&multi=c", ArrayMap.of("multi", new String[] {"a", "b", "c"}), false); // https://github.com/googleapis/google-http-java-client/issues/202 final Map params = new LinkedHashMap(); params.put("username", "un"); params.put("password", "password123;{}"); - subtestWriteTo("username=un&password=password123%3B%7B%7D", params); + subtestWriteTo("username=un&password=password123%3B%7B%7D", params, false); + subtestWriteTo("additionkey=add%2Btion", ArrayMap.of("additionkey", "add+tion"), false); + + subtestWriteTo("a=x", ArrayMap.of("a", "x"), true); + subtestWriteTo("noval", ArrayMap.of("noval", ""), true); + subtestWriteTo( + "multi=a&multi=b&multi=c", ArrayMap.of("multi", Arrays.asList("a", "b", "c")), true); + subtestWriteTo( + "multi=a&multi=b&multi=c", ArrayMap.of("multi", new String[] {"a", "b", "c"}), true); + subtestWriteTo("username=un&password=password123;%7B%7D", params, true); + subtestWriteTo("additionkey=add+tion", ArrayMap.of("additionkey", "add+tion"), true); } - private void subtestWriteTo(String expected, Object data) throws IOException { - UrlEncodedContent content = new UrlEncodedContent(data); + private void subtestWriteTo(String expected, Object data, boolean useEscapeUriPathEncoding) + throws IOException { + UrlEncodedContent content = new UrlEncodedContent(data, useEscapeUriPathEncoding); ByteArrayOutputStream out = new ByteArrayOutputStream(); content.writeTo(out); assertEquals(expected, out.toString()); diff --git a/pom.xml b/pom.xml index 5c56df5b4..a9ee7b39d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 pom Parent for the Google HTTP Client Library for Java Google HTTP Client Library for Java @@ -118,7 +118,7 @@ junit junit - 4.13 + 4.13.1 com.google.truth @@ -339,7 +339,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.1.0 + 3.1.1 org.codehaus.mojo @@ -359,7 +359,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.1.0 + 3.1.1 org.apache.maven.plugins @@ -374,7 +374,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.1.0 + 3.2.0 org.apache.maven.plugins @@ -484,8 +484,7 @@ org.codehaus.mojo clirr-maven-plugin - 1.19.0 - ${basedir}/../clirr-ignored-differences.xml + clirr-ignored-differences.xml true @@ -531,7 +530,7 @@ maven-project-info-reports-plugin - 3.1.0 + 3.1.1 @@ -574,17 +573,17 @@ - google-api-java-client/google-api-client-assembly/android-properties (make the filenames match the version here) - Internally, update the default features.json file --> - 1.36.0 + 1.37.0 1.9.71 UTF-8 3.0.2 2.8.6 - 2.11.1 - 3.12.2 + 2.11.3 + 3.13.0 29.0-android 1.1.4c 1.2 - 4.5.12 + 4.5.13 4.4.13 0.24.0 .. diff --git a/samples/dailymotion-simple-cmdline-sample/pom.xml b/samples/dailymotion-simple-cmdline-sample/pom.xml index c81182186..d9fefc948 100644 --- a/samples/dailymotion-simple-cmdline-sample/pom.xml +++ b/samples/dailymotion-simple-cmdline-sample/pom.xml @@ -4,7 +4,7 @@ com.google.http-client google-http-client-parent - 1.36.0 + 1.37.0 ../../pom.xml dailymotion-simple-cmdline-sample diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 73371f10f..4074dc1ce 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 @@ -36,7 +36,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/samples/pom.xml b/samples/pom.xml index b59d3cdf3..823a7090f 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -18,7 +18,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 4f4ee0a69..4ce2f9b5e 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 @@ -34,7 +34,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 77c213f33..db858e9e9 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -14,7 +14,7 @@ com.google.cloud.samples shared-configuration - 1.0.18 + 1.0.21 @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 8.0.0 + 12.0.0 pom import @@ -51,7 +51,7 @@ junit junit - 4.13 + 4.13.1 test @@ -63,7 +63,7 @@ com.google.http-client google-http-client-gson - 1.35.0 + 1.36.0 test diff --git a/synth.metadata b/synth.metadata index f10802993..4929ab964 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,16 +3,83 @@ { "git": { "name": ".", - "remote": "git@github.com:chingor13/google-http-java-client.git", - "sha": "b1353f8cc7aaf22a30b31bd2ac72248d3a3a0a5d" + "remote": "https://github.com/googleapis/google-http-java-client.git", + "sha": "fe73acdd345ae3a2d7f214bec0058a6c0a122a7d" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "ce68c0e70d36c93ffcde96e9908fb4d94aa4f2e4" + "sha": "0762e8ee2ec21cdfc4d82020b985a104feb0453b" } } + ], + "generatedFiles": [ + ".github/CODEOWNERS", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/readme/synth.py", + ".github/release-please.yml", + ".github/trusted-contribution.yml", + ".github/workflows/auto-release.yaml", + ".github/workflows/ci.yaml", + ".github/workflows/samples.yaml", + ".kokoro/build.bat", + ".kokoro/build.sh", + ".kokoro/coerce_logs.sh", + ".kokoro/common.cfg", + ".kokoro/common.sh", + ".kokoro/continuous/common.cfg", + ".kokoro/continuous/java8.cfg", + ".kokoro/continuous/readme.cfg", + ".kokoro/dependencies.sh", + ".kokoro/linkage-monitor.sh", + ".kokoro/nightly/common.cfg", + ".kokoro/nightly/integration.cfg", + ".kokoro/nightly/java11.cfg", + ".kokoro/nightly/java7.cfg", + ".kokoro/nightly/java8-osx.cfg", + ".kokoro/nightly/java8-win.cfg", + ".kokoro/nightly/java8.cfg", + ".kokoro/nightly/samples.cfg", + ".kokoro/populate-secrets.sh", + ".kokoro/presubmit/clirr.cfg", + ".kokoro/presubmit/common.cfg", + ".kokoro/presubmit/dependencies.cfg", + ".kokoro/presubmit/integration.cfg", + ".kokoro/presubmit/java11.cfg", + ".kokoro/presubmit/java7.cfg", + ".kokoro/presubmit/java8-osx.cfg", + ".kokoro/presubmit/java8-win.cfg", + ".kokoro/presubmit/java8.cfg", + ".kokoro/presubmit/linkage-monitor.cfg", + ".kokoro/presubmit/lint.cfg", + ".kokoro/presubmit/samples.cfg", + ".kokoro/readme.sh", + ".kokoro/release/bump_snapshot.cfg", + ".kokoro/release/common.cfg", + ".kokoro/release/common.sh", + ".kokoro/release/drop.cfg", + ".kokoro/release/drop.sh", + ".kokoro/release/promote.cfg", + ".kokoro/release/promote.sh", + ".kokoro/release/publish_javadoc.cfg", + ".kokoro/release/publish_javadoc.sh", + ".kokoro/release/snapshot.cfg", + ".kokoro/release/snapshot.sh", + ".kokoro/release/stage.cfg", + ".kokoro/release/stage.sh", + ".kokoro/trampoline.sh", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "codecov.yaml", + "samples/install-without-bom/pom.xml", + "samples/pom.xml", + "samples/snapshot/pom.xml", + "samples/snippets/pom.xml" ] } \ No newline at end of file diff --git a/versions.txt b/versions.txt index ed4b40009..180b99457 100644 --- a/versions.txt +++ b/versions.txt @@ -1,17 +1,17 @@ # Format: # module:released-version:current-version -google-http-client:1.36.0:1.36.0 -google-http-client-bom:1.36.0:1.36.0 -google-http-client-parent:1.36.0:1.36.0 -google-http-client-android:1.36.0:1.36.0 -google-http-client-android-test:1.36.0:1.36.0 -google-http-client-apache-v2:1.36.0:1.36.0 -google-http-client-appengine:1.36.0:1.36.0 -google-http-client-assembly:1.36.0:1.36.0 -google-http-client-findbugs:1.36.0:1.36.0 -google-http-client-gson:1.36.0:1.36.0 -google-http-client-jackson2:1.36.0:1.36.0 -google-http-client-protobuf:1.36.0:1.36.0 -google-http-client-test:1.36.0:1.36.0 -google-http-client-xml:1.36.0:1.36.0 +google-http-client:1.37.0:1.37.0 +google-http-client-bom:1.37.0:1.37.0 +google-http-client-parent:1.37.0:1.37.0 +google-http-client-android:1.37.0:1.37.0 +google-http-client-android-test:1.37.0:1.37.0 +google-http-client-apache-v2:1.37.0:1.37.0 +google-http-client-appengine:1.37.0:1.37.0 +google-http-client-assembly:1.37.0:1.37.0 +google-http-client-findbugs:1.37.0:1.37.0 +google-http-client-gson:1.37.0:1.37.0 +google-http-client-jackson2:1.37.0:1.37.0 +google-http-client-protobuf:1.37.0:1.37.0 +google-http-client-test:1.37.0:1.37.0 +google-http-client-xml:1.37.0:1.37.0