diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java index 626c729..727e3ba 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java @@ -47,10 +47,16 @@ public class BuilderConfiguration { * @return the ClassPath * * @throws IOException if there is an error + * @param classLoader */ @Bean - public ClassPath classPath() throws IOException { - return ClassPath.from(getClass().getClassLoader()); + public ClassPath classPath(final ClassLoader classLoader) throws IOException { + return ClassPath.from(classLoader); + } + + @Bean + public ClassLoader classLoader() { + return BuilderConfiguration.class.getClassLoader(); } /** diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java index 9279196..63eb6c2 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java @@ -23,7 +23,8 @@ public class BuilderConfigurationTest { @Test public void canGetClassPath() throws IOException { //when - final ClassPath classPath = new BuilderConfiguration().classPath(); + final BuilderConfiguration builderConfiguration = new BuilderConfiguration(); + final ClassPath classPath = builderConfiguration.classPath(builderConfiguration.getClass().getClassLoader()); //then assertThat(classPath).isNotNull(); }