Skip to content

Commit 2da0a92

Browse files
authored
Adds enableReproducibleBuilds parameter to jib-maven-plugin. (#111)
1 parent bedddb1 commit 2da0a92

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

examples/helloworld/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<version>1</version>
77

88
<properties>
9-
<jib-maven-plugin.version>0.1.0</jib-maven-plugin.version>
9+
<jib-maven-plugin.version>0.1.2</jib-maven-plugin.version>
1010
<mainClass>example.HelloWorld</mainClass>
1111
</properties>
1212

jib-core/src/main/java/com/google/cloud/tools/jib/image/LayerBuilder.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,11 @@ public UnwrittenLayer build() throws IOException {
9898
private void makeListReproducible(List<TarArchiveEntry> entries) {
9999
entries.sort(Comparator.comparing(TarArchiveEntry::getName));
100100
for (TarArchiveEntry entry : entries) {
101-
if (enableReproducibleBuilds) {
102-
entry.setModTime(0);
103-
entry.setGroupId(0);
104-
entry.setUserId(0);
105-
entry.setUserName("");
106-
entry.setGroupName("");
107-
}
101+
entry.setModTime(0);
102+
entry.setGroupId(0);
103+
entry.setUserId(0);
104+
entry.setUserName("");
105+
entry.setGroupName("");
108106
}
109107
}
110108

jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/BuildImageMojo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public class BuildImageMojo extends AbstractMojo {
8989

9090
@Parameter private String mainClass;
9191

92+
@Parameter(defaultValue = "true", required = true)
93+
private boolean enableReproducibleBuilds;
94+
9295
@Override
9396
public void execute() throws MojoExecutionException, MojoFailureException {
9497
validateParameters();
@@ -144,6 +147,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
144147
.setMainClass(mainClass)
145148
.setJvmFlags(jvmFlags)
146149
.setEnvironment(environment)
150+
.setEnableReproducibleBuilds(enableReproducibleBuilds)
147151
.build();
148152

149153
// Uses a directory in the Maven build cache as the Jib cache.

0 commit comments

Comments
 (0)