Skip to content

Commit

Permalink
[Jenkins-65548] Fix - Random ordering of generated sources (#702)
Browse files Browse the repository at this point in the history
* [Jenkins-65548] Fix - Random ordering of generated sources

* `dos2unix src/main/java/org/jenkinsci/maven/plugins/hpi/TagLibInterfaceGeneratorMojo.java`

---------

Co-authored-by: Jesse Glick <jglick@cloudbees.com>
  • Loading branch information
code-arnab and jglick authored Dec 19, 2024
1 parent 20ddd26 commit f656765
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
Expand Down Expand Up @@ -118,6 +119,10 @@ private void report(JPackage pkg, String fileName) {
private void walk(File dir, JPackage pkg, String dirName) throws JClassAlreadyExistsException, IOException {
File[] children = dir.listFiles(File::isDirectory);
if (children != null) {
// Sorting the children to maintain a consistent order
// This is important for reproducible builds
Arrays.sort(children, (a, b) -> a.getName().compareToIgnoreCase(b.getName()));

for (File child : children) {
walk(child, pkg.subPackage(h2j(child.getName())), dirName + '/' + child.getName());
}
Expand All @@ -138,6 +143,10 @@ private void walk(File dir, JPackage pkg, String dirName) throws JClassAlreadyEx

File[] tags = dir.listFiles((unused, name) -> name.endsWith(".jelly"));

// Sorting the tags to maintain a consistent order
// This is important for reproducible builds
Arrays.sort(tags, (a, b) -> a.getName().compareToIgnoreCase(b.getName()));

long timestamp = -1;

for (File tag : tags) {
Expand Down

0 comments on commit f656765

Please sign in to comment.