Skip to content

Commit

Permalink
mod#148 Support multiple export modules TOs
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever authored and gunnarmorling committed Sep 1, 2021
1 parent 62b4613 commit 55630ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/java/org/moditect/model/PackageNamePattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public static enum Kind {
EXCLUSIVE;
}

// TODO multiple TOs
private static final Pattern INCLUSIVE_PATTERN = Pattern.compile( "(.*?)((\\s*to\\s)(.*))?" );
private static final Pattern EXCLUSIVE_PATTERN = Pattern.compile( "(!)(.*?)" );
private static final Pattern MODULES_PATTERN = Pattern.compile( "\\s*,\\s*" );

private final Kind kind;
private final Pattern pattern;
Expand Down Expand Up @@ -65,11 +65,15 @@ public static PackageNamePattern parsePattern(String pattern) {
throw new IllegalArgumentException( "Invalid inclusive pattern: " + pattern );
}
else {
return inclusive( matcher.group( 1 ), matcher.group( 2 ) != null ? Arrays.asList( matcher.group( 4 ) ) : Collections.emptyList() );
return inclusive( matcher.group( 1 ), matcher.group( 2 ) != null ? modules(matcher.group( 4 )) : Collections.emptyList() );
}
}
}

private static List<String> modules(String modules) {
return Arrays.asList(MODULES_PATTERN.split(modules));
}

private static PackageNamePattern inclusive(String pattern, List<String> targetModules) {
return new PackageNamePattern( Kind.INCLUSIVE, pattern, targetModules );
}
Expand Down

0 comments on commit 55630ba

Please sign in to comment.