-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-release jar support (Java 9 to start) #348
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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" | ||
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> |
24 changes: 24 additions & 0 deletions
24
tensorflow-core/tensorflow-core-api-java9/src/main/java/org/tensorflow/MRTest.java
This file contains 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; | ||
} | ||
} |
This file contains 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
54 changes: 54 additions & 0 deletions
54
tensorflow-core/tensorflow-core-api/src/assembly/mrjar.xml
This file contains 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> |
24 changes: 24 additions & 0 deletions
24
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/MRTest.java
This file contains 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; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's for IDE issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I had planed to put in there was some sort of Cleaner for resource scopes, so that should be fine.