Skip to content

Commit 93a49ab

Browse files
committed
Merge pull request matyb#32 from flatiron32/master
Made run quieter and built classpath to include all jars in lib
2 parents 0cee177 + bc53b26 commit 93a49ab

5 files changed

Lines changed: 34 additions & 13 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ bin/*
44
*/bin/*
55
koans/data
66
koans/data*
7+
.classpath
8+
.project

‎koans/run.sh‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2-
mkdir "$DIR"/app
3-
mkdir "$DIR"/app/bin
2+
mkdir -p "$DIR"/app
3+
mkdir -p "$DIR"/app/bin
44
function exitOnError()
55
{
66
rc=$?
77
if [[ $rc != 0 ]] ; then
88
exit $rc
99
fi
1010
}
11-
javac -help
11+
12+
function buildClasspath()
13+
{
14+
appDir=$1
15+
classpath=$appDir/bin
16+
17+
for jar in $appDir/lib/*; do
18+
classpath=$classpath:$jar
19+
done
20+
}
21+
javac -help > /dev/null 2>&1
1222
exitOnError
13-
java -version
23+
java -version > /dev/null 2>&1
1424
exitOnError
15-
clear
16-
java -classpath "$DIR"/app/bin:"$DIR"/app/lib/koans.jar com.sandwich.koan.runner.AppLauncher "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
25+
buildClasspath "$DIR"/app
26+
java -classpath $classpath com.sandwich.koan.runner.AppLauncher "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"

‎lib/file-compiler/src/com/sandwich/util/io/FileCompilerAction.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ private String[] getClasspath() {
112112
}else{
113113
return new String[]{};
114114
}
115-
for(int i = 1; i <= classPaths.length; i++){
116-
classpaths[i] = classPaths[i - 1];
115+
116+
String classpath = "";
117+
for(String jar : classPaths) {
118+
classpath += jar + java.io.File.pathSeparatorChar;
117119
}
118-
return classpaths;
120+
return new String[] {"-classpath", classpath};
119121
}
120122

121123
public File makeDestination(File dest, String fileInDirectory) {

‎lib/koans-lib/src/com/sandwich/koan/KoanClassLoader.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ public class KoanClassLoader extends ClassLoader {
1414
public static DynamicClassLoader createInstance() {
1515
String binDir = DirectoryManager.getBinDir();
1616
String sourceDir = DirectoryManager.getSourceDir();
17-
String[] classPath = new String[]{DirectoryManager.getProjectLibraryDir() +
18-
DirectoryManager.FILESYSTEM_SEPARATOR + "koans.jar"};
17+
File[] jars = new File(DirectoryManager.getProjectLibraryDir()).listFiles();
18+
String[] classPath = new String[jars.length];
19+
for (int i = 0; i < jars.length; i++) {
20+
classPath[i] = jars[i].getAbsolutePath();
21+
}
1922
FileMonitor fileMonitor = FileMonitorFactory.getInstance(
2023
new File(DirectoryManager.getProdMainDir()), new File(DirectoryManager.getDataFile()));
2124
ClassLoader classLoader = DynamicClassLoader.class.getClassLoader();

‎lib/koans-lib/src/com/sandwich/util/io/KoanFileCompileAndRunListener.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ public void fileSaved(File file) {
2626
String absolutePath = file.getAbsolutePath();
2727
if(absolutePath.toLowerCase().endsWith(FileCompiler.JAVA_SUFFIX)){
2828
ApplicationUtils.getPresenter().displayMessage(KoanConstants.EOL+"loading: "+absolutePath);
29+
File[] jars = new File(DirectoryManager.getProjectLibraryDir()).listFiles();
30+
String[] classPath = new String[jars.length];
31+
for (int i = 0; i < jars.length; i++) {
32+
classPath[i] = jars[i].getAbsolutePath();
33+
}
2934
try {
3035
FileCompiler.compile(file,
3136
new File(DirectoryManager.getBinDir()),
3237
listener,
3338
ApplicationSettings.getFileCompilationTimeoutInMs(),
34-
new String[]{DirectoryManager.injectFileSystemSeparators(
35-
DirectoryManager.getProjectLibraryDir(), "koans.jar")});
39+
classPath);
3640
DynamicClassLoader.remove(FileCompiler.sourceToClass(
3741
DirectoryManager.getSourceDir(), DirectoryManager.getBinDir(), file).toURI().toURL());
3842
if(!listener.isLastCompilationAttemptFailure()){

0 commit comments

Comments
 (0)