Skip to content

Commit

Permalink
Improve API of module detector.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 8, 2025
1 parent 8f0835f commit ee575bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -20,8 +21,8 @@
import edu.hm.hafner.analysis.FileNameResolver;
import edu.hm.hafner.analysis.FingerprintGenerator;
import edu.hm.hafner.analysis.FullTextFingerprint;
import edu.hm.hafner.analysis.ModuleDetector;
import edu.hm.hafner.analysis.ModuleDetector.FileSystem;
import edu.hm.hafner.analysis.ModuleDetectorRunner;
import edu.hm.hafner.analysis.ModuleDetectorRunner.FileSystemFacade;
import edu.hm.hafner.analysis.ModuleResolver;
import edu.hm.hafner.analysis.PackageNameResolver;
import edu.hm.hafner.analysis.Report;
Expand Down Expand Up @@ -335,8 +336,9 @@ private void resolveModuleNames(final Report report, final File workspace) {
report.logInfo("Resolving module names from module definitions (build.xml, pom.xml, or Manifest.mf files)");

try {
ModuleResolver resolver = new ModuleResolver();
resolver.run(report, new ModuleDetector(workspace.toPath(), new DefaultFileSystem()));
var runner = new ModuleDetectorRunner(workspace.toPath(), new DefaultFileSystem());
var resolver = new ModuleResolver(runner);
resolver.run(report);
}
catch (InvalidPathException exception) {
report.logException(exception, "Resolving of modul names aborted");
Expand Down Expand Up @@ -370,16 +372,16 @@ private void createFingerprints(final Report report) {
/**
* Provides file system operations using real IO.
*/
private static final class DefaultFileSystem implements FileSystem {
private static final class DefaultFileSystem implements FileSystemFacade {
@MustBeClosed
@Override
public InputStream open(final String fileName) throws IOException {
return Files.newInputStream(Paths.get(fileName));
}

@Override
public String[] find(final Path root, final String pattern) {
return new FileFinder(pattern).find(root.toFile());
public List<String> find(final Path root, final String pattern) {
return Arrays.stream(new FileFinder(pattern).find(root.toFile())).toList();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.junit.jupiter.api.Test;

import edu.hm.hafner.analysis.ModuleDetector;
import edu.hm.hafner.analysis.ModuleDetectorRunner;

import hudson.FilePath;
import hudson.model.FreeStyleProject;
Expand All @@ -23,7 +23,7 @@
import static org.assertj.core.api.Assertions.*;

/**
* Integration test for the {@link ModuleDetector}.
* Integration test for the {@link ModuleDetectorRunner}.
*
* <p>
* These tests work on several pom.xml, build.xml and MANIFEST.MF files that will be copied to the workspace for each
Expand Down

0 comments on commit ee575bf

Please sign in to comment.