Skip to content

Commit

Permalink
[incubator-kie-issues#1347] Enforce reproducible build (apache#6001)
Browse files Browse the repository at this point in the history
* [incubator-kie-issues#1347] Enforce reproducible build

* [incubator-kie-issues#1347] Enforce reproducible build - using custom property

* [incubator-kie-issues#1347] Enforce reproducible build - fix broken test on reproducible build

---------

Co-authored-by: Gabriele-Cardosi <[email protected]>
# Conflicts:
#	.github/workflows/pr-drools.yml
  • Loading branch information
rgdoliveira committed Jul 8, 2024
1 parent 307f1a7 commit e9eb000
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;

import org.junit.Test;
import org.kie.api.KieServices;
Expand Down Expand Up @@ -120,11 +122,19 @@ public static File getFile(String exampleName) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}

for (String str : targetFolder.list()) {
if (str.startsWith(exampleName) && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
FilenameFilter expectedJArFilter = (d, str ) -> str.startsWith(exampleName) &&
str.endsWith(".jar") &&
!str.endsWith("-sources.jar") &&
!str.endsWith("-tests.jar") &&
!str.endsWith("-javadoc.jar");
String[] foundFile = targetFolder.list(expectedJArFilter);
if (foundFile == null || foundFile.length == 0) {
throw new RuntimeException("The target jar does not exist, please build project " + exampleName + " first");
} else if (foundFile.length > 1) {
String errorFiles = Arrays.toString(foundFile);
throw new RuntimeException("Multiple matching files exists: " + errorFiles + "; please check!");
}
return new File(targetFolder, foundFile[0]);
}

throw new RuntimeException("The target jar does not exist, please build project " + exampleName + " first");
Expand Down
36 changes: 36 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,42 @@
<module>drools-distribution</module>
</modules>
</profile>
<profile>
<id>reproducible-build</id>
<activation>
<property>
<name>reproducible</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-artifact-plugin</artifactId>
<executions>
<execution>
<id>check-buildplan</id>
<goals>
<goal>check-buildplan</goal>
</goals>
<!-- The execution's configuration is part of the pluginManagement. This piece here only makes sure the
execution is enabled (by specifying a phase) for full profile builds. -->
<phase>validate</phase>
</execution>
<execution>
<id>compare</id>
<goals>
<goal>compare</goal>
</goals>
<!-- The execution's configuration is part of the pluginManagement. This piece here only makes sure the
execution is enabled (by specifying a phase) for full profile builds. -->
<phase>install</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile><!-- this profile is defined here in order to be available from the root of the drools repository and maven reactor build -->
<id>rewrite</id>
<build>
Expand Down

0 comments on commit e9eb000

Please sign in to comment.