Skip to content

Commit

Permalink
Merge branch 'master' of github.com:GoogleContainerTools/jib into fix…
Browse files Browse the repository at this point in the history
…-jetty12
  • Loading branch information
mpeddada1 committed Mar 22, 2024
2 parents 1d473f4 + 1488874 commit d195041
Show file tree
Hide file tree
Showing 43 changed files with 257 additions and 77 deletions.
4 changes: 4 additions & 0 deletions .allstar/binary_artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore reason: jars are used for testing purposes only
ignorePaths:
- jib-gradle-plugin/src/integration-test/resources/gradle/projects/default-target/libs/dependency-1.0.0.jar
- jib-gradle-plugin/src/integration-test/resources/gradle/projects/simple/libs/dependency-1.0.0.jar
8 changes: 7 additions & 1 deletion .github/ISSUE_TEMPLATE/issue_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ assignees: ''
---

<!--
Before filing an issue, please reproduce with the latest version of Jib.
Please follow the guidelines below before opening an issue:
1. Ensure the issue was not already reported.
2. Open a new issue if you are unable to find an existing issue addressing your problem. Make sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
3. Discuss the priority and potential solutions with the maintainers in the issue. The maintainers would review the issue and add a label "Accepting Contributions" once the issue is ready for accepting contributions.
4. Open a PR only if the issue is labeled with "Accepting Contributions", ensure the PR description clearly describes the problem and solution. Note that an open PR without an issues labeled with "Accepting Contributions" will not be accepted.
Please reproduce with the latest version of Jib.
If you are encountering errors pulling or pushing to remote registries,
please check our Frequently Asked Questions before filing an issue:
Expand Down
14 changes: 6 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
Thank you for your interest in contributing! For general guidelines, please refer to
the [contributing guide](https://github.com/GoogleContainerTools/jib/blob/master/CONTRIBUTING.md).

Before filing a pull request, make sure to do the following:

- [ ] Create a new issue at https://github.com/GoogleContainerTools/jib/issues/new/choose.
- [ ] Ensure that your implementation plan is approved by the team.
Please follow the guidelines below before opening an issue or a PR:
- [ ] Ensure the issue was not already reported.
- [ ] Create a new issue at https://github.com/GoogleContainerTools/jib/issues/new/choose if you are unable to find an existing issue addressing your problem. Make sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
- [ ] Discuss the priority and potential solutions with the maintainers in the issue. The maintainers would review the issue and add a label "Accepting Contributions" once the issue is ready for accepting contributions.
- [ ] Open a PR only if the issue is labeled with "Accepting Contributions", ensure the PR description clearly describes the problem and solution. Note that an open PR without an issues labeled with "Accepting Contributions" will not be accepted.
- [ ] Verify that integration tests and unit tests are passing after the change.
- [ ] Address all checkstyle issues. Refer to
the [style guide](https://github.com/GoogleContainerTools/jib/blob/master/STYLE_GUIDE.md).

This helps to reduce the chance of having a pull request rejected.
- [ ] Address all checkstyle issues. Refer to the [style guide](https://github.com/GoogleContainerTools/jib/blob/master/STYLE_GUIDE.md).

Fixes #<issue_number_goes_here> 🛠️
10 changes: 8 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

This project is currently stable, and we are primarily focused on critical bug fixes and platform evolution to ensure it continues to work for its supported use cases.

# Contributing to Jib

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.
Please follow the guidelines below before opening an issue or a PR:
1. Ensure the issue was not already reported.
2. Open a new issue if you are unable to find an existing issue addressing your problem. Make sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
3. Discuss the priority and potential solutions with the maintainers in the issue. The maintainers would review the issue and add a label "Accepting Contributions" once the issue is ready for accepting contributions.
4. Open a PR only if the issue is labeled with "Accepting Contributions", ensure the PR description clearly describes the problem and solution. Note that an open PR without an issues labeled with "Accepting Contributions" will not be accepted.

## Contributor License Agreement

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ project.ext.dependencyStrings = [
GRADLE_EXTENSION: 'com.google.cloud.tools:jib-gradle-plugin-extension-api:0.4.0',
MAVEN_EXTENSION: 'com.google.cloud.tools:jib-maven-plugin-extension-api:0.4.0',

COMMONS_COMPRESS: 'org.apache.commons:commons-compress:1.21',
COMMONS_COMPRESS: 'org.apache.commons:commons-compress:1.26.0',
ZSTD_JNI: 'com.github.luben:zstd-jni:1.5.5-5',
COMMONS_TEXT: 'org.apache.commons:commons-text:1.10.0',
JACKSON_BOM: 'com.fasterxml.jackson:jackson-bom:2.15.2',
Expand Down Expand Up @@ -371,7 +371,7 @@ subprojects {
// sourceProject(Project) accepts a project and adds it as a dependency in a special manner:
// 1. force evaluation of the project first
// 2. add the project classes as "compileOnly" and make it available to tests in "testImplementation"
// 3. add the project's depedencies as "implementation"
// 3. add the project's dependencies as "implementation"
// 4. remove any transitive reference of any sourceProject depenency that may have appeared
// 5. add the project's classes to the final jar
// Other nice effects (vs shadowJar)
Expand Down
2 changes: 1 addition & 1 deletion docs/google-cloud-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Any Java container can be used for building, not only the `gcr.io/cloud-builders

```yaml
steps:
- name: 'docker.io/library/eclipse-temurin:17'
- name: 'docker.io/library/eclipse-temurin:21'
entrypoint: './gradlew'
args: ['--console=plain', '--no-daemon', ':server:jib', '-Djib.to.image=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']
```
Expand Down
2 changes: 1 addition & 1 deletion docs/privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and version.
### How to disable update checks

1. set the `jib.disableUpdateChecks` system property to `true`
2. set `disableUpdateChecks` to `true` in Jib's global config. The global config is in the following locations by default:
2. set `disableUpdateCheck` to `true` in Jib's global config. The global config is in the following locations by default:
* Linux: `$XDG_CONFIG_HOME/google-cloud-tools-java/jib/config.json` (if `$XDG_CONFIG_HOME` is defined), else `$HOME/.config/google-cloud-tools-java/jib/config.json`
* Mac: `$XDG_CONFIG_HOME/Google/Jib/config.json` (if `$XDG_CONFIG_HOME` is defined), else `$HOME/Library/Preferences/Google/Jib/config.json`
* Windows: `$XDG_CONFIG_HOME\Google\Jib\Config\config.json` (if `$XDG_CONFIG_HOME` is defined), else `%LOCALAPPDATA%\Google\Jib\Config\config.json`
2 changes: 1 addition & 1 deletion examples/dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dropwizard-template-config.version>1.5.0</dropwizard-template-config.version>

<jib.container.appRoot>/app</jib.container.appRoot>
<jib-maven-plugin.version>3.4.0</jib-maven-plugin.version>
<jib-maven-plugin.version>3.4.1</jib-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'com.google.cloud.tools.jib' version '3.4.0'
id 'com.google.cloud.tools.jib' version '3.4.1'
}

sourceCompatibility = 1.8
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>3.4.0</jib-maven-plugin.version>
<jib-maven-plugin.version>3.4.1</jib-maven-plugin.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion examples/java-agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'com.google.cloud.tools.jib' version '3.4.0'
id 'com.google.cloud.tools.jib' version '3.4.1'
id 'de.undercouch.download' version '4.0.0'
id 'com.gorylenko.gradle-git-properties' version '2.2.0'
}
Expand Down
2 changes: 1 addition & 1 deletion examples/java-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>3.4.0</jib-maven-plugin.version>
<jib-maven-plugin.version>3.4.1</jib-maven-plugin.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<download-maven-plugin.version>1.4.2</download-maven-plugin.version>
<git-commit-id-plugin.version>3.0.1</git-commit-id-plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion examples/ktor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
application
kotlin("jvm") version "1.3.10"
id("com.google.cloud.tools.jib") version "3.4.0"
id("com.google.cloud.tools.jib") version "3.4.1"
}

group = "example"
Expand Down
2 changes: 1 addition & 1 deletion examples/micronaut/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id "groovy"
id "com.github.johnrengelman.shadow" version "5.2.0"
id "application"
id 'com.google.cloud.tools.jib' version '3.4.0'
id 'com.google.cloud.tools.jib' version '3.4.1'
}

version "0.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
plugins {
id 'org.springframework.boot' version '2.0.3.RELEASE' apply false
id 'io.spring.dependency-management' version '1.0.6.RELEASE' apply false
id 'com.google.cloud.tools.jib' version '3.4.0' apply false
id 'com.google.cloud.tools.jib' version '3.4.1' apply false
}
2 changes: 1 addition & 1 deletion examples/multi-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-boot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'idea'
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
id 'com.google.cloud.tools.jib' version '3.4.0'
id 'com.google.cloud.tools.jib' version '3.4.1'
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion examples/vertx/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'io.vertx.vertx-plugin' version '0.1.0'
id 'com.google.cloud.tools.jib' version '3.4.0'
id 'com.google.cloud.tools.jib' version '3.4.1'
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,32 @@

import com.google.cloud.tools.jib.Command;
import com.google.cloud.tools.jib.api.HttpRequestTester;
import com.google.common.base.Preconditions;
import com.google.common.io.Resources;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import javax.annotation.Nullable;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import picocli.CommandLine;
Expand All @@ -43,6 +57,15 @@ public class JarCommandTest {

@Nullable private String containerName;

@BeforeClass
public static void createJars() throws IOException, URISyntaxException {
createJarFile(
"jarWithCp.jar", "HelloWorld", "dependency1.jar directory/dependency2.jar", "HelloWorld");
createJarFile("noDependencyJar.jar", "HelloWorld", null, "HelloWorld");
createJarFile("dependency1.jar", "dep/A", null, null);
createJarFile("directory/dependency2.jar", "dep2/B", null, null);
}

@After
public void tearDown() throws IOException, InterruptedException {
if (containerName != null) {
Expand Down Expand Up @@ -315,4 +338,47 @@ public void testJar_baseImageSpecified()
String output = new Command("docker", "run", "--rm", "cli-gcr-base").run();
assertThat(output).isEqualTo("Hello World");
}

public static void createJarFile(
String name, String className, String classPath, String mainClass)
throws IOException, URISyntaxException {
Path javaFilePath =
Paths.get(Resources.getResource("jarTest/standard/" + className + ".java").toURI());
Path workingDir = Paths.get(Resources.getResource("jarTest/standard/").toURI());

// compile the java file
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
Preconditions.checkNotNull(compiler);
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> compilationUnits =
fileManager.getJavaFileObjectsFromFiles(Collections.singletonList(javaFilePath.toFile()));
Iterable<String> options = Arrays.asList("-source", "1.8", "-target", "1.8");
JavaCompiler.CompilationTask task =
compiler.getTask(null, fileManager, null, options, null, compilationUnits);
boolean success = task.call();
assertThat(success).isTrue();

// Create a manifest file
Manifest manifest = new Manifest();
Attributes attributes = new Attributes();
attributes.putValue("Manifest-Version", "1.0");
if (classPath != null) {
attributes.putValue("Class-Path", classPath);
}
if (mainClass != null) {
attributes.putValue("Main-Class", mainClass);
}
manifest.getMainAttributes().putAll(attributes);

// Create JAR
File jarFile = workingDir.resolve(name).toFile();
jarFile.getParentFile().mkdirs();
try (FileOutputStream fileOutputStream = new FileOutputStream(jarFile);
JarOutputStream jarOutputStream = new JarOutputStream(fileOutputStream, manifest)) {
ZipEntry zipEntry = new ZipEntry(className + ".class");
jarOutputStream.putNextEntry(zipEntry);
jarOutputStream.write(Files.readAllBytes(workingDir.resolve(className + ".class")));
jarOutputStream.closeEntry();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class HelloWorld {
public static void main(String[] args) {
System.out.print("Hello World");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dep;

public class A {
public static void getResult() {
System.out.print("Hello ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dep2;

public class B {
public static void getResult() {
System.out.print("World");
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ private static String getDefaultBaseImage(ArtifactProcessor processor) {
if (processor.getJavaVersion() <= 11) {
return "eclipse-temurin:11-jre";
}
return "eclipse-temurin:17-jre";
if (processor.getJavaVersion() <= 17) {
return "eclipse-temurin:17-jre";
}
return "eclipse-temurin:21-jre";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class JarFilesTest {
"11, eclipse-temurin:11-jre",
"13, eclipse-temurin:17-jre",
"17, eclipse-temurin:17-jre",
"21, eclipse-temurin:21-jre",
})
public void testToJibContainer_defaultBaseImage(int javaVersion, String expectedBaseImage)
throws IOException, InvalidImageReferenceException {
Expand Down
7 changes: 6 additions & 1 deletion jib-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ All notable changes to this project will be documented in this file.
-

### Changed
-
- deps: bump org.apache.commons:commons-compress from 1.21 to 1.26.0 ([#4204](https://github.com/GoogleContainerTools/jib/pull/4204))

### Fixed
- fix: image builds should become reproducible once again ([#4204](https://github.com/GoogleContainerTools/jib/pull/4204))

## 0.26.0

### Fixed
- fix: support parsing manifest JSON containing `LayerSources:` from latest Docker. ([#4171](https://github.com/GoogleContainerTools/jib/pull/4171))
Expand Down
2 changes: 1 addition & 1 deletion jib-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Add Jib Core as a dependency using Maven:
<dependency>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-core</artifactId>
<version>0.25.0</version>
<version>0.26.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion jib-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = 0.25.1-SNAPSHOT
version = 0.26.1-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public void testTarballStructure() throws IOException {

assertThat(actual)
.containsExactly(
"c46572ef74f58d95e44dd36c1fbdfebd3752e8b56a794a13c11cfed35a1a6e1c.tar.gz",
"6d2763b0f3940d324ea6b55386429e5b173899608abf7d1bff62e25dd2e4dcea.tar.gz",
"530c1954a2b087d0b989895ea56435c9dc739a973f2d2b6cb9bb98e55bbea7ac.tar.gz",
"98682a867906d9d07cf3c51a4fb9e08e9d5baddd1ca5dc7834f58f434c9cb15c.tar.gz",
"527db49d4e0c4159346119b4971d59016bfedceed874abab2b510ce433f6b15c.tar.gz",
"16d03883198935b4119896dcea0ea14e1bf105b6ac0a35a88820d08bc0263306.tar.gz",
"config.json",
"manifest.json")
.inOrder();
Expand All @@ -114,7 +114,7 @@ public void testTarballStructure() throws IOException {
public void testManifest() throws IOException {
String expectedManifest =
"[{\"Config\":\"config.json\",\"RepoTags\":[\"jib-core/reproducible:latest\"],"
+ "\"Layers\":[\"c46572ef74f58d95e44dd36c1fbdfebd3752e8b56a794a13c11cfed35a1a6e1c.tar.gz\",\"6d2763b0f3940d324ea6b55386429e5b173899608abf7d1bff62e25dd2e4dcea.tar.gz\",\"530c1954a2b087d0b989895ea56435c9dc739a973f2d2b6cb9bb98e55bbea7ac.tar.gz\"]}]";
+ "\"Layers\":[\"98682a867906d9d07cf3c51a4fb9e08e9d5baddd1ca5dc7834f58f434c9cb15c.tar.gz\",\"527db49d4e0c4159346119b4971d59016bfedceed874abab2b510ce433f6b15c.tar.gz\",\"16d03883198935b4119896dcea0ea14e1bf105b6ac0a35a88820d08bc0263306.tar.gz\"]}]";
String generatedManifest = extractFromTarFileAsString(imageTar, "manifest.json");
assertThat(generatedManifest).isEqualTo(expectedManifest);
}
Expand All @@ -125,7 +125,7 @@ public void testConfiguration() throws IOException {
"{\"created\":\"1970-01-01T00:00:00Z\",\"architecture\":\"amd64\",\"os\":\"linux\","
+ "\"config\":{\"Env\":[],\"Entrypoint\":[\"echo\",\"Hello World\"],\"ExposedPorts\":{},\"Labels\":{},\"Volumes\":{}},"
+ "\"history\":[{\"created\":\"1970-01-01T00:00:00Z\",\"author\":\"Jib\",\"created_by\":\"jib-core:null\",\"comment\":\"\"},{\"created\":\"1970-01-01T00:00:00Z\",\"author\":\"Jib\",\"created_by\":\"jib-core:null\",\"comment\":\"\"},{\"created\":\"1970-01-01T00:00:00Z\",\"author\":\"Jib\",\"created_by\":\"jib-core:null\",\"comment\":\"\"}],"
+ "\"rootfs\":{\"type\":\"layers\",\"diff_ids\":[\"sha256:18e4f44e6d1835bd968339b166057bd17ab7d4cbb56dc7262a5cafea7cf8d405\",\"sha256:13369c34f073f2b9c1fa6431e23d925f1a8eac65b1726c8cc8fcc2596c69b414\",\"sha256:4f92c507112d7880ca0f504ef8272b7fdee107263270125036a260a741565923\"]}}";
+ "\"rootfs\":{\"type\":\"layers\",\"diff_ids\":[\"sha256:2fcc2157bf42c89195676ef6e973a96d7b018c9d30ba89db95e9e0722e1c8ef3\",\"sha256:21f521f3217067d277af37512a08c72281d90fdd02d7174db632c8c3a34403bd\",\"sha256:6beba018395265af5061864b7f4678e831eb2daebb1045487c641fc8b142e319\"]}}";
String generatedConfig = extractFromTarFileAsString(imageTar, "config.json");
assertThat(generatedConfig).isEqualTo(expectedConfig);
}
Expand Down
Loading

0 comments on commit d195041

Please sign in to comment.