From 695f4e40829100a00a51c28f9a30e0745bf5ceb3 Mon Sep 17 00:00:00 2001
From: 9Lukas5 <lukas.wiest@infinite-tech.solutions>
Date: Tue, 29 Dec 2020 16:30:11 +0100
Subject: [PATCH] fix(app): buildClasspath: build classpath differently for
 compile and runtime

---
 src/main/java/de/hftstuttgart/modocot/Testrunner.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main/java/de/hftstuttgart/modocot/Testrunner.java b/src/main/java/de/hftstuttgart/modocot/Testrunner.java
index 8f89284..c0d61b3 100644
--- a/src/main/java/de/hftstuttgart/modocot/Testrunner.java
+++ b/src/main/java/de/hftstuttgart/modocot/Testrunner.java
@@ -72,7 +72,6 @@ public class Testrunner
         libraryFolders = args[1].split(":");
         resultFolder = args[2];
         classFolder = Files.createTempDirectory("modocot-testrunner").toAbsolutePath().toString();
-        classPathItems = buildClassPathItems();
 
         // finding all source files
         Set<File> sourceFiles = new HashSet<>();
@@ -94,10 +93,14 @@ public class Testrunner
         writeResult(resultSummary);
     }
 
-    public static String[] buildClassPathItems()
+    public static String[] buildClassPathItems(boolean runtime)
     {
         Set<String> classPathItemsBuild = new HashSet<>(Arrays.asList(libraryFolders));
         classPathItemsBuild.add(classFolder);
+        if (runtime)
+        {
+            classPathItemsBuild.addAll(Arrays.stream(sourceFolders).collect(Collectors.toSet()));
+        }
         return classPathItemsBuild.toArray(new String[0]);
     }
 
@@ -140,6 +143,7 @@ public class Testrunner
 
     public static List<Diagnostic> compile(Set<File> files, File outputDir)
     {
+        classPathItems = buildClassPathItems(false);
         LOG.info("compilation started");
         List<Diagnostic> compilationErrors = new LinkedList<>();
 
@@ -311,6 +315,7 @@ public class Testrunner
 
     public static ModocotResultSummary runTests() throws MalformedURLException
     {
+        classPathItems = buildClassPathItems(true);
         LOG.info("saving original class loader");
         ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
         // get custom one
-- 
GitLab