diff --git a/.kokoro/continuous/java11.cfg b/.kokoro/continuous/java11.cfg new file mode 100644 index 000000000..709f2b4c7 --- /dev/null +++ b/.kokoro/continuous/java11.cfg @@ -0,0 +1,7 @@ +# 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/presubmit/java11.cfg b/.kokoro/presubmit/java11.cfg new file mode 100644 index 000000000..709f2b4c7 --- /dev/null +++ b/.kokoro/presubmit/java11.cfg @@ -0,0 +1,7 @@ +# 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/README.md b/README.md index 0607464c7..e96462c50 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ Java Version | Status ------------ | ------ Java 7 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java7.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java7.html) Java 8 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java8.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java8.html) -Java 10 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java10.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java10.html) +Java 11 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java11.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/google-api-java-client/java11.html) ## Dependencies This library is built on top of two common libraries, also built by Google, and also designed to diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java index 5a23f315c..1de14b99a 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java @@ -173,12 +173,24 @@ private static ApiClientVersion getDefault() { private static String getJavaVersion() { String version = System.getProperty("java.version"); - // Java 9 doesn't report a semver here: instead it's something like 9-Debian+0-x-y - if (version.startsWith("9")) { - return "9.0.0"; - } else { - return formatSemver(version); + if (version == null) { + return null; } + + // Try parsing the full semver + String formatted = formatSemver(version, null); + if (formatted != null) { + return formatted; + } + + // Some java versions start with the version number and may contain extra info + // e.g. Java 9 reports something like 9-Debian+0-x-y while Java 11 reports "11" + Matcher m = Pattern.compile("^(\\d+)[^\\d]?").matcher(version); + if (m.find()) { + return m.group(1) + ".0.0"; + } + + return null; } private static String formatName(String name) { @@ -187,6 +199,10 @@ private static String formatName(String name) { } private static String formatSemver(String version) { + return formatSemver(version, version); + } + + private static String formatSemver(String version, String defaultValue) { if (version == null) { return null; } @@ -196,7 +212,7 @@ private static String formatSemver(String version) { if (m.find()) { return m.group(1); } else { - return version; + return defaultValue; } } } diff --git a/pom.xml b/pom.xml index b4ffd1e3a..42800549c 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.0.1 attach-javadocs @@ -386,7 +386,7 @@ maven-javadoc-plugin - -Xdoclint:none + none