before_code
stringlengths
30
149k
reviewer_comment
stringlengths
16
20.6k
after_code
stringlengths
30
163k
diff_context
stringlengths
0
22.4k
file_path
stringlengths
6
155
comment_line
int64
0
26
language
stringclasses
19 values
quality_score
float64
0.07
1
comment_type
stringclasses
9 values
comment_length
int64
16
20.6k
before_lines
int64
2
4.61k
after_lines
int64
2
4.4k
is_negative
bool
2 classes
pr_title
stringlengths
7
140
pr_number
int64
18
61.2k
repo_name
stringclasses
29 values
repo_stars
int64
321
56k
repo_language
stringclasses
14 values
reviewer_username
stringclasses
378 values
author_username
stringclasses
739 values
user
stringlengths
361
200k
assistant
stringlengths
16
20.6k
system
stringclasses
1 value
* 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 sp...
```suggestion private static final String SPRING_BOOT_RESOURCE_DIR = "jar/springboot"; ``` And maybe this can just be `jar/springboot/springbootJar.jar`?
* 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 sp...
@@ -0,0 +1,49 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.714
question
158
45
43
false
Implement JarProcessor to determine jar type.
2,797
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement JarProcessor to determine jar type. BEFORE CODE: * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or...
```suggestion private static final String SPRING_BOOT_RESOURCE_DIR = "jar/springboot"; ``` And maybe this can just be `jar/springboot/springbootJar.jar`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* * 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 Licen...
I think `STANDARD` is probably the more standard term?
* * 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 Licen...
@@ -0,0 +1,52 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.357
question
54
45
45
false
Implement JarProcessor to determine jar type.
2,797
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement JarProcessor to determine jar type. BEFORE CODE: * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distribu...
I think `STANDARD` is probably the more standard term?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @param tarImage the {@link TarImage} that defines the path to the base image * @return a new {@link JavaContainerBuilder} */ public static JavaContainerBuilder from(TarImage tarImage) { return new JavaContainerBuilder(Jib.from(tarImage)); } private final JibContainerBuilder jibContainerBuilder; ...
This should remain an instance variable (non-`static`), scoped and limited only to each individual instance. `static` means a global variable shared by every instance of `JavaContainerBuilder`.
* @param tarImage the {@link TarImage} that defines the path to the base image * @return a new {@link JavaContainerBuilder} */ public static JavaContainerBuilder from(TarImage tarImage) { return new JavaContainerBuilder(Jib.from(tarImage)); } private final JibContainerBuilder jibContainerBuilder; ...
@@ -204,7 +204,7 @@ public static JavaContainerBuilder from(TarImage tarImage) { private RelativeUnixPath dependenciesDestination = RelativeUnixPath.get("libs"); private RelativeUnixPath othersDestination = RelativeUnixPath.get("classpath"); @Nullable private String mainClass; - private ModificationTimeProvid...
jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java
26
Java
0.571
suggestion
193
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * @param tarImage the {@link TarImage} that defines the path to the base image * @return a new {@link JavaContain...
This should remain an instance variable (non-`static`), scoped and limited only to each individual instance. `static` means a global variable shared by every instance of `JavaContainerBuilder`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @param pathInContainer path in container. */ public static void addFileToLayer( Map<LayerType, FileEntriesLayer.Builder> layerBuilders, LayerType layerType, Path sourceFile, AbsoluteUnixPath pathInContainer) { if (!layerBuilders.containsKey(layerType)) { layerBuilders.put(lay...
Should remain an instance method. And note `JavaContainerBuilder` is a public API. Probably we don't want to expose this internal helper method. Just asking: did we decide to use `JavaContainerBuilder` instead of `JibContainerBuilder` for some reason? It's fine if `JavaContainerBuilder` works, but just saying I b...
} Instant modificationTime = modificationTimeProvider.get(sourceFile, pathInContainer); layerBuilders.get(layerType).addEntry(sourceFile, pathInContainer, modificationTime); } private void addDirectoryContentsToLayer( Map<LayerType, FileEntriesLayer.Builder> layerBuilders, LayerType layerTy...
@@ -691,7 +700,18 @@ private void addFileToLayer( layerBuilders.get(layerType).addEntry(sourceFile, pathInContainer, modificationTime); } - private void addDirectoryContentsToLayer( + /** + * Adds the contents of a directory to a {@link FileEntriesLayer.Builder}. + * + * @param layerBuilders map that ...
jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java
26
Java
0.643
refactor
359
50
30
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * @param pathInContainer path in container. */ public static void addFileToLayer( Map<LayerType, FileEntr...
Should remain an instance method. And note `JavaContainerBuilder` is a public API. Probably we don't want to expose this internal helper method. Just asking: did we decide to use `JavaContainerBuilder` instead of `JibContainerBuilder` for some reason? It's fine if `JavaContainerBuilder` works, but just saying I b...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return jibContainerBuilder; } private JavaContainerBuilder addDirectory( List<PathPredicatePair> addedPaths, Path directory, Predicate<Path> filter) throws NoSuchFileException, NotDirectoryException { if (!Files.exists(directory)) { throw new NoSuchFileException(directory.toString()); ...
Ditto. We need to think twice before making this part of the public API surface.
return jibContainerBuilder; } private JavaContainerBuilder addDirectory( List<PathPredicatePair> addedPaths, Path directory, Predicate<Path> filter) throws NoSuchFileException, NotDirectoryException { if (!Files.exists(directory)) { throw new NoSuchFileException(directory.toString()); ...
@@ -679,7 +679,16 @@ private JavaContainerBuilder addDirectory( return this; } - private void addFileToLayer( + /** + * Adds a file to a {@link FileEntriesLayer.Builder}. + * + * @param layerBuilders map that keeps track of all layers, with the key being the layer type and + * value being a {@li...
jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java
26
Java
0.214
suggestion
83
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java PR Title: Implement explode mode for regular jar. BEFORE CODE: return jibContainerBuilder; } private JavaContainerBuilder addDirectory( List<PathPredicatePair> addedPa...
Ditto. We need to think twice before making this part of the public API surface.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} /** * Determines whether the jar is a spring boot or regular jar, given a path to the jar. * * @param jarPath path to the jar. * @return the jar type. * @throws IOException if I/O error occurs when opening the file. */ public static JarType determineJarType(Path jarPath) throws IOException { ...
I think this should be configurable and if not then use a temporary directory. Potentially we could have a jib local build directory that we can pass in.
/** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFi...
@@ -49,4 +66,88 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.429
suggestion
156
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: } /** * Determines whether the jar is a spring boot or regular jar, given a path to the jar. * * @param jarPat...
I think this should be configurable and if not then use a temporary directory. Potentially we could have a jib local build directory that we can pass in.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Determine class and resource files in the directory containing jar contents and create // FileEntriesLayer for each type of layer (class or resource), while maintaining the // file's original project structure. FileEntriesLayer classesLayer = addDirectoryContentsToLayer( File...
`"Class-Path"` -> `Attributes.Name.CLASS_PATH`
// dependencies as entries. If Class-Path is not present in the jar's manifest then skip adding // a dependencies layer. JarFile jarFile = new JarFile(jarPath.toFile()); String classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH); if (classPath != null) ...
@@ -49,4 +66,88 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.214
suggestion
46
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: // Determine class and resource files in the directory containing jar contents and create // FileEntriesLayer for e...
`"Class-Path"` -> `Attributes.Name.CLASS_PATH`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// FileEntriesLayer for each type of layer (class or resource), while maintaining the // file's original project structure. FileEntriesLayer classesLayer = addDirectoryContentsToLayer( FileEntriesLayer.builder(), tempDirectoryPath, isClassFile, ...
`" "` -> `"//s+"` for handling any kind of white space I might also do `classPath.trim()` ?
JarFile jarFile = new JarFile(jarPath.toFile()); String classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH); if (classPath != null) { List<Path> dependencies = Splitter.onPattern("\\s+") .splitToList(classPath.trim()) ...
@@ -49,4 +66,88 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.357
question
92
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: // FileEntriesLayer for each type of layer (class or resource), while maintaining the // file's original project str...
`" "` -> `"//s+"` for handling any kind of white space I might also do `classPath.trim()` ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
tempDirectoryPath, isClassFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))) .setName("Classes") .build(); FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( FileEntriesLayer.builder(), ...
Do we have to fail here? Would this code path also handle the shaded jar style jars (which may not have `Class-Path` entries)?
Splitter.onPattern("\\s+") .splitToList(classPath.trim()) .stream() .map(Paths::get) .collect(Collectors.toList()); FileEntriesLayer.Builder dependenciesLayerBuilder = FileEntriesLayer.builder().setName("dependencies"); dependencies...
@@ -49,4 +66,88 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.643
bug
126
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: tempDirectoryPath, isClassFile, APP_ROOT.resolve(RelativeUnixPath.get("explo...
Do we have to fail here? Would this code path also handle the shaded jar style jars (which may not have `Class-Path` entries)?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @return the jar type. * @throws IOException if I/O error occurs when opening the file. */ public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } ...
Another option is `... isResrouceFile = isClassFile.negate()`, which I think works better in this case.
* @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { re...
@@ -49,4 +64,85 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.571
suggestion
103
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * @return the jar type. * @throws IOException if I/O error occurs when opening the file. */ public static JarType...
Another option is `... isResrouceFile = isClassFile.negate()`, which I think works better in this case.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return JarType.STANDARD; } /** * Explode jar and create three layers for classes, resources and dependencies on container. * * @param jarPath path to jar file. * @return list of {@link FileEntriesLayer}. * @throws IOException if I/O error occurs when opening the file. */ public static List<...
How about "explodedJarRoot" or "localExplodedJarRoot"? `tempDirectoryPath` gives the impression that it's a directory for a callee to use as a temp storage.
} return JarType.STANDARD; } /** * Explodes jar and create three layers for classes, resources and dependencies on container. * * @param jarPath path to jar file * @param tempDirPath path to temporary jib local directory * @return list of {@link FileEntriesLayer} * @throws IOException if ...
@@ -49,4 +64,85 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.571
question
157
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: return JarType.STANDARD; } /** * Explode jar and create three layers for classes, resources and dependencies on ...
How about "explodedJarRoot" or "localExplodedJarRoot"? `tempDirectoryPath` gives the impression that it's a directory for a callee to use as a temp storage.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
FileEntriesLayer classesLayer = addDirectoryContentsToLayer( FileEntriesLayer.builder(), tempDirectoryPath, isClassFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))) .setName("Classes") .build(); FileEntrie...
super nit: ```suggestion dependencies.add(Paths.get(dependency)); ``` Just FYI, another way is ``` .splitToList().stream().map(Paths::get).collect(Collectors.toList()); ```
JarFile jarFile = new JarFile(jarPath.toFile()); String classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH); if (classPath != null) { List<Path> dependencies = Splitter.onPattern("\\s+") .splitToList(classPath.trim()) ...
@@ -49,4 +64,85 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.714
suggestion
191
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: FileEntriesLayer classesLayer = addDirectoryContentsToLayer( FileEntriesLayer.builder(), ...
super nit: ```suggestion dependencies.add(Paths.get(dependency)); ``` Just FYI, another way is ``` .splitToList().stream().map(Paths::get).collect(Collectors.toList()); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.setName("Resources") .build(); // Get dependencies from Class-Path in the jar's manifest and create a FileEntriesLayer.Builder // with these dependencies as entries. List<Path> dependencies = new ArrayList<>(); JarFile jarFile = new JarFile(jarPath.toFile()); String classPa...
I believe we customarily put the most frequently changing layers at the bottom (needs to double-check). So perhaps ```suggestion layers.add(dependenciesLayerBuilder.build()); layers.add(resourcesLayer); layers.add(classesLayer); ```
dependenciesLayerBuilder.addEntry( path, APP_ROOT.resolve(RelativeUnixPath.get("dependencies")).resolve(path))); layers.add(dependenciesLayerBuilder.build()); } Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class"); Predicate<Path> isRe...
@@ -49,4 +64,85 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.786
suggestion
251
49
49
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: .setName("Resources") .build(); // Get dependencies from Class-Path in the jar's manifest and c...
I believe we customarily put the most frequently changing layers at the bottom (needs to double-check). So perhaps ```suggestion layers.add(dependenciesLayerBuilder.build()); layers.add(resourcesLayer); layers.add(classesLayer); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* License for the specific language governing permissions and limitations under * the License. */ package com.google.cloud.tools.jib.cli.jar; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; import com.google.cloud.tools.jib.api.buildplan.Fi...
```suggestion private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithCp.jar"; ``` Also applies to other constants.
* License for the specific language governing permissions and limitations under * the License. */ package com.google.cloud.tools.jib.cli.jar; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; import com.google.cloud.tools.jib.api.buildplan.Fi...
@@ -18,17 +18,24 @@ import static com.google.common.truth.Truth.assertThat; +import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; +import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; +import com.google.cloud.tools.jib.api.buildplan.FileEntry; import com.google.cloud.tools.jib.cli.jar.Ja...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.714
suggestion
163
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * License for the specific language governing permissions and limitations under * the License. */ package com.google...
```suggestion private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithCp.jar"; ``` Also applies to other constants.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
AbsoluteUnixPath.get("/app/explodedJar/directory1/class1.class"), AbsoluteUnixPath.get("/app/explodedJar/directory1/class2.class"), AbsoluteUnixPath.get("/app/explodedJar/directory2"), AbsoluteUnixPath.get("/app/explodedJar/directory2/class4.class"), AbsoluteU...
Assert before attempting `layers.get(2)`. Otherwise, for example, if the code base accidentally changes to produce only two layer, we'll hit an index-out-of-bound error when attempting `.get(2)`.
.collect(Collectors.toList()); assertThat(actualResourcesPath) .containsExactly( AbsoluteUnixPath.get("/app/explodedJar/META-INF"), AbsoluteUnixPath.get("/app/explodedJar/META-INF/MANIFEST.MF")); // Validate classes layer. List<AbsoluteUnixPath> actualClassesPath...
@@ -44,4 +51,77 @@ public void testDetermineJarType_standard() throws IOException, URISyntaxExcepti JarType jarType = JarProcessor.determineJarType(standardJar); assertThat(jarType).isEqualTo(JarType.STANDARD); } + + @Test + public void testExplodeMode_standard() throws IOException, URISyntaxException { ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.714
suggestion
195
48
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement explode mode for regular jar. BEFORE CODE: AbsoluteUnixPath.get("/app/explodedJar/directory1/class1.class"), AbsoluteUnixPath.get("/app/exp...
Assert before attempting `layers.get(2)`. Otherwise, for example, if the code base accidentally changes to produce only two layer, we'll hit an index-out-of-bound error when attempting `.get(2)`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Path springBootJar = Paths.get(Resources.getResource(SPRING_BOOT_RESOURCE_DIR).toURI()); JarType jarType = JarProcessor.determineJarType(springBootJar); assertThat(jarType).isEqualTo(JarType.SPRING_BOOT); } @Test public void testDetermineJarType_standard() throws IOException, URISyntaxException { ...
I guess no need to assert the size when using `.containsExactly`?
"jar/standard/standardJarWithoutClassPath.jar"; private static final String STANDARD_JAR_WITH_ONLY_CLASSES = "jar/standard/standardJarWithOnlyClasses.jar"; private static final String STANDARD_JAR_EMPTY = "jar/standard/emptyStandardJar.jar"; @Rule public final TemporaryFolder temporaryFolder = new Te...
@@ -44,4 +51,77 @@ public void testDetermineJarType_standard() throws IOException, URISyntaxExcepti JarType jarType = JarProcessor.determineJarType(standardJar); assertThat(jarType).isEqualTo(JarType.STANDARD); } + + @Test + public void testExplodeMode_standard() throws IOException, URISyntaxException { ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.357
question
65
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement explode mode for regular jar. BEFORE CODE: Path springBootJar = Paths.get(Resources.getResource(SPRING_BOOT_RESOURCE_DIR).toURI()); JarType jarType = JarPr...
I guess no need to assert the size when using `.containsExactly`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @throws IOException if I/O error occurs when opening the file. */ public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; ...
Once a `Closeable` class is closed, it's permanently shutdown and not usable. So you should put the entire code that needs to use `localExplodedJarRoot` into the try-resource block.
public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } /** * Explodes jar and create three layers for classes, resource...
@@ -49,4 +67,97 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.571
suggestion
181
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * @throws IOException if I/O error occurs when opening the file. */ public static JarType determineJarType(Path jarP...
Once a `Closeable` class is closed, it's permanently shutdown and not usable. So you should put the entire code that needs to use `localExplodedJarRoot` into the try-resource block.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, @Nullable Path tempDirPath) throws IOException { Path localExplodedJarRoot; if (tempDirPath == null) { try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { localExplodedJarRoot = tempDirector...
Minor point, but Jib build plugins use non-capitalized name "classes" (as defined in `JavaContainerBuilder.LayerType`).
Path localExplodedJarRoot = tempDirPath; ZipUtil.unzip(jarPath, localExplodedJarRoot); List<FileEntriesLayer> layers = new ArrayList<>(); // Get dependencies from Class-Path in the jar's manifest and add a layer with these // dependencies as entries. If Class-Path is not present in the jar's manife...
@@ -49,4 +67,97 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.714
nitpick
119
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, @Nullable Path tempDirPath) throws IOException...
Minor point, but Jib build plugins use non-capitalized name "classes" (as defined in `JavaContainerBuilder.LayerType`).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ package com.google.cloud.tools.jib.cli.jar; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; import com.google.cloud.tools.jib.api.buildplan.FileEntry; import com.google.clou...
```suggestion private static final String SPRING_BOOT_JAR = "jar/springboot/springboot_sample.jar"; private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithClassPath.jar"; private static final String STANDARD_JAR = "jar/standard/standardJar.jar"; ```
*/ package com.google.cloud.tools.jib.cli.jar; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; import com.google.cloud.tools.jib.api.buildplan.FileEntry; import com.google.clou...
@@ -18,17 +18,25 @@ import static com.google.common.truth.Truth.assertThat; +import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; +import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; +import com.google.cloud.tools.jib.api.buildplan.FileEntry; import com.google.cloud.tools.jib.cli.jar.Ja...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.786
suggestion
308
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement explode mode for regular jar. BEFORE CODE: */ package com.google.cloud.tools.jib.cli.jar; import static com.google.common.truth.Truth.assertThat; import com.go...
```suggestion private static final String SPRING_BOOT_JAR = "jar/springboot/springboot_sample.jar"; private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithClassPath.jar"; private static final String STANDARD_JAR = "jar/standard/standardJar.jar"; ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.setName("Classes") .build(); FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( FileEntriesLayer.builder(), localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))) ...
You can remove this `else` branch if you initialize the variable on line 118 like `List<Path> dependencies = new ArrayList<>();`. How about skipping adding the dependencies layer if it's empty? To be fair, it shouldn't matter, because I believe jib-core will drop any empty layers. But we can be conservative at this ...
Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class"); Predicate<Path> isResourceFile = isClassFile.negate(); // Determine class and resource files in the directory containing jar contents and create // FileEntriesLayer for each type of layer (classes or resources), wh...
@@ -49,4 +67,97 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.643
refactor
330
51
45
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: .setName("Classes") .build(); FileEntriesLayer resourcesLayer = addDirectoryContentsToLa...
You can remove this `else` branch if you initialize the variable on line 118 like `List<Path> dependencies = new ArrayList<>();`. How about skipping adding the dependencies layer if it's empty? To be fair, it shouldn't matter, because I believe jib-core will drop any empty layers. But we can be conservative at this ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.stream.Collectors; import javax.annotation.Nullable; /** Process jar file contents and create layers. */ public class JarProcessor { private static final AbsoluteUnixPath APP_ROOT = AbsoluteUnixPath.get("/app"); /** * Jar Type. ...
I think an enum is unnecessary if this is only to define layer names. It looks okay to me to use the string literals in the code as before.
import java.util.stream.Collectors; /** Process jar file contents and create layers. */ public class JarProcessor { private static final AbsoluteUnixPath APP_ROOT = AbsoluteUnixPath.get("/app"); /** * Jar Type. * * <ul> * <li>{@code STANDARD} a regular jar. * <li>{@code SPRING_BOOT} a spring b...
@@ -35,6 +54,29 @@ SPRING_BOOT; } + /** Represents the different types of layers. */ + @VisibleForTesting + public enum ExplodedModeLayerType {
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.429
suggestion
139
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.stream.Collectors; import javax.annotation.N...
I think an enum is unnecessary if this is only to define layer names. It looks okay to me to use the string literals in the code as before.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* * @param jarPath path to the jar. * @return the jar type. * @throws IOException if I/O error occurs when opening the file. */ public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { ...
Oh! I realized there's a problem. When `TempDirectoryProvider` is closed, all the contents (i.e., exploded jar) will be cleaned up. That is, nothing left when exiting the method. However, tar creating happens far later in jib-core. I guess this method should just use `tempDirPath` (should not be `@Nullable`), unless th...
List<FileEntriesLayer> layers = new ArrayList<>(); // Get dependencies from Class-Path in the jar's manifest and add a layer with these // dependencies as entries. If Class-Path is not present in the jar's manifest then skip adding // a dependencies layer. JarFile jarFile = new JarFile(jarPath.toFi...
@@ -49,4 +91,92 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.786
question
489
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * * @param jarPath path to the jar. * @return the jar type. * @throws IOException if I/O error occurs when openi...
Oh! I realized there's a problem. When `TempDirectoryProvider` is closed, all the contents (i.e., exploded jar) will be cleaned up. That is, nothing left when exiting the method. However, tar creating happens far later in jib-core. I guess this method should just use `tempDirPath` (should not be `@Nullable`), unless th...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))) .setName(ExplodedModeLayerType.CLASSES.getName()) .build(); FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( FileEntriesLayer.builder(), localExplodedJar...
Nit: can chain `...builder().setName("dependencies")`.
/* * Copyright 2020 Google LLC. * * 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...
@@ -49,4 +91,92 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.357
nitpick
54
51
149
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))) .setName(ExplodedModeLayerType.CLASSE...
Nit: can chain `...builder().setName("dependencies")`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @return list of {@link FileEntriesLayer}. * @throws IOException if I/O error occurs when opening the jar file or if the directory for the * temporary directory path provided doesn't exist. */ public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath) throws IOExcep...
what about a jar that contains no resources?
* @return list of {@link FileEntriesLayer} * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist */ public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath) throws IOException { Path localExploded...
@@ -49,4 +65,88 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.071
question
46
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * @return list of {@link FileEntriesLayer}. * @throws IOException if I/O error occurs when opening the jar file or if ...
what about a jar that contains no resources?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } /** * Explode jar and create three layers for classes, resources...
Perhaps I should've brought this up before, I'm also curious if we should persist the `MANIFEST.MF` after exploding the jar. That manifest only applies when using a Jar. Does it make sense to filter it out when building container layers?
public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile()); if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } /** * Explodes jar and create three layers for classes, resource...
@@ -49,4 +65,88 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.643
question
237
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
loosebazooka
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: public static JarType determineJarType(Path jarPath) throws IOException { JarFile jarFile = new JarFile(jarPath.toFile...
Perhaps I should've brought this up before, I'm also curious if we should persist the `MANIFEST.MF` after exploding the jar. That manifest only applies when using a Jar. Does it make sense to filter it out when building container layers?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithClassPath.jar"; private static final String STANDARD_JAR_WITHOUT_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithoutClassPath.jar"; private static final String STANDARD_JAR = "jar/standard/standardJar.j...
Any reason not using `@Rule public final TemporaryFolder` as we do in other tests?
private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithClassPath.jar"; private static final String STANDARD_JAR_WITHOUT_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithoutClassPath.jar"; private static final String STANDARD_JAR_WITH_ONLY_CLASSES = "ja...
@@ -18,30 +18,181 @@ import static com.google.common.truth.Truth.assertThat; +import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; +import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; +import com.google.cloud.tools.jib.api.buildplan.FileEntry; import com.google.cloud.tools.jib.cli.jar.J...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.357
question
82
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement explode mode for regular jar. BEFORE CODE: private static final String STANDARD_JAR_WITH_CLASS_PATH_MANIFEST = "jar/standard/standardJarWithClassPath.jar";...
Any reason not using `@Rule public final TemporaryFolder` as we do in other tests?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
JarFile jarFile = new JarFile(jarPath.toFile()); String classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH); if (classPath != null) { List<Path> dependencies = Splitter.onPattern("\\s+") .splitToList(classPath.trim()) ...
Sorry, looking at this again, maybe this doesn't need to accept a builder. It can create it locally. That said, it can accept a layer name instead? For example, ```java private static FileEntriesLayer createLayerFromDirectoryContents(String layerName, ...) { FileEntriesLayer.Builder builder = FileEntriesLayer.buil...
// Determine class and resource files in the directory containing jar contents and create // FileEntriesLayer for each type of layer (classes or resources), while maintaining the // file's original project structure. FileEntriesLayer classesLayer = addDirectoryContentsToLayer( "class...
@@ -49,4 +65,86 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container. + * + * @param jarPath path to jar file. + * @param tempDirPath path to te...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.857
question
419
43
41
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: JarFile jarFile = new JarFile(jarPath.toFile()); String classPath = jarFile.getManifest().getMainAttributes(...
Sorry, looking at this again, maybe this doesn't need to accept a builder. It can create it locally. That said, it can accept a layer name instead? For example, ```java private static FileEntriesLayer createLayerFromDirectoryContents(String layerName, ...) { FileEntriesLayer.Builder builder = FileEntriesLayer.buil...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
"jar/standard/standardJarWithOnlyClasses.jar"; private static final String STANDARD_JAR_EMPTY = "jar/standard/emptyStandardJar.jar"; @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Test public void testDetermineJarType_springBoot() throws IOException, URISyntaxException { ...
super nit: I think this comment is obvious enough to be removed.
"jar/standard/standardJarWithOnlyClasses.jar"; private static final String STANDARD_JAR_EMPTY = "jar/standard/emptyStandardJar.jar"; @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Test public void testDetermineJarType_springBoot() throws IOException, URISyntaxException { ...
@@ -18,30 +18,260 @@ import static com.google.common.truth.Truth.assertThat; +import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath; +import com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer; +import com.google.cloud.tools.jib.api.buildplan.FileEntry; import com.google.cloud.tools.jib.cli.jar.J...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.286
nitpick
64
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Implement explode mode for regular jar. BEFORE CODE: "jar/standard/standardJarWithOnlyClasses.jar"; private static final String STANDARD_JAR_EMPTY = "jar/standard/em...
super nit: I think this comment is obvious enough to be removed.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* <li>{@code STANDARD} a regular jar. * <li>{@code SPRING_BOOT} a spring boot fat jar. * </ul> */ public enum JarType { STANDARD, SPRING_BOOT; } /** * Determines whether the jar is a spring boot or regular jar. * * @param jarPath path to the jar. * @return the jar type. * @...
```suggestion * Explodes jar and create three layers for classes, resources and dependencies on container. ``` and we don't put a period for `@param`, `@return` and such, but honestly, I didn't care.
* <li>{@code STANDARD} a regular jar. * <li>{@code SPRING_BOOT} a spring boot fat jar. * </ul> */ public enum JarType { STANDARD, SPRING_BOOT; } /** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the jar * @return the jar type * @t...
@@ -49,4 +65,86 @@ public static JarType determineJarType(Path jarPath) throws IOException { } return JarType.STANDARD; } + + /** + * Explode jar and create three layers for classes, resources and dependencies on container.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.786
suggestion
205
51
51
false
Implement explode mode for regular jar.
2,813
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Implement explode mode for regular jar. BEFORE CODE: * <li>{@code STANDARD} a regular jar. * <li>{@code SPRING_BOOT} a spring boot fat jar. * </ul> */ public e...
```suggestion * Explodes jar and create three layers for classes, resources and dependencies on container. ``` and we don't put a period for `@param`, `@return` and such, but honestly, I didn't care.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
throws InvalidImageReferenceException { String imageSpec = buildOptions.getTargetImage(); if (imageSpec.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) { // TODO: allow setting docker env and docker executable (along with path/env) return Containerizer.to( DockerDaemonImage.named(imageSpec.r...
It's not possible to have both `--username` and `--to-username` given, right? Is it worth checking that here? ``` Preconditions.checkArgument(!(buildOptions.getUsernamePassword().isPresent() && buildOptinos.getToUsernamePassword.isPresent())); ```
private static Containerizer create(JibCli buildOptions, ConsoleLogger logger) throws InvalidImageReferenceException, FileNotFoundException { String imageSpec = buildOptions.getTargetImage(); if (imageSpec.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) { // TODO: allow setting docker env and docker exec...
@@ -0,0 +1,147 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java
26
Java
0.857
suggestion
250
51
51
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java PR Title: Build Command for building from cli BEFORE CODE: throws InvalidImageReferenceException { String imageSpec = buildOptions.getTargetImage(); if (imageSpec.startsW...
It's not possible to have both `--username` and `--to-username` given, right? Is it worth checking that here? ``` Preconditions.checkArgument(!(buildOptions.getUsernamePassword().isPresent() && buildOptinos.getToUsernamePassword.isPresent())); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
TarImage.at(Paths.get(imageSpec.replaceFirst(TAR_IMAGE_PREFIX, ""))) .named(buildOptions.getName())); } ImageReference imageReference = ImageReference.parse(imageSpec.replaceFirst(REGISTRY_IMAGE_PREFIX, "")); RegistryImage registryImage = RegistryImage.named(imageReference); ...
I think this needs a little more work for Windows (as in `DefaultCredentialRetrievers.asList()`). Add a TODO?
if (imageSpec.startsWith(TAR_IMAGE_PREFIX)) { return Containerizer.to( TarImage.at(Paths.get(imageSpec.replaceFirst(TAR_IMAGE_PREFIX, ""))) .named(buildOptions.getName())); } ImageReference imageReference = ImageReference.parse(imageSpec.replaceFirst(REGISTRY_IMAGE_PREF...
@@ -0,0 +1,147 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java
26
Java
0.5
security
109
51
51
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java PR Title: Build Command for building from cli BEFORE CODE: TarImage.at(Paths.get(imageSpec.replaceFirst(TAR_IMAGE_PREFIX, ""))) .named(buildOptions.getName()));...
I think this needs a little more work for Windows (as in `DefaultCredentialRetrievers.asList()`). Add a TODO?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
CredentialRetrieverFactory.forImage( imageReference, logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage())), buildOptions); return Containerizer.to(registryImage); } static void applyCredentialConfig( RegistryImage registryImage, CredentialRetrieverFactory factory...
We haven't finalized if we'll have a default build output directory somewhere, but we if do, it may make sense to put the application cache into it. But I feel a bit weird for a CLI tool like this to create some output directory.
DefaultCredentialRetrievers defaultCredentialRetrievers = DefaultCredentialRetrievers.init( CredentialRetrieverFactory.forImage( imageReference, logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage()))); Credentials.getToCredentialRetrievers(buildOp...
@@ -0,0 +1,147 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java
26
Java
0.429
performance
229
51
48
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java PR Title: Build Command for building from cli BEFORE CODE: CredentialRetrieverFactory.forImage( imageReference, logEvent -> logger.log(logEvent.getLevel(), logEvent...
We haven't finalized if we'll have a default build output directory somewhere, but we if do, it may make sense to put the application cache into it. But I feel a bit weird for a CLI tool like this to create some output directory.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
new JibCli(), "--target=ignored.io/igored/ignored", "--credential-helper", credHelperFile.toAbsolutePath().toString()); Containerizers.applyCredentialConfig( mockRegistryImage, mockCredentialRetrieverFactory, buildOptions); // verify we adde...
```suggestion // verify we added our intended credential retriever ```
/* * Copyright 2020 Google LLC. * * 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...
@@ -0,0 +1,275 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/ContainerizersTest.java
26
Java
0.571
security
78
51
150
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/ContainerizersTest.java PR Title: Build Command for building from cli BEFORE CODE: new JibCli(), "--target=ignored.io/igored/ignored", "--credential-helper", ...
```suggestion // verify we added our intended credential retriever ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ArgumentCaptor.forClass(CredentialRetriever.class); verify(mockRegistryImage, times(4)).addCredentialRetriever(captor.capture()); List<CredentialRetriever> configuredRetrievers = captor.getAllValues(); assertThat(configuredRetrievers).hasSize(4); // remove all auto added credentials ...
```suggestion // verify we added our intended credential retriever ```
/* * Copyright 2020 Google LLC. * * 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...
@@ -0,0 +1,275 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/ContainerizersTest.java
26
Java
0.571
security
78
43
150
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/cli2/ContainerizersTest.java PR Title: Build Command for building from cli BEFORE CODE: ArgumentCaptor.forClass(CredentialRetriever.class); verify(mockRegistryImage, times(4)).addCredentialRetr...
```suggestion // verify we added our intended credential retriever ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage()))); Credentials.getToCredentialRetrievers(buildOptions, defaultCredentialRetrievers) .forEach(registryImage::addCredentialRetriever); return Containerizer.to(registryImage); } static void applyConfiguration(Containeri...
Nit: for consistency, we can use `.forEach(containerizer::withAdditionalTag)`?
logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage()))); Credentials.getToCredentialRetrievers(buildOptions, defaultCredentialRetrievers) .forEach(registryImage::addCredentialRetriever); return Containerizer.to(registryImage); } private static void applyConfiguration(Co...
@@ -0,0 +1,130 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java
26
Java
0.429
question
78
46
44
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java PR Title: Build Command for building from cli BEFORE CODE: logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage()))); Credentials.getToCredentialRetrieve...
Nit: for consistency, we can use `.forEach(containerizer::withAdditionalTag)`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** Helper class for creating Containerizers from JibCli specifications. */ public class Containerizers { /** * Create a Containerizer from a jibcli command line specification. * * @param buildOptions JibCli options * @return a populated Containerizer * @throws InvalidImageReferenceException if the i...
Can all there methods `private`?
/** Helper class for creating Containerizers from JibCli specifications. */ public class Containerizers { /** * Create a Containerizer from a jibcli command line specification. * * @param buildOptions JibCli options * @return a populated Containerizer * @throws InvalidImageReferenceException if the i...
@@ -0,0 +1,130 @@ +/* + * Copyright 2020 Google LLC. + * + * 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...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java
26
Java
0.214
question
32
51
51
false
Build Command for building from cli
2,818
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Containerizers.java PR Title: Build Command for building from cli BEFORE CODE: /** Helper class for creating Containerizers from JibCli specifications. */ public class Containerizers { /** * Create...
Can all there methods `private`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.common.io.Resources; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Instant; import java.util.Map; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Bef...
```suggestion @Rule public final MockitoRule rule = MockitoJUnit.rule(); @Mock private ConsoleLogger consoleLogger; @Mock private JibCli jibCli; ```
import com.google.common.io.Resources; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Instant; import java.util.Map; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Bef...
@@ -38,13 +40,27 @@ import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; import org.junit.Assert; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.Mockito...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/buildfile/BuildFilesTest.java
26
Java
0.714
suggestion
160
51
51
false
Add credentials for `from` image in BuildFile
2,840
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/buildfile/BuildFilesTest.java PR Title: Add credentials for `from` image in BuildFile BEFORE CODE: import com.google.common.io.Resources; import java.io.IOException; import java.net.URISyntaxException; import ...
```suggestion @Rule public final MockitoRule rule = MockitoJUnit.rule(); @Mock private ConsoleLogger consoleLogger; @Mock private JibCli jibCli; ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
String baseImageReference = from.getImage(); if (baseImageReference.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) { return Jib.from( DockerDaemonImage.named(baseImageReference.replaceFirst(DOCKER_DAEMON_IMAGE_PREFIX, ""))); } if (baseImageReference.startsWith(TAR_IMAGE_PREFIX)) { return ...
Is it required for platform spec to be fully specified?
if (baseImageReference.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) { return Jib.from( DockerDaemonImage.named(baseImageReference.replaceFirst(DOCKER_DAEMON_IMAGE_PREFIX, ""))); } if (baseImageReference.startsWith(TAR_IMAGE_PREFIX)) { return Jib.from( TarImage.at(Paths.get(baseIma...
@@ -98,4 +103,42 @@ public static JibContainerBuilder toJibContainerBuilder( } return containerBuilder; } + + @VisibleForTesting + // TODO: add testing, need to do via intergration tests as there's no good way to extract out that + // the base image was populated as the user intended currently. + sta...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.214
question
55
33
32
false
Add credentials for `from` image in BuildFile
2,840
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add credentials for `from` image in BuildFile BEFORE CODE: String baseImageReference = from.getImage(); if (baseImageReference.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)...
Is it required for platform spec to be fully specified?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.apache.commons.text.StringSubstitutor; import org.apache.commons.text.io.StringSubstitutorReader; /** Class to convert BuildFiles to build container representations. */ public class BuildFiles { /** Read a build file from disk and apply templating parameters. */ private static BuildFileSpec toBuildFile...
maybe we can add a small `e.g ` at the end to make this more clear?
import org.apache.commons.text.StringSubstitutor; import org.apache.commons.text.io.StringSubstitutorReader; /** Class to convert BuildFiles to build container representations. */ public class BuildFiles { /** Read a build file from disk and apply templating parameters. */ private static BuildFileSpec toBuildFile...
@@ -53,33 +69,22 @@ private static BuildFileSpec toBuildFileSpec( * * @param projectRoot the root context directory of this build * @param buildFilePath a file containing the build definition - * @param templateParameters a map of templating variables to apply on the file before parsing + * @param build...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.357
question
68
51
51
false
Add credentials for `from` image in BuildFile
2,840
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add credentials for `from` image in BuildFile BEFORE CODE: import org.apache.commons.text.StringSubstitutor; import org.apache.commons.text.io.StringSubstitutorReader; /** ...
maybe we can add a small `e.g ` at the end to make this more clear?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return Jib.from( DockerDaemonImage.named(baseImageReference.replaceFirst(DOCKER_DAEMON_IMAGE_PREFIX, ""))); } if (baseImageReference.startsWith(TAR_IMAGE_PREFIX)) { return Jib.from( TarImage.at(Paths.get(baseImageReference.replaceFirst(TAR_IMAGE_PREFIX, "")))); } ImageRef...
The iteration order is actually important. Internally we used `LinkedHashSet` everywhere to preserve the order while conveniently removing duplicates (also signifying that duplicates can't exist). However, I see that it can easily make the Jib API user to mess up with the order. Maybe accepting a `Set` wasn't a good id...
DockerDaemonImage.named(baseImageReference.replaceFirst(DOCKER_DAEMON_IMAGE_PREFIX, ""))); } if (baseImageReference.startsWith(TAR_IMAGE_PREFIX)) { return Jib.from( TarImage.at(Paths.get(baseImageReference.replaceFirst(TAR_IMAGE_PREFIX, "")))); } ImageReference imageReference =...
@@ -98,4 +103,42 @@ public static JibContainerBuilder toJibContainerBuilder( } return containerBuilder; } + + @VisibleForTesting + // TODO: add testing, need to do via intergration tests as there's no good way to extract out that + // the base image was populated as the user intended currently. + sta...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.643
refactor
409
31
30
false
Add credentials for `from` image in BuildFile
2,840
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add credentials for `from` image in BuildFile BEFORE CODE: return Jib.from( DockerDaemonImage.named(baseImageReference.replaceFirst(DOCKER_DAEMON_IMAGE_PREFI...
The iteration order is actually important. Internally we used `LinkedHashSet` everywhere to preserve the order while conveniently removing duplicates (also signifying that duplicates can't exist). However, I see that it can easily make the Jib API user to mess up with the order. Maybe accepting a `Set` wasn't a good id...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
JibContainerBuilder containerBuilder = buildFile.getFrom().isPresent() ? createJibContainerBuilder(buildFile.getFrom().get(), buildOptions, logger) : Jib.fromScratch(); buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime); buildFile.getFormat().ifPresent(...
I think this can be private without @VisibleForTesting?
JibContainerBuilder containerBuilder = buildFile.getFrom().isPresent() ? createJibContainerBuilder(buildFile.getFrom().get(), cliOptions, logger) : Jib.fromScratch(); buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime); buildFile.getFormat().ifPresent(co...
@@ -98,4 +103,42 @@ public static JibContainerBuilder toJibContainerBuilder( } return containerBuilder; } + + @VisibleForTesting + // TODO: add testing, need to do via intergration tests as there's no good way to extract out that + // the base image was populated as the user intended currently. + sta...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.214
question
55
51
51
false
Add credentials for `from` image in BuildFile
2,840
GoogleContainerTools/jib
11,032
Java
chanseokoh
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add credentials for `from` image in BuildFile BEFORE CODE: JibContainerBuilder containerBuilder = buildFile.getFrom().isPresent() ? createJibContaine...
I think this can be private without @VisibleForTesting?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
JibContainerBuilder containerBuilder = buildFile.getFrom().isPresent() ? createJibContainerBuilder(buildFile.getFrom().get(), buildOptions, logger) : Jib.fromScratch(); buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime); buildFile.getFormat().ifPresent...
sorry, does this PR need to submitted before we start writing the integration tests?
JibContainerBuilder containerBuilder = buildFile.getFrom().isPresent() ? createJibContainerBuilder(buildFile.getFrom().get(), cliOptions, logger) : Jib.fromScratch(); buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime); buildFile.getFormat().ifPresent(c...
@@ -98,4 +103,42 @@ public static JibContainerBuilder toJibContainerBuilder( } return containerBuilder; } + + @VisibleForTesting + // TODO: add testing, need to do via intergration tests as there's no good way to extract out that + // the base image was populated as the user intended currently.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java
26
Java
0.214
question
85
51
51
false
Add credentials for `from` image in BuildFile
2,840
GoogleContainerTools/jib
11,032
Java
mpeddada1
loosebazooka
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java PR Title: Add credentials for `from` image in BuildFile BEFORE CODE: JibContainerBuilder containerBuilder = buildFile.getFrom().isPresent() ? createJibContain...
sorry, does this PR need to submitted before we start writing the integration tests?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @return list of {@link FileEntriesLayer} * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist */ public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath) throws IOException { Path localExploded...
I think it's okay to embed the predicate. And I think the name 'isSnapshot' is fine in this local scope. ```suggestion .filter(isSnapshot.negate()) ```
* @return list of {@link FileEntriesLayer} * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist */ public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath) throws IOException { Path localExploded...
@@ -82,27 +82,48 @@ public static JarType determineJarType(Path jarPath) throws IOException { ZipUtil.unzip(jarPath, localExplodedJarRoot); List<FileEntriesLayer> layers = new ArrayList<>(); - // Get dependencies from Class-Path in the jar's manifest and add a layer with these - // dependencies as ent...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.714
suggestion
168
51
51
false
Add snapshot dependencies layer in explode mode for standard jar.
2,858
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Add snapshot dependencies layer in explode mode for standard jar. BEFORE CODE: * @return list of {@link FileEntriesLayer} * @throws IOException if I/O error occurs when o...
I think it's okay to embed the predicate. And I think the name 'isSnapshot' is fine in this local scope. ```suggestion .filter(isSnapshot.negate()) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip // adding a dependencies layer. String classPath = null; try (JarFile jarFile = new JarFile(jarPath.toFile())) { classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH); ...
For consistency, let's use the name as defined by `JavaContainerBuilder.LayerType`. ```suggestion FileEntriesLayer.builder().setName("dependencies"); ```
// and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip // adding a dependencies layer. String classPath = null; try (JarFile jarFile = new JarFile(jarPath.toFile())) { classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH); ...
@@ -82,27 +82,48 @@ public static JarType determineJarType(Path jarPath) throws IOException { ZipUtil.unzip(jarPath, localExplodedJarRoot); List<FileEntriesLayer> layers = new ArrayList<>(); - // Get dependencies from Class-Path in the jar's manifest and add a layer with these - // dependencies as ent...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.929
suggestion
168
51
51
false
Add snapshot dependencies layer in explode mode for standard jar.
2,858
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Add snapshot dependencies layer in explode mode for standard jar. BEFORE CODE: // and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip ...
For consistency, let's use the name as defined by `JavaContainerBuilder.LayerType`. ```suggestion FileEntriesLayer.builder().setName("dependencies"); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Predicate<String> isNotSnapshotDependency = isSnapshotDependency.negate(); List<String> allDependencies = Splitter.onPattern("\\s+").splitToList(classPath.trim()); List<Path> nonSnapshotDependencies = allDependencies .stream() .filter(isNotSnapshotDependency) ...
Likewise, ```suggestion FileEntriesLayer.builder().setName("snapshot dependencies"); ```
List<String> allDependencies = Splitter.onPattern("\\s+").splitToList(classPath.trim()); List<Path> nonSnapshotDependencies = allDependencies .stream() .filter(isSnapshot.negate()) .map(Paths::get) .collect(Collectors.toList()); List<Pa...
@@ -82,27 +82,48 @@ public static JarType determineJarType(Path jarPath) throws IOException { ZipUtil.unzip(jarPath, localExplodedJarRoot); List<FileEntriesLayer> layers = new ArrayList<>(); - // Get dependencies from Class-Path in the jar's manifest and add a layer with these - // dependencies as ent...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.714
suggestion
103
51
51
false
Add snapshot dependencies layer in explode mode for standard jar.
2,858
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Add snapshot dependencies layer in explode mode for standard jar. BEFORE CODE: Predicate<String> isNotSnapshotDependency = isSnapshotDependency.negate(); List<Strin...
Likewise, ```suggestion FileEntriesLayer.builder().setName("snapshot dependencies"); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class"); Predicate<Path> isResourceFile = isClassFile.negate(); // Determine class and resource files in the directory containing jar contents and create // FileEntriesLayer for each type of layer (classes or resources), whi...
I remember this used to be caught by the formatter. Maybe not anymore. ```suggestion * Computes the entrypoint for a standard jar in exploded mode. ```
// Determine class and resource files in the directory containing jar contents and create // FileEntriesLayer for each type of layer (classes or resources), while maintaining the // file's original project structure. Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class");...
@@ -145,6 +149,42 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Compute the entrypoint for a standard jar in exploded mode.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.786
suggestion
159
51
51
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class"); Predicate<Pa...
I remember this used to be caught by the formatter. Maybe not anymore. ```suggestion * Computes the entrypoint for a standard jar in exploded mode. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.containsExactly( AbsoluteUnixPath.get("/app/explodedJar/META-INF"), AbsoluteUnixPath.get("/app/explodedJar/META-INF/MANIFEST.MF")); // Validate classes layer. // TODO: Validate order of file paths once // https://github.com/GoogleContainerTools/jib/issues/2821 is fixed. ...
Just so you know, if you don't need a nested directory or multiple directories, you can use the root: `temporaryFolder.getRoot().toPath()`.
.containsExactly( AbsoluteUnixPath.get("/app/explodedJar/META-INF"), AbsoluteUnixPath.get("/app/explodedJar/META-INF/MANIFEST.MF")); // Validate classes layer. // TODO: Validate order of file paths once // https://github.com/GoogleContainerTools/jib/issues/2821 is fixed. ...
@@ -281,4 +282,46 @@ public void testExplodeMode_standard_withoutClassPathInManifest_containsOnlyClas AbsoluteUnixPath.get("/app/explodedJar/class1.class"), AbsoluteUnixPath.get("/app/explodedJar/class2.class")); } + + @Test + public void testExplodeMode_standard_computeEntrypoint_allLaye...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java
26
Java
0.571
suggestion
139
51
51
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarProcessorTest.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: .containsExactly( AbsoluteUnixPath.get("/app/explodedJar/META-INF"), Abs...
Just so you know, if you don't need a nested directory or multiple directories, you can use the root: `temporaryFolder.getRoot().toPath()`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
isClassFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( RESOURCES, localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar")));...
Using `_` is only accepted in test method names. `computeEntrypointForExplodedStandard()`? And I don't know who will require this method, but you should always double-checking if a method may have a narrower access scope. (Just don't habitually make everything `public` until necessary.)
APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( RESOURCES, localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resource...
@@ -145,6 +149,42 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Compute the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param layer...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.643
suggestion
290
51
51
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: isClassFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); FileEntries...
Using `_` is only accepted in test method names. `computeEntrypointForExplodedStandard()`? And I don't know who will require this method, but you should always double-checking if a method may have a narrower access scope. (Just don't habitually make everything `public` until necessary.)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( RESOURCES, localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /**...
I admit we don't have a good established policy around throwing, handling, and reporting exceptions and errors. We have not done well so far. But at least the situation for Jib CLI is not so grim, as it is not a library but a CLI. So I think throwing a runtime exception to crash for this type of errors is more or less ...
addDirectoryContentsToLayer( RESOURCES, localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /** * Computes the entrypoint for a st...
@@ -145,6 +149,42 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Compute the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param layer...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.714
bug
484
51
51
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( RESOURCES, ...
I admit we don't have a good established policy around throwing, handling, and reporting exceptions and errors. We have not done well so far. But at least the situation for Jib CLI is not so grim, as it is not a library but a CLI. So I think throwing a runtime exception to crash for this type of errors is more or less ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return layers; } /** * Compute the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @param tempDirPath path to temporary jib local directory * @param layers list of {@link FileEntriesLayer} * @return list of {@link String} representing entrypoint * @thr...
The CLI will crash with this message. And providing a clear message implying an actionable fix increases the chance of the user understanding and fixing the issue on their own, resulting in less frustrated getting-started experience (which is important to increase the chance of adoption). It also reduces our workload b...
} /** * Computes the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypointForExplodedStand...
@@ -145,6 +149,42 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Compute the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param layer...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
1
bug
591
51
43
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: return layers; } /** * Compute the entrypoint for a standard jar in exploded mode. * * @pa...
The CLI will crash with this message. And providing a clear message implying an actionable fix increases the chance of the user understanding and fixing the issue on their own, resulting in less frustrated getting-started experience (which is important to increase the chance of adoption). It also reduces our workload b...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* * @param jarPath path to jar file * @param tempDirPath path to temporary jib local directory * @param layers list of {@link FileEntriesLayer} * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * ...
At least this should be ```suggestion classpath.add(APP_ROOT + "/dependencies/*"); ``` Just so you know, there's an issue with the order of loading jars (like #1871 for Jib build plugins), but I think there's nothing we can do about it for a standard jar.
* @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypointForExplodedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFil...
@@ -145,6 +149,42 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Compute the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param layer...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.857
suggestion
267
51
38
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: * * @param jarPath path to jar file * @param tempDirPath path to temporary jib local directory *...
At least this should be ```suggestion classpath.add(APP_ROOT + "/dependencies/*"); ``` Just so you know, there's an issue with the order of loading jars (like #1871 for Jib build plugins), but I think there's nothing we can do about it for a standard jar.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist * @throws IllegalArgumentException if main class is not found in the jar manifest */ public static ImmutableList<String> computeEntrypoint_explodedStandard( Path jarPath, Path t...
Considering the order of loading classes, `explodedJar` should come before `dependencies`. That said, how about going simple? It's okay to put a non-existing directory. I think the level of code reduction is worth. ```java String classpath = APP_ROOT + "/explodedJar:" + APP_ROOT + "/dependencies/*"; ```
throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an...
@@ -145,6 +149,42 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Compute the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param layer...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.857
suggestion
309
49
33
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * pr...
Considering the order of loading classes, `explodedJar` should come before `dependencies`. That said, how about going simple? It's okay to put a non-existing directory. I think the level of code reduction is worth. ```java String classpath = APP_ROOT + "/explodedJar:" + APP_ROOT + "/dependencies/*"; ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ public static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new J...
Perhaps this can be package-private? ```suggestion static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath) ``` And if this needs to be package-private only to be able to call from tests (i.e., it should have been `private` if not for the tests), add `@VisibleForTesting`.
/** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ public static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new J...
@@ -76,7 +81,7 @@ public static JarType determineJarType(Path jarPath) throws IOException { * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist */ - public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath)...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.857
suggestion
302
51
51
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: /** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the...
Perhaps this can be package-private? ```suggestion static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath) ``` And if this needs to be package-private only to be able to call from tests (i.e., it should have been `private` if not for the tests), add `@VisibleForTesting`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
layers.add(classesLayer); return layers; } /** * Computes the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @param tempDirPath path to temporary jib local directory * @param layers list of {@link FileEntriesLayer} * @return list of {@link String} re...
Sorry, I think this reads better: ```suggestion "`Main-Class:` attribute for an application main class not defined in the input Jar's manifest (`META-INF/MANIFEST.MF` in the Jar)."); ```
return layers; } /** * Computes the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypo...
@@ -145,6 +149,33 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Computes the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param laye...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.786
suggestion
199
51
44
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: layers.add(classesLayer); return layers; } /** * Computes the entrypoint for a standard jar ...
Sorry, I think this reads better: ```suggestion "`Main-Class:` attribute for an application main class not defined in the input Jar's manifest (`META-INF/MANIFEST.MF` in the Jar)."); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( RESOURCES, localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /**...
Oh, actually, I remember unzipping a jar somewhere else too. Are we unzipping it multiple times? We should unzip only once for efficiency.
addDirectoryContentsToLayer( RESOURCES, localExplodedJarRoot, isResourceFile, APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /** * Computes the entrypoint for a st...
@@ -145,6 +149,33 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Computes the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param laye...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.429
suggestion
138
51
51
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: FileEntriesLayer resourcesLayer = addDirectoryContentsToLayer( RESOURCES, ...
Oh, actually, I remember unzipping a jar somewhere else too. Are we unzipping it multiple times? We should unzip only once for efficiency.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /** * Computes the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @param tempDirPath path to temporary jib local...
Nit: I think this code block is super fast, so it's good to put everything in to the try-resource block. ```suggestion try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) ...
layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /** * Computes the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening t...
@@ -145,6 +149,33 @@ public static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Computes the entrypoint for a standard jar in exploded mode. + * + * @param jarPath path to jar file + * @param tempDirPath path to temporary jib local directory + * @param laye...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.929
suggestion
357
51
47
false
Compute entrypoint for a standard jar in exploded mode.
2,862
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Compute entrypoint for a standard jar in exploded mode. BEFORE CODE: APP_ROOT.resolve(RelativeUnixPath.get("explodedJar"))); layers.add(resourcesLayer); lay...
Nit: I think this code block is super fast, so it's good to put everything in to the try-resource block. ```suggestion try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ package com.google.cloud.tools.jib.global; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.Range; /** Names of system properties defined/used by Jib. */ public class JibSystemProperties { public static final String UPSTREAM_CLIENT...
I realize this is a draft, but I'm not super fond of this name. I sometimes think `preserveClasspathOrder` is a decent name, but i'm not sure.
*/ package com.google.cloud.tools.jib.global; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.Range; /** Names of system properties defined/used by Jib. */ public class JibSystemProperties { public static final String UPSTREAM_CLIENT...
@@ -32,10 +33,12 @@ public static final String SEND_CREDENTIALS_OVER_HTTP = "sendCredentialsOverHttp"; public static final String SERIALIZE = "jib.serialize"; - private static final String DISABLE_USER_AGENT = "_JIB_DISABLE_USER_AGENT"; - @VisibleForTesting public static final String SKIP_EXISTING_IMAGES = ...
jib-core/src/main/java/com/google/cloud/tools/jib/global/JibSystemProperties.java
26
Java
0.5
suggestion
142
51
51
false
Add option to expand wildcard in entrypoint runtime classpath
2,866
GoogleContainerTools/jib
11,032
Java
loosebazooka
chanseokoh
Review this pull request change. Language: Java File: jib-core/src/main/java/com/google/cloud/tools/jib/global/JibSystemProperties.java PR Title: Add option to expand wildcard in entrypoint runtime classpath BEFORE CODE: */ package com.google.cloud.tools.jib.global; import com.google.common.annotations.VisibleFo...
I realize this is a draft, but I'm not super fond of this name. I sometimes think `preserveClasspathOrder` is a decent name, but i'm not sure.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* </ul> */ public enum JarType { STANDARD, SPRING_BOOT; } /** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the jar * @return the jar type * @throws IOException if I/O error occurs when opening the file */ @VisibleForTesting static J...
Sorry, this was my fault but how about ```suggestion * Creates layers for dependencies, snapshot dependencies, resources and classes on container for a standard jar. ```
* Jar Type. * * <ul> * <li>{@code STANDARD} a regular jar. * <li>{@code SPRING_BOOT} a spring boot fat jar. * </ul> */ public enum JarType { STANDARD, SPRING_BOOT; } /** * Determines whether the jar is a spring boot or standard jar. * * @param jarPath path to the jar ...
@@ -68,16 +70,16 @@ public static JarType determineJarType(Path jarPath) throws IOException { } /** - * Explodes jar and create three layers for classes, resources and dependencies on container. + * Creates three layers for classes, resources, and dependencies on container for a standard jar.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java
26
Java
0.714
suggestion
176
51
51
false
Rename JarProcessor method and adjust method access
2,872
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java PR Title: Rename JarProcessor method and adjust method access BEFORE CODE: * </ul> */ public enum JarType { STANDARD, SPRING_BOOT; } /** * Determines whether the j...
Sorry, this was my fault but how about ```suggestion * Creates layers for dependencies, snapshot dependencies, resources and classes on container for a standard jar. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public class CliLogger { /** * Create a new logger for the cli. * * @param verbosity the configure verbosity * @param consoleOutput the configured consoleOutput format * @return a new ConsoleLogger instance */ public static ConsoleLogger newLogger(Verbosity verbosity, ConsoleOutput consoleOutput)...
Flipping `enableTwoCursorUpJump` doesn't effectively change output and is not required to fix the issue. However, since there's no need to employ the two-cursor-up-jump trick (was only necessary for Maven), I'm turning it off.
public class CliLogger { /** * Create a new logger for the CLI. * * @param verbosity the configure verbosity * @param consoleOutput the configured consoleOutput format * @return a new ConsoleLogger instance */ public static ConsoleLogger newLogger(Verbosity verbosity, ConsoleOutput consoleOutput)...
@@ -22,36 +22,54 @@ import com.google.common.annotations.VisibleForTesting; import java.io.PrintStream; -/** A simple cli logger that logs to the command line based on the configured log level. */ +/** A simple CLI logger that logs to the command line based on the configured log level. */ public class CliLogger { ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/logging/CliLogger.java
26
Java
0.643
suggestion
226
51
51
false
Fix broken Jib CLI logging
2,876
GoogleContainerTools/jib
11,032
Java
chanseokoh
chanseokoh
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/logging/CliLogger.java PR Title: Fix broken Jib CLI logging BEFORE CODE: public class CliLogger { /** * Create a new logger for the cli. * * @param verbosity the configure verbosity * @para...
Flipping `enableTwoCursorUpJump` doesn't effectively change output and is not required to fix the issue. However, since there's no need to employ the two-cursor-up-jump trick (was only necessary for Maven), I'm turning it off.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.Callable; import picocli.CommandLine; @CommandLine.Command( name = "build", showAtFileInUsageHelp = true, description = "Build a container") public clas...
Maybe we can make the error message a bit more specific - "The Build File YAML either does not exist or cannot be opened for reading" since `isReadable` checks for both.
import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.Callable; import picocli.CommandLine; @CommandLine.Command( name = "build", showAtFileInUsageHelp = true, description = "Build a container") public clas...
@@ -40,18 +43,29 @@ public Integer call() { try { ConsoleLogger logger = CliLogger.newLogger(globalOptions.getVerbosity(), globalOptions.getConsoleOutput()); + + Path buildFile = globalOptions.getBuildFile(); + if (!Files.isReadable(buildFile)) { + logger.log(Level.ERROR, "Cannot...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Build.java
26
Java
0.643
suggestion
169
51
51
false
Give better error message on Jib CLI
2,877
GoogleContainerTools/jib
11,032
Java
mpeddada1
chanseokoh
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Build.java PR Title: Give better error message on Jib CLI BEFORE CODE: import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import java.nio.file.Files; import java.nio.file.Path; import...
Maybe we can make the error message a bit more specific - "The Build File YAML either does not exist or cannot be opened for reading" since `isReadable` checks for both.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ package com.google.cloud.tools.jib.cli.cli2; import com.google.cloud.tools.jib.api.Containerizer; import com.google.cloud.tools.jib.api.JibContainerBuilder; import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud.tools.jib.cli.jar.JarFi...
I think we should accept this is an ordinary argument, not through an option, e.g., `jib ... jar my.jar`.
*/ package com.google.cloud.tools.jib.cli.cli2; import com.google.cloud.tools.jib.api.Containerizer; import com.google.cloud.tools.jib.api.JibContainerBuilder; import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud.tools.jib.cli.jar.JarFi...
@@ -0,0 +1,88 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.571
suggestion
105
51
51
false
Add jar cli sub-command to the jib cli
2,878
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Add jar cli sub-command to the jib cli BEFORE CODE: */ package com.google.cloud.tools.jib.cli.cli2; import com.google.cloud.tools.jib.api.Containerizer; import com.google.cloud.tools...
I think we should accept this is an ordinary argument, not through an option, e.g., `jib ... jar my.jar`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Path jarFile = getJarFile(); try { ConsoleLogger logger = CliLogger.newLogger(globalOptions.getVerbosity(), globalOptions.getConsoleOutput()); if (!Files.exists(jarFile)) { logger.log(LogEvent.Level.ERROR, "The file path provided does not exist: " + jarFile); return 1; ...
Should also print the exception type. Check `Build.java`. That said, can we explore a way to share code?
/* * Copyright 2020 Google LLC. * * 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...
@@ -0,0 +1,88 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.714
question
104
32
76
false
Add jar cli sub-command to the jib cli
2,878
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Add jar cli sub-command to the jib cli BEFORE CODE: Path jarFile = getJarFile(); try { ConsoleLogger logger = CliLogger.newLogger(globalOptions.getVerbosity(), g...
Should also print the exception type. Check `Build.java`. That said, can we explore a way to share code?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ public Path getJarFile() { return jarFile; } @Override public Integer call() { globalOptions.validate(); Path jarFile = getJarFile(); try { ConsoleLogger logger = CliLogger.newLogger(globalOptions.getVerbosity(), globalOptions.getConsoleOutput()); if (!Files.exists(j...
We need to sort out what we should provide for a temporary staging directory. We may eventually go for a dedicated build output directory, but for now, I think we can provide a system temp directory. Let's talk offline.
if (!Files.exists(jarFile)) { logger.log(LogEvent.Level.ERROR, "The file path provided does not exist: " + jarFile); return 1; } if (Files.isDirectory(jarFile)) { logger.log( LogEvent.Level.ERROR, "The file path provided is for a directory. Please provi...
@@ -0,0 +1,85 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.5
style
219
40
30
false
Add jar cli sub-command to the jib cli
2,878
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Add jar cli sub-command to the jib cli BEFORE CODE: */ public Path getJarFile() { return jarFile; } @Override public Integer call() { globalOptions.validate(); P...
We need to sort out what we should provide for a temporary staging directory. We may eventually go for a dedicated build output directory, but for now, I think we can provide a system temp directory. Let's talk offline.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud.tools.jib.cli.jar.JarFiles; import com.google.cloud.tools.jib.filesystem.TempDirectoryProvider; import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import java.nio.fi...
```suggestion try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ``` and remove the field and the `finally` block.
import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud.tools.jib.cli.jar.JarFiles; import com.google.cloud.tools.jib.filesystem.TempDirectoryProvider; import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import java.nio.fi...
@@ -40,22 +38,15 @@ @SuppressWarnings("NullAway.Init") // initialized by picocli private Path jarFile; - /** - * Returns a user configured Path to a jar file. - * - * @return a path to a jar file - */ - public Path getJarFile() { - return jarFile; - } + private final TempDirectoryProvider tempDir...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.786
suggestion
152
51
51
false
Add jar cli sub-command to the jib cli
2,878
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Add jar cli sub-command to the jib cli BEFORE CODE: import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud...
```suggestion try (TempDirectoryProvider tempDirectoryProvider = new TempDirectoryProvider()) { ``` and remove the field and the `finally` block.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import org.junit.After; import org.junit.Before; import org.junit.Test; import picocli.CommandLine; public class JarCommandTest { p...
This is a creative trick, but I feel it isn't really safe to replace stdout and stderr. For example, the unit framework depends on it, and I think we will not be able to see test failures. I have been thinking of two options for verifying command output: run as a separate process, or refactor the code. I didn't real...
import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import org.junit.Test; import picocli.CommandLine; public class JarCommandTest { @Test public void testErrorLogging_fileDoesNotExist() { ...
@@ -0,0 +1,94 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.5
bug
633
51
51
false
Add integration testing for jib cli jar command.
2,885
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration testing for jib cli jar command. BEFORE CODE: import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; impor...
This is a creative trick, but I feel it isn't really safe to replace stdout and stderr. For example, the unit framework depends on it, and I think we will not be able to see test failures. I have been thinking of two options for verifying command output: run as a separate process, or refactor the code. I didn't real...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@After public void tearDown() { System.setOut(originalOut); System.setErr(originalErr); } @Test public void testErrorLogging_fileDoesNotExist() { Integer actual = new CommandLine(new JibCli()) .execute("--target", "docker://jib-cli-image", "jar", "unknown.jar"); assertTh...
Let's just go for ```suggestion assertThat(exitCode).isEqualTo(1); ```
jibCli.setErr(new PrintWriter(stringWriter)); Path jarFile = Paths.get("/"); Integer exitCode = jibCli.execute("--target", "docker://jib-cli-image", "jar", jarFile.toString()); assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( "[ERROR] T...
@@ -0,0 +1,94 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.571
suggestion
77
45
27
false
Add integration testing for jib cli jar command.
2,885
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration testing for jib cli jar command. BEFORE CODE: @After public void tearDown() { System.setOut(originalOut); System.setErr(originalErr)...
Let's just go for ```suggestion assertThat(exitCode).isEqualTo(1); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.nio.file.Paths; import org.junit.Test; import picocli.CommandLine; public class JarCommandTest { @Test public void testErrorLogging_fileDoesNotExist() { CommandLine jibCli = new CommandLine(new JibCli()); StringWriter sw = new StringWriter(); jibCli.setErr(new PrintWriter(sw)); Intege...
I don't think we have "emptyDir" in our test runtime classpath. Maybe just `Paths.get("/")`?
import java.nio.file.Paths; import org.junit.Test; import picocli.CommandLine; public class JarCommandTest { @Test public void testErrorLogging_fileDoesNotExist() { CommandLine jibCli = new CommandLine(new JibCli()); StringWriter stringWriter = new StringWriter(); jibCli.setErr(new PrintWriter(stringW...
@@ -0,0 +1,76 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.357
question
92
50
50
false
Add integration testing for jib cli jar command.
2,885
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration testing for jib cli jar command. BEFORE CODE: import java.nio.file.Paths; import org.junit.Test; import picocli.CommandLine; public class JarCom...
I don't think we have "emptyDir" in our test runtime classpath. Maybe just `Paths.get("/")`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* 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 com.google.cloud.tools.jib.cli.cli2; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.tools.jib.Comma...
The Google style doesn't allow 'sw'. I think we can go for ```suggestion StringWriter stringWriter = new StringWriter(); ```
* 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 com.google.cloud.tools.jib.cli.cli2; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.tools.jib.Comma...
@@ -0,0 +1,76 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.714
suggestion
131
51
51
false
Add integration testing for jib cli jar command.
2,885
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Add integration testing for jib cli jar command. BEFORE CODE: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the spec...
The Google style doesn't allow 'sw'. I think we can go for ```suggestion StringWriter stringWriter = new StringWriter(); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.api.JibContainerBuilder; import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud.tools.jib.cli.jar.JarFiles; import com.google.cloud.tools.jib.filesystem.TempDirectoryProvider; import com.google.cloud.tools.j...
I don't think this needs to be a field. Just instantiate as a local variable in `call()`. I know you'll going to use it in a `finally` block, so you can create it before `try {`.
import com.google.cloud.tools.jib.api.JibContainerBuilder; import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools.jib.cli.cli2.logging.CliLogger; import com.google.cloud.tools.jib.cli.jar.JarFiles; import com.google.cloud.tools.jib.filesystem.TempDirectoryProvider; import com.google.cloud.tools.j...
@@ -41,13 +42,20 @@ @SuppressWarnings("NullAway.Init") // initialized by picocli private Path jarFile; + private final SingleThreadedExecutor executor = new SingleThreadedExecutor();
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.571
suggestion
178
51
51
false
Modify CliLogger to use PrintWriter
2,887
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Modify CliLogger to use PrintWriter BEFORE CODE: import com.google.cloud.tools.jib.api.JibContainerBuilder; import com.google.cloud.tools.jib.api.LogEvent; import com.google.cloud.tools...
I don't think this needs to be a field. Just instantiate as a local variable in `call()`. I know you'll going to use it in a `finally` block, so you can create it before `try {`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* 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....
Probably ```suggestion @CommandLine.Spec protected CommandSpec spec = CommandSpec.create(); ``` I guess it can't be `private`?
* 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....
@@ -23,13 +23,17 @@ import com.google.cloud.tools.jib.cli.jar.JarFiles; import com.google.cloud.tools.jib.filesystem.TempDirectoryProvider; import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; +import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.F...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.714
question
136
51
51
false
Modify CliLogger to use PrintWriter
2,887
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Modify CliLogger to use PrintWriter BEFORE CODE: * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BAS...
Probably ```suggestion @CommandLine.Spec protected CommandSpec spec = CommandSpec.create(); ``` I guess it can't be `private`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.util.concurrent.Callable; import picocli.CommandLine; import picocli.CommandLine.Model.CommandSpec; @CommandLine.Command(name = "jar", showAtFil...
I think this will be what the user will see on the command-line with the help usage. Should include what values are available. That said, take a look at the `--vebosity` and `--console` options. ```java @Option( names = "--verbosity", paramLabel = "<level>", defaultValue = "lifecycle", ...
import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.util.concurrent.Callable; import picocli.CommandLine; import picocli.Comm...
@@ -43,6 +44,14 @@ @SuppressWarnings("NullAway.Init") // initialized by picocli private Path jarFile; + @CommandLine.Option( + names = "--mode", + defaultValue = "exploded", + paramLabel = "<mode>", + description = "The processing mode")
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
1
suggestion
869
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.Files; import java.nio.file....
I think this will be what the user will see on the command-line with the help usage. Should include what values are available. That said, take a look at the `--vebosity` and `--console` options. ```java @Option( names = "--verbosity", paramLabel = "<level>", defaultValue = "lifecycle", ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
String classPath = null; // Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snapshot // and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip // adding the dependencies layers. try (JarFile jarFile = new JarFile(jarPath.toFile())...
I missed this. `jib jar` will fail if running from a different directory (e.g., `jib ... jar ../my.jar`). Perhaps the first argument to `addEntry` should be ~~`jarPath.resolve(path)`~~?
? APP_ROOT.resolve(path) : APP_ROOT.resolve("dependencies").resolve(path.getFileName()))); layers.add(nonSnapshotLayer.build()); } if (!snapshots.isEmpty()) { FileEntriesLayer.Builder snapshotLayer = FileEntriesLayer.b...
@@ -191,4 +208,47 @@ private static FileEntriesLayer addDirectoryContentsToLayer( }); return builder.build(); } + + private static List<FileEntriesLayer> getDependenciesLayers(Path jarPath) throws IOException { + List<FileEntriesLayer> layers = new ArrayList<>(); + String classPath = null; +...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.571
bug
185
42
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: String classPath = null; // Get dependencies from Class-Path in the jar's manifest and add a layer each for n...
I missed this. `jib jar` will fail if running from a different directory (e.g., `jib ... jar ../my.jar`). Perhaps the first argument to `addEntry` should be ~~`jarPath.resolve(path)`~~?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } } /** * Creates layers for depe...
In this case, I think it's fine to have ```suggestion List<FileEntriesLayer> layers = getDependenciesLayers(jarPath); ```
static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } } /** * Creates layers for dependencies, snapshot de...
@@ -86,47 +87,13 @@ static JarType determineJarType(Path jarPath) throws IOException { */ static List<FileEntriesLayer> createExplodedModeLayersForStandardJar( Path jarPath, Path tempDirPath) throws IOException { - Path localExplodedJarRoot = tempDirPath; - ZipUtil.unzip(jarPath, localExplodedJarRoo...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.714
suggestion
128
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: @VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = n...
In this case, I think it's fine to have ```suggestion List<FileEntriesLayer> layers = getDependenciesLayers(jarPath); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an application main class not defined in the input Jar's " + "manifest (`META-INF/MANIFEST.MF` in ...
Not that I care, but just FYI, this [doc](https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html) stylizes the archive as "JAR." It stands for "Java™ Archive (JAR)" files.
* @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypointForPackagedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String m...
@@ -173,6 +168,28 @@ static JarType determineJarType(Path jarPath) throws IOException { } } + /** + * Computes the entrypoint for a standard jar in packaged mode. + * + * @param jarPath path to jar file + * @return list of {@link String} representing entrypoint + * @throws IOException if I/O error ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.357
suggestion
188
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null)...
Not that I care, but just FYI, this [doc](https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html) stylizes the archive as "JAR." It stands for "Java™ Archive (JAR)" files.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /** * Creates layers for dependencies, snapshot dependencies and the jar itself on container for a * standard jar. * * @param jarPath path to jar file * @return list of {@link FileEntriesLayer} * @throws IOExcepti...
Oh, I remember we decided to do `java -jar`. In that case, we should retain the directory structure for the dependencies given in `Class-Path:` in `MANIFEST.MF`.
* standard jar. * * @param jarPath path to jar file * @return list of {@link FileEntriesLayer} * @throws IOException if I/O error occurs when opening the jar file */ static List<FileEntriesLayer> createLayersForPackagedStandard(Path jarPath) throws IOException { // Add dependencies layers. L...
@@ -151,6 +116,32 @@ static JarType determineJarType(Path jarPath) throws IOException { return layers; } + /** + * Creates layers for dependencies, snapshot dependencies and the jar itself on container for a + * standard jar. + * + * @param jarPath path to jar file + * @return list of {@link FileEn...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.571
suggestion
161
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: layers.add(resourcesLayer); layers.add(classesLayer); return layers; } /** * Creates layers for d...
Oh, I remember we decided to do `java -jar`. In that case, we should retain the directory structure for the dependencies given in `Class-Path:` in `MANIFEST.MF`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.util.concurrent.Callable; import picocli.CommandLine; import picocli.CommandLine.Model.CommandSpec; @CommandLine.Command(name = "jar", showAtFil...
Why not creating a dedicated type and have the descriptions like other options? ``` "set console output type, candidates: ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE}") ``` I think it will take care of validation for us too.
import com.google.cloud.tools.jib.plugins.common.logging.ConsoleLogger; import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.util.concurrent.Callable; import picocli.CommandLine; import picocli.Comm...
@@ -44,6 +44,14 @@ @SuppressWarnings("NullAway.Init") // initialized by picocli private Path jarFile; + @CommandLine.Option( + names = "--mode", + defaultValue = "exploded", + paramLabel = "<mode>", + description = "The jar processing mode, candidates: packaged, default: exploded")
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java
26
Java
0.929
question
235
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/Jar.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: import com.google.cloud.tools.jib.plugins.common.logging.SingleThreadedExecutor; import java.nio.file.Files; import java.nio.file....
Why not creating a dedicated type and have the descriptions like other options? ``` "set console output type, candidates: ${COMPLETION-CANDIDATES}, default: ${DEFAULT-VALUE}") ``` I think it will take care of validation for us too.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snapshot // and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip // adding the dependencies layers. try (JarFile jarFile = new JarFile(jarPath.toFile())) { classPath = jarFile...
I just tried my `C.jar` example, but it throws an NPE. In this case, `jarPath` is simply `C.jar` (not an absolute path) and `jarPath.getParent()` returns null. ``` ~/A$ jib --target=docker://foo --stacktrace jar C.jar java.lang.NullPointerException at com.google.cloud.tools.jib.cli.jar.JarModeProcessor.la...
nonSnapshotLayer, jarParent.resolve(path), mode.equals(ProcessingMode.packaged) ? APP_ROOT.resolve(path) : APP_ROOT.resolve("dependencies").resolve(path.getFileName()))); layers.add(nonSnapsho...
@@ -191,4 +204,50 @@ private static FileEntriesLayer addDirectoryContentsToLayer( }); return builder.build(); } + + private static List<FileEntriesLayer> getDependenciesLayers(Path jarPath) throws IOException { + List<FileEntriesLayer> layers = new ArrayList<>(); + String classPath = null; +...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.929
bug
678
44
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: // Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snapshot // and snapsh...
I just tried my `C.jar` example, but it throws an NPE. In this case, `jarPath` is simply `C.jar` (not an absolute path) and `jarPath.getParent()` returns null. ``` ~/A$ jib --target=docker://foo --stacktrace jar C.jar java.lang.NullPointerException at com.google.cloud.tools.jib.cli.jar.JarModeProcessor.la...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Path jarFile = Paths.get(Resources.getResource("jarTest/jarWithCp.jar").toURI()); Integer exitCode = new CommandLine(new JibCli()) .execute("--target", "docker://jib-cli-image", "jar", jarFile.toString()); String output = new Command("docker", "run", "--rm", "jib-cli-image").run(); ...
```suggestion public void testJar_unknownMode() throws URISyntaxException { ```
public void testJar_explodedMode_toDocker() throws IOException, InterruptedException, URISyntaxException { Path jarPath = Paths.get(Resources.getResource("jarTest/jarWithCp.jar").toURI()); Integer exitCode = new CommandLine(new JibCli()) .execute("--target", "docker://exploded-jar", ...
@@ -57,20 +57,52 @@ public void testErrorLogging_directoryGiven() throws URISyntaxException { assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( - "[ERROR] The file path provided is for a directory. Please provide a path to a jar file: " + "[ERROR...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.714
suggestion
83
42
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: Path jarFile = Paths.get(Resources.getResource("jarTest/jarWithCp.jar").toURI()); Integer exitCode ...
```suggestion public void testJar_unknownMode() throws URISyntaxException { ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertThat(exitCode).isEqualTo(0); assertThat(output).isEqualTo("HelloWorld"); } @Test public void testJar_packagedMode_toDocker() throws IOException, InterruptedException, URISyntaxException { Path jarFile = Paths.get(Resources.getResource("jarTest/jarWithCp.jar").toURI()); Integer exitCo...
Perhaps we don't even need to pass a jar file?
.execute("--target", "docker://exploded-jar", "jar", jarPath.toString()); String output = new Command("docker", "run", "--rm", "exploded-jar").run(); try (JarFile jarFile = new JarFile(jarPath.toFile())) { String classPath = jarFile.getManifest().getMainAttributes().getValue(Attribut...
@@ -57,20 +57,52 @@ public void testErrorLogging_directoryGiven() throws URISyntaxException { assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( - "[ERROR] The file path provided is for a directory. Please provide a path to a jar file: " + "[ERROR...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.071
question
46
37
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: assertThat(exitCode).isEqualTo(0); assertThat(output).isEqualTo("HelloWorld"); } @Test publ...
Perhaps we don't even need to pass a jar file?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2020 Google LLC. * * 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...
Let's have exploded (default mode) come first.
/* * Copyright 2020 Google LLC. * * 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...
@@ -0,0 +1,22 @@ +/* + * Copyright 2020 Google LLC. + * + * 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 ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/ProcessingMode.java
20
Java
0.071
suggestion
46
23
23
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/ProcessingMode.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: /* * Copyright 2020 Google LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * us...
Let's have exploded (default mode) come first.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public class JarFiles { /** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param jarPath path to the jar file * @param tempDirPath path to a temporary directory which will be used store the exploded jar's * contents * @param mode mode for processing jar * @return...
Maybe we can be consistent with the names. Given that the class name is already `JarModeProcessor`, ```suggestion layers = JarModeProcessor.createLayersForPackagedStandard(jarPath); entrypoint = JarModeProcessor.computeEntrypointForPackagedStandard(jarPath); ``` And unfortunately, renaming a method m...
public class JarFiles { /** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param jarPath path to the jar file * @param tempDirPath path to a temporary directory which will be used store the exploded jar's * contents * @param mode mode for processing jar * @return...
@@ -33,20 +33,28 @@ * @param jarPath path to the jar file * @param tempDirPath path to a temporary directory which will be used store the exploded jar's * contents + * @param mode mode for processing jar * @return JibContainerBuilder * @throws IOException if I/O error occurs when opening the j...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java
26
Java
0.786
suggestion
351
35
35
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarFiles.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: public class JarFiles { /** * Generates a {@link JibContainerBuilder} from contents of a jar file. * * @param jarP...
Maybe we can be consistent with the names. Given that the class name is already `JarModeProcessor`, ```suggestion layers = JarModeProcessor.createLayersForPackagedStandard(jarPath); entrypoint = JarModeProcessor.computeEntrypointForPackagedStandard(jarPath); ``` And unfortunately, renaming a method m...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
FileEntriesLayer.Builder builder = FileEntriesLayer.builder().setName(layerName); new DirectoryWalker(sourceRoot) .filterRoot() .filter(path -> Files.isDirectory(path) || pathFilter.test(path)) .walk( path -> { AbsoluteUnixPath pathOnContainer = ...
Now that we have refactored out this logic to this method, short-circuiting is possible, and I think it helps readability. And now I think it should be fine to expand the `try` block until the end. For example, ```suggestion try (JarFile jarFile = new JarFile(jarPath.toFile())) { String classPath = jarFi...
List<Path> nonSnapshots = allDependencies .stream() .filter(isSnapshot.negate()) .map(Paths::get) .collect(Collectors.toList()); List<Path> snapshots = allDependencies .stream() .filte...
@@ -191,4 +202,49 @@ private static FileEntriesLayer addDirectoryContentsToLayer( }); return builder.build(); } + + private static List<FileEntriesLayer> getDependenciesLayers( + Path jarPath, AbsoluteUnixPath pathOnContainer) throws IOException { + List<FileEntriesLayer> layers = new Arra...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
1
refactor
553
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: FileEntriesLayer.Builder builder = FileEntriesLayer.builder().setName(layerName); new DirectoryWalker(sourceRo...
Now that we have refactored out this logic to this method, short-circuiting is possible, and I think it helps readability. And now I think it should be fine to expand the `try` block until the end. For example, ```suggestion try (JarFile jarFile = new JarFile(jarPath.toFile())) { String classPath = jarFi...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private static List<FileEntriesLayer> getDependenciesLayers( Path jarPath, AbsoluteUnixPath pathOnContainer) throws IOException { List<FileEntriesLayer> layers = new ArrayList<>(); String classPath = null; // Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snaps...
super nit: I think in this local scope, it's fine to name it `nonSnapshotLayer`. I think it'll help reduce cognitive load when reading the code block.
if (!nonSnapshots.isEmpty()) { FileEntriesLayer.Builder nonSnapshotLayer = FileEntriesLayer.builder().setName(DEPENDENCIES); nonSnapshots.forEach( path -> addDependency( nonSnapshotLayer, jarParent.reso...
@@ -191,4 +202,49 @@ private static FileEntriesLayer addDirectoryContentsToLayer( }); return builder.build(); } + + private static List<FileEntriesLayer> getDependenciesLayers( + Path jarPath, AbsoluteUnixPath pathOnContainer) throws IOException { + List<FileEntriesLayer> layers = new Arra...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.5
nitpick
150
47
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: private static List<FileEntriesLayer> getDependenciesLayers( Path jarPath, AbsoluteUnixPath pathOnContainer) ...
super nit: I think in this local scope, it's fine to name it `nonSnapshotLayer`. I think it'll help reduce cognitive load when reading the code block.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
() -> JarModeProcessor.computeEntrypointForExplodedStandard(standardJar)); assertThat(ex) .hasMessageThat() .isEqualTo( "`Main-Class:` attribute for an application main class not defined in the input JAR's manifest (`META-INF/MANIFEST.MF` in the JAR)."); } @Test publi...
`jarLayer().getEntries().get(0).getExtractionPath()`? And before this, also assert that the size of `jarLayer().getEntries()` is 1.
public void testCreateLayersForPackagedStandard_emptyJar() throws IOException, URISyntaxException { Path standardJar = Paths.get(Resources.getResource(STANDARD_JAR_EMPTY).toURI()); List<FileEntriesLayer> layers = JarModeProcessor.createLayersForPackagedStandard(standardJar); assertThat(layers.size(...
@@ -326,6 +326,125 @@ public void testExplodedMode_standard_computeEntrypoint_noMainClass() throws URI assertThat(ex) .hasMessageThat() .isEqualTo( - "`Main-Class:` attribute for an application main class not defined in the input Jar's manifest (`META-INF/MANIFEST.MF` in the Jar)."); +...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java
26
Java
0.571
refactor
134
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: () -> JarModeProcessor.computeEntrypointForExplodedStandard(standardJar)); assertThat(ex) ...
`jarLayer().getEntries().get(0).getExtractionPath()`? And before this, also assert that the size of `jarLayer().getEntries()` is 1.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
FileEntriesLayer jarLayer = layers.get(0); assertThat(jarLayer.getName()).isEqualTo("jar"); assertThat( jarLayer .getEntries() .stream() .map(FileEntry::getExtractionPath) .collect(Collectors.toList()) .get(0)) ...
ditto But this test is identical to the one above. May be remove this test?
Path standardJar = Paths.get(Resources.getResource(STANDARD_JAR_WITH_CLASS_PATH_MANIFEST).toURI()); List<FileEntriesLayer> layers = JarModeProcessor.createLayersForPackagedStandard(standardJar); assertThat(layers.size()).isEqualTo(3); FileEntriesLayer nonSnapshotLayer = layers.get(0); File...
@@ -326,6 +326,125 @@ public void testExplodedMode_standard_computeEntrypoint_noMainClass() throws URI assertThat(ex) .hasMessageThat() .isEqualTo( - "`Main-Class:` attribute for an application main class not defined in the input Jar's manifest (`META-INF/MANIFEST.MF` in the Jar)."); +...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java
26
Java
0.286
refactor
78
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessorTest.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: FileEntriesLayer jarLayer = layers.get(0); assertThat(jarLayer.getName()).isEqualTo("jar"); assertThat...
ditto But this test is identical to the one above. May be remove this test?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ @VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } } /** * Creates layers fo...
```suggestion getDependenciesLayers(jarPath, APP_ROOT.resolve("dependencies")); ```
@VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } return JarType.STANDARD; } } /** * Creates layers for depe...
@@ -86,47 +87,12 @@ static JarType determineJarType(Path jarPath) throws IOException { */ static List<FileEntriesLayer> createExplodedModeLayersForStandardJar( Path jarPath, Path tempDirPath) throws IOException { + // Add dependencies layers. + List<FileEntriesLayer> layers = + getDependencie...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.571
suggestion
93
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: */ @VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFi...
```suggestion getDependenciesLayers(jarPath, APP_ROOT.resolve("dependencies")); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return ImmutableList.of("java", "-cp", classpath, mainClass); } } /** * Computes the entrypoint for a standard jar in packaged mode. * * @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar f...
I'm not a big fan of using a map for the purpose of returning more than one value. How about creating a private inner class? For this purpose, I think we don't even need getters and setters. ```java private static class LocalDependencies { private final List<Path> snapshots; private final List<Path> nonSnapsh...
} return layers; } } } private static void addDependency( FileEntriesLayer.Builder layerbuilder, Path fullDepPath, AbsoluteUnixPath pathOnContainer) { if (!Files.exists(fullDepPath)) { throw new IllegalArgumentException( String.format( "Dependency r...
@@ -163,14 +223,51 @@ static JarType determineJarType(Path jarPath) throws IOException { jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( - "`Main-Class:` attribute for an application main c...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.857
refactor
721
51
37
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: return ImmutableList.of("java", "-cp", classpath, mainClass); } } /** * Computes the entrypoint for ...
I'm not a big fan of using a map for the purpose of returning more than one value. How about creating a private inner class? For this purpose, I think we don't even need getters and setters. ```java private static class LocalDependencies { private final List<Path> snapshots; private final List<Path> nonSnapsh...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} @Test public void testToJibContainerBuilder_packagedStandard_basicInfo() throws IOException, URISyntaxException, InvalidImageReferenceException { Path standardJar = Paths.get(Resources.getResource(SIMPLE_STANDARD_JAR).toURI()); Path destDir = temporaryFolder.getRoot().toPath(); JibContainerBu...
Assert that `buildPlan.getLayers()` is of size 2 before this.
.getEntries()); } @Test public void testToJibContainerBuilder_packagedStandard_basicInfo() throws IOException, URISyntaxException, InvalidImageReferenceException { Path standardJar = Paths.get(Resources.getResource(SIMPLE_STANDARD_JAR).toURI()); Path destDir = temporaryFolder.getRoo...
@@ -106,4 +107,41 @@ public void testToJibContainerBuilder_basicInfo() .build() .getEntries()); } + + @Test + public void testToJibContainerBuilder_packagedStandard_basicInfo() + throws IOException, URISyntaxException, InvalidImageReferenceException { + Path standardJar = ...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java
26
Java
0.357
suggestion
61
40
42
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: } @Test public void testToJibContainerBuilder_packagedStandard_basicInfo() throws IOException, URISyntaxExcep...
Assert that `buildPlan.getLayers()` is of size 2 before this.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @throws IOException if I/O error occurs when opening the file */ @VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } ...
We have the enum class defined in this Java package (`c.g.c.t.jib.cli.jar.ProcessingMode`). Why not use it?
* @throws IOException if I/O error occurs when opening the file */ @VisibleForTesting static JarType determineJarType(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { if (jarFile.getEntry("BOOT-INF") != null) { return JarType.SPRING_BOOT; } ...
@@ -83,58 +84,16 @@ static JarType determineJarType(Path jarPath) throws IOException { * @throws IOException if I/O error occurs when opening the jar file or if temporary directory * provided doesn't exist */ - static List<FileEntriesLayer> createExplodedModeLayersForStandardJar( - Path jarPath, P...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.571
question
107
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: * @throws IOException if I/O error occurs when opening the file */ @VisibleForTesting static JarType determi...
We have the enum class defined in this Java package (`c.g.c.t.jib.cli.jar.ProcessingMode`). Why not use it?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ static ImmutableList<String> computeEntrypointForPackagedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) {...
I think short-circuiting will help readability. ```java if (classPath == null) { // should flip the comparison return new ArrayList<>(); } List<FileEntriesLayer> layers = new ArrayList<>(); ```
*/ static ImmutableList<String> computeEntrypointForPackagedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) {...
@@ -163,14 +145,92 @@ static JarType determineJarType(Path jarPath) throws IOException { jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( - "`Main-Class:` attribute for an application main c...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
1
suggestion
226
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: */ static ImmutableList<String> computeEntrypointForPackagedStandard(Path jarPath) throws IOException { ...
I think short-circuiting will help readability. ```java if (classPath == null) { // should flip the comparison return new ArrayList<>(); } List<FileEntriesLayer> layers = new ArrayList<>(); ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an application main class not defined in the input JAR's " + "manifest (`...
nit: let's just call these `nonShapshots`.
String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an application main class not defined in the input JAR's " + "manifest (`...
@@ -163,14 +145,92 @@ static JarType determineJarType(Path jarPath) throws IOException { jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( - "`Main-Class:` attribute for an application main c...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.214
nitpick
42
51
51
false
Implement packaged mode for standard jar.
2,888
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Implement packaged mode for standard jar. BEFORE CODE: String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); ...
nit: let's just call these `nonShapshots`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} @Test public void testErrorLogging_directoryGiven() throws URISyntaxException { CommandLine jibCli = new CommandLine(new JibCli()); StringWriter stringWriter = new StringWriter(); jibCli.setErr(new PrintWriter(stringWriter)); Path jarFile = Paths.get("/"); Integer exitCode = jibCli...
It's okay to put everything into the `try` block, especially in tests.
@Test public void testErrorLogging_directoryGiven() throws URISyntaxException { CommandLine jibCli = new CommandLine(new JibCli()); StringWriter stringWriter = new StringWriter(); jibCli.setErr(new PrintWriter(stringWriter)); Path jarFile = Paths.get("/"); Integer exitCode = jibCli.exec...
@@ -64,11 +68,20 @@ public void testErrorLogging_directoryGiven() throws URISyntaxException { @Test public void testJar_toDocker() throws IOException, InterruptedException, URISyntaxException { - Path jarFile = Paths.get(Resources.getResource("simpleJar.jar").toURI()); + Path jarPath = Paths.get(Resources...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.357
suggestion
70
42
51
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: } @Test public void test...
It's okay to put everything into the `try` block, especially in tests.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Integer exitCode = jibCli.execute("--target", "docker://jib-cli-image", "jar", jarFile.toString()); assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( "[ERROR] The file path provided is for a directory. Please provide a path to a jar file: " ...
No need for splitting. I think it can be `assertThat(classPath).isEqualTo("dependency1.jar;directory/dependency2.jar")`, even without checking not null. And just double-check that the main in `simplJar` does use classes in both `dependency1.jar` and `dependency2.jar`.
assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( "[ERROR] The file path provided is for a directory. Please provide a path to a jar file: " + jarFile.toString() + "\n"); } @Test public void testJar_toDocker() throws IO...
@@ -64,11 +68,20 @@ public void testErrorLogging_directoryGiven() throws URISyntaxException { @Test public void testJar_toDocker() throws IOException, InterruptedException, URISyntaxException { - Path jarFile = Paths.get(Resources.getResource("simpleJar.jar").toURI()); + Path jarPath = Paths.get(Resources...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.786
suggestion
272
33
45
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: Integer exitCode = ...
No need for splitting. I think it can be `assertThat(classPath).isEqualTo("dependency1.jar;directory/dependency2.jar")`, even without checking not null. And just double-check that the main in `simplJar` does use classes in both `dependency1.jar` and `dependency2.jar`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@Test public void testToJibContainerBuilder_basicInfo() throws IOException, URISyntaxException, InvalidImageReferenceException { Path standardJar = Paths.get(Resources.getResource(SIMPLE_STANDARD_JAR).toURI()); Path destDir = temporaryFolder.getRoot().toPath(); JibContainerBuilder containerBuilder...
```suggestion standardJar.getParent().resolve("dependency1"), ```
@Test public void testToJibContainerBuilder_basicInfo() throws IOException, URISyntaxException, InvalidImageReferenceException { Path standardJar = Paths.get(Resources.getResource(SIMPLE_STANDARD_JAR).toURI()); Path destDir = temporaryFolder.getRoot().toPath(); JibContainerBuilder containerBuilder...
@@ -67,7 +67,8 @@ public void testToJibContainerBuilder_basicInfo() .isEqualTo( FileEntriesLayer.builder() .addEntry( - Paths.get("dependency1"), AbsoluteUnixPath.get("/app/dependencies/dependency1")) + standardJar.getParent().resolve(Paths.ge...
jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java
26
Java
0.571
suggestion
87
51
51
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/jar/JarFilesTest.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: @Test public void testToJibContainerBuilde...
```suggestion standardJar.getParent().resolve("dependency1"), ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
.map(Paths::get) .collect(Collectors.toList()); List<Path> snapshotDependencies = allDependencies.stream().filter(isSnapshot).map(Paths::get).collect(Collectors.toList()); Path jarParent = jarPath.getParent() == null ? Paths.get("") : jarPath.getParent(); if (!non...
```suggestion .resolve("dependencies") ``` and the one above tool.
.collect(Collectors.toList()); List<Path> snapshotDependencies = allDependencies.stream().filter(isSnapshot).map(Paths::get).collect(Collectors.toList()); Path jarParent = jarPath.getParent() == null ? Paths.get("") : jarPath.getParent(); if (!nonSnapshotDependencies.isEmpty())...
@@ -123,7 +127,10 @@ static JarType determineJarType(Path jarPath) throws IOException { snapshotDependencies.forEach( path -> snapshotDependenciesLayerBuilder.addEntry( - path, APP_ROOT.resolve(RelativeUnixPath.get("dependencies")).resolve(path))); + ...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.571
suggestion
93
51
51
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: .map(Paths::get) ...
```suggestion .resolve("dependencies") ``` and the one above tool.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snapshot // and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip // adding the dependencies layers. String classPath = null; try (JarFile jarFile = new JarFile(jarPath.toFile()))...
I just realized one thing we are missing. Remember [this output](https://github.com/GoogleContainerTools/jib/pull/2888#discussion_r520255662)? A lot of people will try Jib CLI on a standard JAR without having dependency JARs at all or in right relative locations, and they will just see `java.nio.file.NoSuchFileExceptio...
// and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip // adding the dependencies layers. String classPath = null; try (JarFile jarFile = new JarFile(jarPath.toFile())) { classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH);...
@@ -108,13 +108,17 @@ static JarType determineJarType(Path jarPath) throws IOException { .collect(Collectors.toList()); List<Path> snapshotDependencies = allDependencies.stream().filter(isSnapshot).map(Paths::get).collect(Collectors.toList()); + Path jarParent = jarPath.getParent()...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.786
bug
722
51
51
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: // Get dependencies from Class-Path in...
I just realized one thing we are missing. Remember [this output](https://github.com/GoogleContainerTools/jib/pull/2888#discussion_r520255662)? A lot of people will try Jib CLI on a standard JAR without having dependency JARs at all or in right relative locations, and they will just see `java.nio.file.NoSuchFileExceptio...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
jibCli.setErr(new PrintWriter(stringWriter)); Path jarFile = Paths.get("/"); Integer exitCode = jibCli.execute("--target", "docker://jib-cli-image", "jar", jarFile.toString()); assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( "[ERROR] T...
Q: why contains? Are there other dependencies?
jibCli.setErr(new PrintWriter(stringWriter)); Path jarFile = Paths.get("/"); Integer exitCode = jibCli.execute("--target", "docker://jib-cli-image", "jar", jarFile.toString()); assertThat(exitCode).isEqualTo(1); assertThat(stringWriter.toString()) .isEqualTo( "[ERROR] T...
@@ -64,13 +66,36 @@ public void testErrorLogging_directoryGiven() throws URISyntaxException { @Test public void testJar_toDocker() throws IOException, InterruptedException, URISyntaxException { - Path jarFile = Paths.get(Resources.getResource("simpleJar.jar").toURI()); + Path jarPath = Paths.get(Resources...
jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java
26
Java
0.071
question
46
50
50
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/cli2/JarCommandTest.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: jibCli.setErr(new PrintWrit...
Q: why contains? Are there other dependencies?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypointForExplodedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFil...
`if (!Files.exist(jarParent.resolve(depPath)))`
*/ static ImmutableList<String> computeEntrypointForExplodedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) {...
@@ -173,6 +174,21 @@ static JarType determineJarType(Path jarPath) throws IOException { } } + private static void addDependency( + FileEntriesLayer.Builder layerbuilder, + Path depPath, + Path jarParent, + AbsoluteUnixPath pathOnContainer) { + File depFile = new File(jarParent.resolve(...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.214
suggestion
47
51
47
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: * @param jarPath path to jar file * ...
`if (!Files.exist(jarParent.resolve(depPath)))`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* Computes the entrypoint for a standard jar in exploded mode. * * @param jarPath path to jar file * @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypointForExplodedStandard(Path ja...
Maybe pass in `pathOnContainer` is because it's computable here with `APP_ROOT.resolve("dependencies").resolve(depPath.getFileName())`?
* @return list of {@link String} representing entrypoint * @throws IOException if I/O error occurs when opening the jar file */ static ImmutableList<String> computeEntrypointForExplodedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String m...
@@ -173,6 +174,21 @@ static JarType determineJarType(Path jarPath) throws IOException { } } + private static void addDependency( + FileEntriesLayer.Builder layerbuilder, + Path depPath, + Path jarParent, + AbsoluteUnixPath pathOnContainer) {
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.571
question
135
51
49
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: * Computes the entrypoint for a standar...
Maybe pass in `pathOnContainer` is because it's computable here with `APP_ROOT.resolve("dependencies").resolve(depPath.getFileName())`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
static ImmutableList<String> computeEntrypointForExplodedStandard(Path jarPath) throws IOException { try (JarFile jarFile = new JarFile(jarPath.toFile())) { String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { ...
I think this will cause confusion when a dependency is nested. It reads like such a dependency should be in the same parent directory. How about something like "Dependency required by the JAR (as specified in 'Class-Path:' in the JAR manifest) doesn't exist: <full path of jarParent.resolve(depPath)>" ? And then w...
String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); if (mainClass == null) { throw new IllegalArgumentException( "`Main-Class:` attribute for an application main class not defined in the input Jar's " + "manifest (`...
@@ -173,6 +174,21 @@ static JarType determineJarType(Path jarPath) throws IOException { } } + private static void addDependency( + FileEntriesLayer.Builder layerbuilder, + Path depPath, + Path jarParent, + AbsoluteUnixPath pathOnContainer) { + File depFile = new File(jarParent.resolve(...
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java
26
Java
0.643
question
422
50
43
false
Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container.
2,893
GoogleContainerTools/jib
11,032
Java
chanseokoh
mpeddada1
Review this pull request change. Language: Java File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarModeProcessor.java PR Title: Modify standard jar exploded mode to not maintain original directory structure when adding dependencies to container. BEFORE CODE: static ImmutableList<String> computeEntr...
I think this will cause confusion when a dependency is nested. It reads like such a dependency should be in the same parent directory. How about something like "Dependency required by the JAR (as specified in 'Class-Path:' in the JAR manifest) doesn't exist: <full path of jarParent.resolve(depPath)>" ? And then w...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.