mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 09:48:03 +00:00
add wildcard support from commandline
This commit is contained in:
parent
e4d3f1a141
commit
68e1f59ccc
5
pom.xml
5
pom.xml
@ -93,6 +93,11 @@
|
|||||||
<artifactId>commons-cli</artifactId>
|
<artifactId>commons-cli</artifactId>
|
||||||
<version>1.8.0</version>
|
<version>1.8.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.8.0</version> <!-- Check for the latest version -->
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -10,9 +10,13 @@ import de.maishai.typedast.typedclass.TypedClass;
|
|||||||
import de.maishai.typedast.typedclass.TypedProgram;
|
import de.maishai.typedast.typedclass.TypedProgram;
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
||||||
import org.apache.commons.cli.*;
|
import org.apache.commons.cli.*;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Formatter;
|
import java.util.logging.Formatter;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
@ -137,9 +141,27 @@ public class Compiler {
|
|||||||
|
|
||||||
List<String> sourcePaths = new ArrayList<>();
|
List<String> sourcePaths = new ArrayList<>();
|
||||||
for (String arg : cmd.getArgs()) {
|
for (String arg : cmd.getArgs()) {
|
||||||
|
if (arg.contains("*")) {
|
||||||
|
sourcePaths.addAll(expandWildcards(arg));
|
||||||
|
} else {
|
||||||
String sourcePath = arg.endsWith(JAVA_FILE_EXTENSION) ? arg : arg + JAVA_FILE_EXTENSION;
|
String sourcePath = arg.endsWith(JAVA_FILE_EXTENSION) ? arg : arg + JAVA_FILE_EXTENSION;
|
||||||
sourcePaths.add(sourcePath);
|
sourcePaths.add(sourcePath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
generateByteCodeFilesFromFiles(sourcePaths);
|
generateByteCodeFilesFromFiles(sourcePaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<String> expandWildcards(String pattern) {
|
||||||
|
List<String> matchingFiles = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
File dir = new File(".");
|
||||||
|
Collection<File> files = FileUtils.listFiles(dir, new WildcardFileFilter(pattern), null);
|
||||||
|
for (File file : files) {
|
||||||
|
matchingFiles.add(file.getPath());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.severe("Error expanding wildcards: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return matchingFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user