From e56be8214e62551650b8c0bff3ac9332fb8d2ede Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Tue, 6 Jul 2021 15:06:12 -0700 Subject: [PATCH 01/11] Initial multi-release jar support Signed-off-by: Ryan Nett --- tensorflow-core/tensorflow-core-api/pom.xml | 48 +++++++++++++++++++ .../src/main/java/org/tensorflow/MRTest.java | 24 ++++++++++ .../src/main/java9/org/tensorflow/MRTest.java | 27 +++++++++++ 3 files changed, 99 insertions(+) create mode 100644 tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java create mode 100644 tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java diff --git a/tensorflow-core/tensorflow-core-api/pom.xml b/tensorflow-core/tensorflow-core-api/pom.xml index 4ebe1234e80..2a9078d5e9a 100644 --- a/tensorflow-core/tensorflow-core-api/pom.xml +++ b/tensorflow-core/tensorflow-core-api/pom.xml @@ -22,6 +22,9 @@ org.tensorflow.core.api 0.3.1 1.0.1 + + ${project.basedir}/src/main/java9 + ${project.build.directory}/classes-java9 @@ -143,6 +146,50 @@ + + org.apache.maven.plugins + maven-antrun-plugin + 3.0.0 + + + compile-java9 + compile + + + + + + + + run + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.2.0 + + + copy-resources + prepare-package + + copy-resources + + + ${project.build.outputDirectory}/META-INF/versions/9 + + + ${java9.build.outputDirectory} + + + + + + maven-compiler-plugin 3.8.0 @@ -372,6 +419,7 @@ ${java.module.name} + true diff --git a/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java b/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java new file mode 100644 index 00000000000..8d9ea407292 --- /dev/null +++ b/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java @@ -0,0 +1,24 @@ +/* + Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +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. +======================================================================= + +*/ +package org.tensorflow; + +public class MRTest { + public static int version() { + return 8; + } +} diff --git a/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java b/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java new file mode 100644 index 00000000000..e283f6c87e5 --- /dev/null +++ b/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java @@ -0,0 +1,27 @@ +/* + Copyright 2021 The TensorFlow Authors. All Rights Reserved. + + 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. + ======================================================================= + + */ +package org.tensorflow; + +import java.lang.ref.Cleaner; + +public class MRTest { + public static int version(){ + Cleaner.create(); + return 9; + } +} From 98886fef4a2f51ec200b90d531ca02c9b430c154 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sun, 11 Jul 2021 17:29:24 -0700 Subject: [PATCH 02/11] Add test, make package private Signed-off-by: Ryan Nett --- .../src/main/java/org/tensorflow/MRTest.java | 4 +- .../src/main/java9/org/tensorflow/MRTest.java | 7 +--- .../java/org/tensorflow/MultiReleaseTest.java | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/MultiReleaseTest.java diff --git a/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java b/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java index 8d9ea407292..c0dafb416ef 100644 --- a/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java +++ b/tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java @@ -17,8 +17,8 @@ */ package org.tensorflow; -public class MRTest { - public static int version() { +class MRTest { + static int version() { return 8; } } diff --git a/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java b/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java index e283f6c87e5..f95db519a62 100644 --- a/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java +++ b/tensorflow-core/tensorflow-core-api/src/main/java9/org/tensorflow/MRTest.java @@ -17,11 +17,8 @@ */ package org.tensorflow; -import java.lang.ref.Cleaner; - -public class MRTest { - public static int version(){ - Cleaner.create(); +class MRTest { + static int version(){ return 9; } } diff --git a/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/MultiReleaseTest.java b/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/MultiReleaseTest.java new file mode 100644 index 00000000000..709fb7dc032 --- /dev/null +++ b/tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/MultiReleaseTest.java @@ -0,0 +1,38 @@ +/* + Copyright 2021 The TensorFlow Authors. All Rights Reserved. + + 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. + ======================================================================= + + */ +package org.tensorflow; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class MultiReleaseTest { + + @Test + public void testMultirelease(){ + String javaVersion = System.getProperty("java.version"); + System.out.println("Testing on Java version " + javaVersion); + int value = MRTest.version(); + if(javaVersion.compareTo("9") >= 0){ + assertEquals(9, value); + } else { + assertEquals(8, value); + } + } + +} From 6330c52eb193381f193ee54f0b60d159a0d4b1b6 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sun, 11 Jul 2021 17:39:01 -0700 Subject: [PATCH 03/11] Add JDK 8 test to CI Signed-off-by: Ryan Nett --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 969ebe9aecc..606a29f0db1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,32 @@ jobs: - name: Run lint checks run: | mvn compiler:compile -Pdev,jdk11 -B -U -e + quick-build-jdk8: + if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'CI build') + runs-on: ubuntu-latest + container: centos:7 + steps: + - name: Checkout repository + uses: actions/checkout@v1 + - name: Install environment + run: | + yum -y update + yum -y install centos-release-scl-rh epel-release + yum -y install java-1.8.0-openjdk-devel devtoolset-7 + echo Downloading Maven + curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz + tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ + ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/bin/mvn + - name: Build project + run: | + source scl_source enable devtoolset-7 || true + export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) + echo $JAVA_HOME + mvn -version + mvn clean install -Pdev -B -U -e -Dlint.skip=true + - name: Run lint checks + run: | + mvn compiler:compile -Pdev -B -U -e check-format: if: github.event_name == 'pull_request' runs-on: ubuntu-latest From 5d0c66de98f40c3a864fd4946d0c7a33ded313fd Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sun, 11 Jul 2021 18:28:06 -0700 Subject: [PATCH 04/11] Use setup-java, don't lint check --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 606a29f0db1..dd69d20dc6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,12 +46,16 @@ jobs: container: centos:7 steps: - name: Checkout repository - uses: actions/checkout@v1 + uses: actions/checkout@v1 + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: 8 - name: Install environment run: | yum -y update yum -y install centos-release-scl-rh epel-release - yum -y install java-1.8.0-openjdk-devel devtoolset-7 + yum -y install devtoolset-7 echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ @@ -63,9 +67,6 @@ jobs: echo $JAVA_HOME mvn -version mvn clean install -Pdev -B -U -e -Dlint.skip=true - - name: Run lint checks - run: | - mvn compiler:compile -Pdev -B -U -e check-format: if: github.event_name == 'pull_request' runs-on: ubuntu-latest From a6af976622c1b025e39003c4126c70209c36a0ba Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sun, 11 Jul 2021 20:10:39 -0700 Subject: [PATCH 05/11] Use compiler plugin instead of ant Signed-off-by: Ryan Nett --- tensorflow-core/tensorflow-core-api/pom.xml | 63 +++++-------------- .../java/org/tensorflow/MultiReleaseTest.java | 29 +++++---- 2 files changed, 30 insertions(+), 62 deletions(-) diff --git a/tensorflow-core/tensorflow-core-api/pom.xml b/tensorflow-core/tensorflow-core-api/pom.xml index 2a9078d5e9a..fde9a53c51a 100644 --- a/tensorflow-core/tensorflow-core-api/pom.xml +++ b/tensorflow-core/tensorflow-core-api/pom.xml @@ -22,9 +22,6 @@ org.tensorflow.core.api 0.3.1 1.0.1 - - ${project.basedir}/src/main/java9 - ${project.build.directory}/classes-java9 @@ -146,50 +143,6 @@ - - org.apache.maven.plugins - maven-antrun-plugin - 3.0.0 - - - compile-java9 - compile - - - - - - - - run - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.2.0 - - - copy-resources - prepare-package - - copy-resources - - - ${project.build.outputDirectory}/META-INF/versions/9 - - - ${java9.build.outputDirectory} - - - - - - maven-compiler-plugin 3.8.0 @@ -216,6 +169,22 @@ ${project.basedir}/src/gen/annotations + + compile-java-9 + compile + + compile + + + 9 + 9 + 9 + + ${project.basedir}/src/main/java9 + + true + +