diff --git a/builder/pom.xml b/builder/pom.xml index 73d39c3..18f07d5 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -31,7 +31,6 @@ 1.0.0 2.13.0 3.9.0 - 0.3.0 2.18.1 3.0.0 @@ -60,11 +59,6 @@ ${lombok.version} provided - - net.kemitix - conditional - ${conditional.version} - io.github.lukehutch fast-classpath-scanner diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java index 795271a..0628f4d 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java @@ -21,14 +21,9 @@ package net.kemitix.checkstyle.ruleset.builder; -import com.google.common.reflect.ClassPath; import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; -import lombok.RequiredArgsConstructor; -import net.kemitix.conditional.Value; import org.springframework.stereotype.Service; -import java.net.URLClassLoader; -import java.util.function.Supplier; import java.util.stream.Stream; /** @@ -37,30 +32,12 @@ import java.util.stream.Stream; * @author Paul Campbell (pcampbell@kemitix.net). */ @Service -@RequiredArgsConstructor public class DefaultPackageScanner implements PackageScanner { - private final ClassPath classPath; - @Override public final Stream apply(final RuleSource ruleSource) { - return Value.>where(isJava8()) - .then(scanPackageByClassPath(ruleSource.getBasePackage())) - .otherwise(scanPackageByModulePath(ruleSource.getBasePackage())); - } - - private boolean isJava8() { - return getClass().getClassLoader() instanceof URLClassLoader; - } - - private Supplier> scanPackageByClassPath(final String basePackage) { - return () -> classPath.getTopLevelClassesRecursive(basePackage) - .stream() - .map(ClassPath.ClassInfo::getName); - } - - private Supplier> scanPackageByModulePath(final String basePackage) { - return () -> new FastClasspathScanner(basePackage) + final String basePackage = ruleSource.getBasePackage(); + return new FastClasspathScanner(basePackage) .scan() .getNamesOfAllStandardClasses() .stream() diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java index 240d12c..92ca00b 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java @@ -1,10 +1,7 @@ package net.kemitix.checkstyle.ruleset.builder; -import com.google.common.reflect.ClassPath; -import org.junit.Before; import org.junit.Test; -import java.io.IOException; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -16,16 +13,10 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class DefaultPackageScannerTest { - private PackageScanner scanner; - - @Before - public void setUp() throws Exception { - final ClassPath classPath = ClassPath.from(getClass().getClassLoader()); - scanner = new DefaultPackageScanner(classPath); - } + private PackageScanner scanner = new DefaultPackageScanner(); @Test - public void canScanCheckstylePackage() throws IOException { + public void canScanCheckstylePackage() { //when final Stream result = scanner.apply(RuleSource.CHECKSTYLE); //then @@ -34,7 +25,7 @@ public class DefaultPackageScannerTest { } @Test - public void canScanSevntuPackage() throws IOException { + public void canScanSevntuPackage() { //when final Stream result = scanner.apply(RuleSource.SEVNTU); //then