Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues#1347] Enforce reproducible build #6001

Merged
merged 3 commits into from
Jun 24, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/pr-drools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Build Chain
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/build-chain@main
env:
BUILD_MVN_OPTS_CURRENT: -Dfull
BUILD_MVN_OPTS_CURRENT: '-Dfull -Dreproducible'
MAVEN_OPTS: "-Dfile.encoding=UTF-8"
with:
definition-file: https://raw.githubusercontent.com/${GROUP:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/pull-request-config.yaml
Expand Down
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
Loading