Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package org.apache.camel.dsl.jbang.core.commands;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;
import java.util.Properties;

import org.apache.camel.RuntimeCamelException;
Expand Down Expand Up @@ -232,4 +234,10 @@ int rankGroupId(MavenGav o1) {
};
}

protected String getBuildMavenProjectDate() {
// 2024-09-23T10:00:00Z
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
return sdf.format(new Date());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ private void createMavenPom(File settings, File profile, File pom, Set<String> d
} else {
context = context.replaceAll("\\{\\{ \\.MainClassname }}", mainClassname);
}
context = context.replaceFirst("\\{\\{ \\.ProjectBuildOutputTimestamp }}", this.getBuildMavenProjectDate());

Properties prop = new CamelCaseOrderedProperties();
RuntimeUtil.loadProperties(prop, settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ private void createMavenPom(File settings, File pom, Set<String> deps) throws Ex
context = context.replaceAll("\\{\\{ \\.QuarkusVersion }}", quarkusVersion);
context = context.replaceFirst("\\{\\{ \\.JavaVersion }}", javaVersion);
context = context.replaceFirst("\\{\\{ \\.CamelVersion }}", camelVersion);
context = context.replaceFirst("\\{\\{ \\.ProjectBuildOutputTimestamp }}", this.getBuildMavenProjectDate());

context = replaceBuildProperties(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ private void createMavenPom(File settings, File profile, File pom, Set<String> d
} else {
context = context.replaceAll("\\{\\{ \\.CamelSpringBootVersion }}", camelVersion);
}
context = context.replaceFirst("\\{\\{ \\.ProjectBuildOutputTimestamp }}", this.getBuildMavenProjectDate());

context = replaceBuildProperties(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<properties>
<java.version>{{ .JavaVersion }}</java.version>
<project.build.outputTimestamp>{{ .ProjectBuildOutputTimestamp }}</project.build.outputTimestamp>
{{ .BuildProperties }}
{{ .CamelKubernetesProperties }}
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<version>{{ .Version }}</version>

<properties>
<project.build.outputTimestamp>{{ .ProjectBuildOutputTimestamp }}</project.build.outputTimestamp>
<compiler-plugin.version>3.13.0</compiler-plugin.version>
<failsafe.useModulePath>false</failsafe.useModulePath>
<maven.compiler.release>{{ .JavaVersion }}</maven.compiler.release>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<properties>
<java.version>{{ .JavaVersion }}</java.version>
<project.build.outputTimestamp>{{ .ProjectBuildOutputTimestamp }}</project.build.outputTimestamp>
{{ .BuildProperties }}
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,17 @@ private boolean containsDependency(List<Dependency> deps, String group, String a
private String toGAV(Dependency d) {
return d.getGroupId() + ":" + d.getArtifactId() + ":" + d.getVersion();
}

@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldGenerateReproducibleBuild(RuntimeType rt) throws Exception {
Export command = createCommand(rt, new String[] { "classpath:route.yaml" },
"--gav=examples:route:1.0.0", "--dir=" + workingDir, "--quiet");
int exit = command.doCall();

Assertions.assertEquals(0, exit);
Model model = readMavenModel();
Assertions.assertNotNull(model.getProperties().get("project.build.outputTimestamp"));
}

}