-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use AdoptOpenJDK image as default base image in Jib CLI Jar #3075
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3075 +/- ##
============================================
+ Coverage 71.15% 71.19% +0.03%
- Complexity 2307 2312 +5
============================================
Files 278 278
Lines 9746 9759 +13
Branches 989 990 +1
============================================
+ Hits 6935 6948 +13
Misses 2471 2471
Partials 340 340
Continue to review full report at Codecov.
|
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 plan is to check the Java version and choose between Java 8 and 11, right?
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessors.java
Show resolved
Hide resolved
@@ -198,8 +198,9 @@ public Integer call() { | |||
CacheDirectories cacheDirectories = | |||
CacheDirectories.from(commonCliOptions, jarFile.toAbsolutePath().getParent()); | |||
JarProcessor processor = JarProcessors.from(jarFile, cacheDirectories, mode); | |||
Integer jarJavaVersion = JarProcessors.getJavaMajorVersion(jarFile); |
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.
Instead of making getJavaMajorVersion()
public and calling it twice (although I have no idea if there will be noticeable performance impact when "opening a jar" twice with new JarFile()
in this case), how about adding a field JarProcessor.javaVersion
and a getter for it? (Maybe the current getJavaMajorVersion()
should be renamed to, say, {read|determine}JavaMajorVersion
if we do so.) That way, we can avoid running the code twice. I see JarProcessor
is already passed into toJibContainerBuilder()
, so it just needs to call the getter.
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.
Ah I missed this. Thanks for pointing this out - adding a getter to JarProcessor
is a good idea. Since interfaces don't allow instance fields, I had to add a parameter to the constructors of the JarProcessor
instances which resulted in a couple of extra changes to the tests.
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.
LGTM, only minor comments.
In many cases, the previous approach to call some methods multiple times is better for readability and compact code in general. It's just that this was a special case involving opening a jar. Although it can still be the case that opening and inspecting is really quick and all of this is meaningless. But yeah, I think the current pattern doesn't look bad.
No description provided.