Skip to content

Commit 765a3ef

Browse files
committed
Move DefaultClasspathScanner to org.junit.platform.commons.util
...to avoid package cycle
1 parent a78daf5 commit 765a3ef

File tree

10 files changed

+18
-31
lines changed

10 files changed

+18
-31
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11-
package org.junit.platform.commons.support.scanning;
11+
package org.junit.platform.commons.util;
1212

1313
import static java.nio.file.FileVisitResult.CONTINUE;
1414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11-
package org.junit.platform.commons.support.scanning;
11+
package org.junit.platform.commons.util;
1212

1313
import java.nio.file.Path;
1414
import java.util.function.Predicate;

junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClasspathScannerLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import org.junit.platform.commons.JUnitException;
1818
import org.junit.platform.commons.support.scanning.ClasspathScanner;
19-
import org.junit.platform.commons.support.scanning.DefaultClasspathScanner;
2019

2120
/**
2221
* @since 1.12
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11-
package org.junit.platform.commons.support.scanning;
11+
package org.junit.platform.commons.util;
1212

1313
import static java.util.Collections.emptyMap;
1414

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11-
package org.junit.platform.commons.support.scanning;
11+
package org.junit.platform.commons.util;
1212

1313
import static java.util.stream.Collectors.joining;
14-
import static org.apiguardian.api.API.Status.INTERNAL;
15-
import static org.junit.platform.commons.support.scanning.ClasspathFilters.CLASS_FILE_SUFFIX;
14+
import static org.junit.platform.commons.util.ClasspathFilters.CLASS_FILE_SUFFIX;
1615
import static org.junit.platform.commons.util.StringUtils.isNotBlank;
1716

1817
import java.io.IOException;
@@ -33,15 +32,13 @@
3332
import java.util.function.Supplier;
3433
import java.util.stream.Stream;
3534

36-
import org.apiguardian.api.API;
3735
import org.junit.platform.commons.PreconditionViolationException;
3836
import org.junit.platform.commons.function.Try;
3937
import org.junit.platform.commons.logging.Logger;
4038
import org.junit.platform.commons.logging.LoggerFactory;
4139
import org.junit.platform.commons.support.Resource;
42-
import org.junit.platform.commons.util.PackageUtils;
43-
import org.junit.platform.commons.util.Preconditions;
44-
import org.junit.platform.commons.util.UnrecoverableExceptions;
40+
import org.junit.platform.commons.support.scanning.ClassFilter;
41+
import org.junit.platform.commons.support.scanning.ClasspathScanner;
4542

4643
/**
4744
* <h2>DISCLAIMER</h2>
@@ -52,8 +49,7 @@
5249
*
5350
* @since 1.0
5451
*/
55-
@API(status = INTERNAL, since = "1.12")
56-
public class DefaultClasspathScanner implements ClasspathScanner {
52+
class DefaultClasspathScanner implements ClasspathScanner {
5753

5854
private static final Logger logger = LoggerFactory.getLogger(DefaultClasspathScanner.class);
5955

@@ -72,7 +68,7 @@ public class DefaultClasspathScanner implements ClasspathScanner {
7268

7369
private final BiFunction<String, ClassLoader, Try<Class<?>>> loadClass;
7470

75-
public DefaultClasspathScanner(Supplier<ClassLoader> classLoaderSupplier,
71+
DefaultClasspathScanner(Supplier<ClassLoader> classLoaderSupplier,
7672
BiFunction<String, ClassLoader, Try<Class<?>>> loadClass) {
7773

7874
this.classLoaderSupplier = classLoaderSupplier;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11-
package org.junit.platform.commons.support.scanning;
11+
package org.junit.platform.commons.util;
1212

1313
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
1414
import static org.junit.jupiter.api.Assertions.assertThrows;
15-
import static org.junit.platform.commons.support.scanning.CloseablePath.JAR_URI_SCHEME;
15+
import static org.junit.platform.commons.util.CloseablePath.JAR_URI_SCHEME;
1616
import static org.mockito.ArgumentMatchers.any;
1717
import static org.mockito.Mockito.mock;
1818
import static org.mockito.Mockito.only;
@@ -31,8 +31,8 @@
3131
import org.junit.jupiter.api.AfterEach;
3232
import org.junit.jupiter.api.BeforeEach;
3333
import org.junit.jupiter.api.Test;
34-
import org.junit.platform.commons.support.scanning.CloseablePath.FileSystemProvider;
3534
import org.junit.platform.commons.test.ConcurrencyTestingUtils;
35+
import org.junit.platform.commons.util.CloseablePath.FileSystemProvider;
3636
import org.junit.platform.engine.support.hierarchical.OpenTest4JAwareThrowableCollector;
3737

3838
class CloseablePathTests {
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11-
package org.junit.platform.commons.support.scanning;
11+
package org.junit.platform.commons.util;
1212

1313
import static java.util.Objects.requireNonNull;
1414
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,8 +49,7 @@
4949
import org.junit.platform.commons.function.Try;
5050
import org.junit.platform.commons.logging.LogRecordListener;
5151
import org.junit.platform.commons.support.Resource;
52-
import org.junit.platform.commons.util.ClassLoaderUtils;
53-
import org.junit.platform.commons.util.ReflectionUtils;
52+
import org.junit.platform.commons.support.scanning.ClassFilter;
5453

5554
/**
5655
* Unit tests for {@link DefaultClasspathScanner}.

platform-tests/src/test/resources/log4j2-test.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</Appenders>
88
<Loggers>
99
<Logger name="org.junit" level="warn" />
10-
<Logger name="org.junit.platform.commons.support.scanning.DefaultClasspathScanner" level="error" />
10+
<Logger name="org.junit.platform.commons.util.DefaultClasspathScanner" level="error" />
1111
<Logger name="org.junit.platform.engine.support.descriptor.DemoClassTestDescriptor" level="error" />
1212
<Logger name="org.junit.platform.launcher.core.CompositeEngineExecutionListener" level="error" />
1313
<Logger name="org.junit.platform.launcher.core.CompositeTestExecutionListener" level="error" />

platform-tooling-support-tests/projects/graalvm-starter/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ tasks.test {
3030
val initializeAtBuildTime = mapOf(
3131
// These need to be added to native-build-tools
3232
"6.0" to listOf(
33+
"org.junit.platform.commons.util.DefaultClasspathScanner",
3334
"org.junit.platform.commons.util.KotlinReflectionUtils",
3435
"org.junit.platform.launcher.core.DiscoveryIssueNotifier\$1",
3536
)

platform-tooling-support-tests/src/archUnit/java/platform/tooling/support/tests/ArchUnitTests.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,8 @@
5959
import org.junit.jupiter.params.support.ParameterInfo;
6060
import org.junit.platform.commons.support.Resource;
6161
import org.junit.platform.commons.support.scanning.ClasspathScanner;
62-
import org.junit.platform.commons.support.scanning.DefaultClasspathScanner;
6362
import org.junit.platform.commons.util.ModuleUtils;
64-
import org.junit.platform.commons.util.Preconditions;
6563
import org.junit.platform.commons.util.ReflectionUtils;
66-
import org.junit.platform.commons.util.StringUtils;
67-
import org.junit.platform.commons.util.UnrecoverableExceptions;
6864
import org.junit.platform.engine.TestDescriptor;
6965
import org.junit.platform.engine.reporting.OutputDirectoryProvider;
7066
import org.junit.platform.engine.support.hierarchical.ThrowableCollector;
@@ -153,12 +149,8 @@ void freeOfPackageCycles(JavaClasses classes) throws Exception {
153149
Resource.class) //
154150
.ignoreDependency(ReflectionUtils.class, Resource.class) //
155151
.ignoreDependency(ClasspathScanner.class, Resource.class) //
156-
.ignoreDependency(DefaultClasspathScanner.class, Resource.class) //
157-
158-
// Move DefaultClasspathScanner to org.junit.platform.commons.util?
159-
.ignoreDependency(DefaultClasspathScanner.class, Preconditions.class) //
160-
.ignoreDependency(DefaultClasspathScanner.class, StringUtils.class) //
161-
.ignoreDependency(DefaultClasspathScanner.class, UnrecoverableExceptions.class) //
152+
.ignoreDependency(Class.forName("org.junit.platform.commons.util.DefaultClasspathScanner"),
153+
Resource.class) //
162154

163155
// Needs more investigation
164156
.ignoreDependency(resideInAPackage("org.junit.platform.console.options"),

0 commit comments

Comments
 (0)