FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Multi-release jar support (Java 9 to start) by rnett · Pull Request #348 · tensorflow/java · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) .xml  (4) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
    • pom.xml
      • pom.xml
        • MRTest.java
      • pom.xml
          • mrjar.xml
          • MRTest.java
1 change: 1 addition & 0 deletions tensorflow-core/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<description>Parent POM of TensorFlow core artifacts</description>

<modules>
<module>tensorflow-core-api-java9</module>
<module>tensorflow-core-generator</module>
<module>tensorflow-core-api</module>
</modules>
Expand Down
31 changes: 31 additions & 0 deletions tensorflow-core/tensorflow-core-api-java9/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Are you creating a new module to avoid errors in the IDE? Because I think there is a way to add java9+ source files in the same module (tensorflow-core-api) but in a separate folder, I'd personally prefer that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, it's for IDE issues.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think we should design our project based on IDE's "bugs", they might come up with a fix later (if none already exists?).

I'd be curious to give it a try if you place the JDK9 sources in, let say, src/java9

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, in theory, but I think this one was pretty severe. If I remember right @JimClarke5 tried this (w/ source folders) but put it off because of the IDE issues? I'm going to try it.

This is also fully supported by maven (see https://maven.apache.org/plugins/maven-compiler-plugin/multirelease.html) so it's not like it's a hack.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maven handles them nicely, but InteliJ complains of duplicate classes for those classes with different implementations as it doesn't seem to understand the difference between the 2 Java versions.

There is an open issue at:
Add support for building Java 9 multi-release jars

and
IntelliJ support to multi-release jars

As of Feb 2021, these still seems to be an open issues.

rnett Jul 6, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Testing it, it seems like you only get that error on the declarations, it's not that bad to just ignore. It keeps everything in the same module and has less maven configuration. There's no way to allow the source folder to use Java 9+ (or whatever) though, so using any 9+ APIs there will result in false positive errors. I'd prefer the multi-module solution, at least until those issues are fixed.

karllessard Jul 7, 2021
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I personally find the solution with multiple directories in the same module way cleaner, it requires almost no additional Maven configuration, nor any inter-module manual assembly, and it works like a charm outside the IDE.

I think it depends on how much code we want to put in these version-specific classes. If we just add the code that differs between JDK versions, then I'd be comfortable to just leave the src/main/java9 as a non-source directory by default and there will be no error. Of course the IDE won't be as efficient to assist you writing the code under that folder but it should be rare cases. But if we are heading to do full duplicates of the core classes (e.g. EagerSession), then it may become more painful. I would not recommend doing that though.

@Craigacp , any thoughts on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The only thing I had planed to put in there was some sort of Cleaner for resource scopes, so that should be fine.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core</artifactId>
<version>0.4.0-SNAPSHOT</version>
</parent>
<artifactId>tensorflow-core-api-java9</artifactId>
<packaging>jar</packaging>

<name>TensorFlow Core Java 9 API Classes</name>
<description>Java 9 classes for the Tensorflow Core API</description>

<properties>
<java.module.name>org.tensorflow.core.api.java9</java.module.name>
<maven.compiler.source>9</maven.compiler.source>
<maven.compiler.target>9</maven.compiler.target>
<maven.compiler.release>9</maven.compiler.release>
<maven.install.skip>true</maven.install.skip>
</properties>

<dependencies>
</dependencies>

<build>
<plugins>
</plugins>
</build>
</project>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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 9;
}
}
32 changes: 28 additions & 4 deletions tensorflow-core/tensorflow-core-api/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<description>Platform-dependent native code and pure-Java code for the TensorFlow machine intelligence library.</description>

<properties>
<maven.install.skip>false</maven.install.skip>
<native.build.skip>false</native.build.skip>
<javacpp.build.skip>${native.build.skip}</javacpp.build.skip>
<javacpp.parser.skip>${native.build.skip}</javacpp.parser.skip>
Expand Down Expand Up @@ -475,12 +476,35 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/mrjar.xml</descriptor>
</descriptors>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<mergeManifestMode>merge</mergeManifestMode>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

<!--
/* 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.
=======================================================================
*/
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>mvjar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>org.tensorflow:tensorflow-core-api</include>
</includes>
<binaries>
<unpack>true</unpack>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>org.tensorflow:tensorflow-core-api-java9</include>
</includes>
<binaries>
<outputDirectory>META-INF/versions/9</outputDirectory>
<unpack>true</unpack>
<includeDependencies>false</includeDependencies>
<unpackOptions>
<excludes>
<exclude>/META-INF/**</exclude>
</excludes>
</unpackOptions>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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;
}
}

Back | FazBrowse Home | New Git URL