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

[KIE-1339] fix Drools reproducible build also when running the complete test-suite #5999

Merged
merged 1 commit into from
Jun 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.drools.core.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
Expand All @@ -35,6 +36,7 @@
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

import org.junit.AfterClass;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -52,6 +54,16 @@ public class KeyStoreHelperTest {
private static final String KEY_PASSWORD = "keypwd";
private static final String KEY_PHRASE = "secretkey";

@AfterClass
public static void cleanup() {
try {
new File(KEYSTORE_JCEKS_FILENAME).delete();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is created when this test runs, so it has to be deleted in order to avoid that it mistakenly ends up in the test jar.

} catch (Exception e) {
// ignore
}

}

@Test
public void testSignDataWithPrivateKey() throws UnsupportedEncodingException,
UnrecoverableKeyException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.defaultkiesessionfromfile;

import java.io.File;
import java.io.PrintStream;

import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
Expand All @@ -26,9 +29,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;


public class DefaultKieSessionFromFileExample {

Expand Down Expand Up @@ -69,8 +69,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -80,14 +79,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
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")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and all subsequent fixes are all identical: the maven task checking the reproducible build adds more files to the target folder, so they have to be filtered away here in order to pick up the correct jar file to be used here.

return new File(targetFolder, str);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
*/
package org.drools.example.api.defaultkiesessionfromfile;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintStream;

import org.junit.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;

public class DefaultKieSessionFromByteArrayExampleTest {
Expand Down Expand Up @@ -105,8 +105,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -116,8 +115,7 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.kiemodulefrommultiplefiles;

import java.io.File;
import java.io.PrintStream;

import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
Expand All @@ -27,9 +30,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;


public class KieModuleFromMultipleFilesExample {

Expand Down Expand Up @@ -76,8 +76,7 @@ public static File getFile(String exampleName) {
File folder = new File( KieModuleFromMultipleFilesExample.class.getProtectionDomain().getCodeSource().getLocation().getPath() );
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -87,14 +86,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
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")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.kiemodulemodel;

import java.io.File;
import java.io.PrintStream;

import org.drools.base.util.Drools;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
Expand All @@ -31,9 +34,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;

public class KieModuleModelExample {

private static final Logger LOG = LoggerFactory.getLogger(KieModuleModelExample.class);
Expand Down Expand Up @@ -115,8 +115,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -126,14 +125,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
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")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.namedkiesessionfromfile;

import java.io.File;
import java.io.PrintStream;

import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
Expand All @@ -26,9 +29,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;


public class NamedKieSessionFromFileExample {

Expand Down Expand Up @@ -69,8 +69,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -80,14 +79,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
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")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down
Loading