Skip to content

Commit

Permalink
Fixing swallowed compilation errors due to package name / path mismat…
Browse files Browse the repository at this point in the history
…ch when using `dependsOn`.
  • Loading branch information
ammachado committed Feb 23, 2024
1 parent 7716bc4 commit 57be9a4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public B dependsOn(Collection<Input> inputs) {

public B dependsOn(@Language("java") String... inputsAsStrings) {
this.dependsOn = Arrays.stream(inputsAsStrings)
.map(Input::fromString)
.map(input -> Input.fromString(resolveSourcePathFromSourceText(Paths.get(""), input), input))
.collect(toList());
return (B) this;
}
Expand Down Expand Up @@ -417,6 +417,10 @@ public Builder<P, B> clone() {

@Override
default Path sourcePathFromSourceText(Path prefix, String sourceCode) {
return resolveSourcePathFromSourceText(prefix, sourceCode);
}

static Path resolveSourcePathFromSourceText(Path prefix, String sourceCode) {
Pattern packagePattern = Pattern.compile("^package\\s+([^;]+);");
Pattern classPattern = Pattern.compile("(class|interface|enum|record)\\s*(<[^>]*>)?\\s+(\\w+)");

Expand Down

0 comments on commit 57be9a4

Please sign in to comment.