Skip to content

Commit

Permalink
Use fileName.startsWith instead of contains.
Browse files Browse the repository at this point in the history
Should make filters a bit more strict. Closes #6
  • Loading branch information
LexManos committed Aug 10, 2021
1 parent 2d2081a commit ba5f05c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/bin/
/.classpath
/.project
/repo/
11 changes: 6 additions & 5 deletions src/main/java/cpw/mods/bootstraplauncher/BootstrapLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import java.util.Set;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class BootstrapLauncher {
private static final boolean DEBUG = System.getProperties().containsKey("bsl.debug");
@SuppressWarnings("unchecked")
public static void main(String[] args) {
var legacyCP = loadLegacyClassPath();
System.setProperty("legacyClassPath", String.join(File.pathSeparator, legacyCP)); //Ensure backwards compatibility if somebody reads this value later on.
var ignoreList = System.getProperty("ignoreList", "/org/ow2/asm/,securejarhandler"); //TODO: find existing modules automatically instead of taking in an ignore list.
var ignoreList = System.getProperty("ignoreList", "asm,securejarhandler"); //TODO: find existing modules automatically instead of taking in an ignore list.
var ignores = ignoreList.split(",");

var previousPkgs = new HashSet<String>();
Expand All @@ -40,18 +39,20 @@ public static void main(String[] args) {

outer:
for (var legacy : legacyCP) {
var path = Paths.get(legacy);
var filename = path.getFileName().toString();

for (var filter : ignores) {
if (legacy.contains(filter)) {
if (filename.startsWith(filter)) {
if (DEBUG)
System.out.println(legacy + " IGNORED: " + filter);
continue outer;
}
}

var path = Paths.get(legacy);
if (DEBUG)
System.out.println(path);
var filename = path.getFileName().toString();

if (filenameMap.containsKey(filename)) {
mergeMap.computeIfAbsent(filenameMap.get(filename), k -> new ArrayList<>()).add(path);
continue;
Expand Down

0 comments on commit ba5f05c

Please sign in to comment.