Skip to content

Commit

Permalink
Ignore additional classpath on usecase when using the plugin
Browse files Browse the repository at this point in the history
It is not appropriate for the plugin to assume that an arbitrary classpath will be present (particularly if used in CI-type pipelines).
In order for the before refactor classes to compile the classpath will already need to include the class path. If the 'after' classpath needs to be different either the project pom can be amended upfront or else the plugin can be declared with additional dependencies.
  • Loading branch information
harrisric authored Dec 4, 2024
1 parent 12c42a1 commit 419bdb2
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,16 @@ public class RefactorMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException {

List<String> testClasspathElements;
try {
List<String> testClasspathElements;
try {
testClasspathElements = project.getTestClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unable to resolve test class path for the project", e);
}

// remove anything within this projects target directory as it has been
// remove anything within this projects target directory as this will invalidate it
testClasspathElements.removeIf(s -> s.startsWith(targetDirectory));

// might need to add source from other projects if running multi-module??

UseCase useCaseInstance = getUseCaseInstance();
AstraCore.run(sourceDirectory.getAbsolutePath(), new UseCase() {

Expand All @@ -86,9 +84,7 @@ public Predicate<String> getPrefilteringPredicate() {

@Override
public Set<String> getAdditionalClassPathEntries() {
HashSet<String> additionalClassPath = new HashSet<>(useCaseInstance.getAdditionalClassPathEntries());
additionalClassPath.addAll(testClasspathElements);
return additionalClassPath;
return Set.of();
}
});

Expand Down

0 comments on commit 419bdb2

Please sign in to comment.