diff --git a/pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java b/pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java index e3dd4d0..78ea43c 100644 --- a/pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java +++ b/pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java @@ -75,7 +75,10 @@ public class DefaultPluginRepository extends BasePluginRepository { OrFileFilter hiddenPluginFilter = new OrFileFilter(new HiddenFilter()); if (development) { - hiddenPluginFilter.addFileFilter(new NameFileFilter("target")); + // skip default build output folders since these will cause errors in the logs + hiddenPluginFilter + .addFileFilter(new NameFileFilter("target")) // MAVEN + .addFileFilter(new NameFileFilter("build")); // GRADLE } return hiddenPluginFilter; diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java index be77114..cb629d5 100644 --- a/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java +++ b/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java @@ -48,6 +48,9 @@ public class DefaultPluginRepositoryTest { Files.createFile(Paths.get(testFolder.getRoot().getAbsolutePath()).resolve("plugin-1.zip")); testFolder.newFolder("plugin-2"); testFolder.newFolder("plugin-3"); + // standard maven/gradle bin folder - these should be skipped in development mode because the cause errors + testFolder.newFolder("target"); + testFolder.newFolder("build"); } /** @@ -61,10 +64,27 @@ public class DefaultPluginRepositoryTest { List result = instance.getPluginPaths(); - assertEquals(3, result.size()); + assertEquals(5, result.size()); assertPathExists(result, pluginsRoot.resolve("plugin-1")); assertPathExists(result, pluginsRoot.resolve("plugin-2")); assertPathExists(result, pluginsRoot.resolve("plugin-3")); + // when not in development mode we will honor these folders + assertPathExists(result, pluginsRoot.resolve("target")); + assertPathExists(result, pluginsRoot.resolve("build")); + } + + @Test + public void testGetPluginArchivesInDevelopmentMode() { + Path pluginsRoot = getPluginsRoot(); + + PluginRepository instance = new DefaultPluginRepository(pluginsRoot, true); + + List result = instance.getPluginPaths(); + + // target and build should be ignored + assertEquals(3, result.size()); + assertPathDoesNotExists(result, pluginsRoot.resolve("target")); + assertPathDoesNotExists(result, pluginsRoot.resolve("build")); } /** @@ -81,6 +101,8 @@ public class DefaultPluginRepositoryTest { assertFalse(Files.exists(pluginsRoot.resolve("plugin-1.zip"))); assertTrue(instance.deletePluginPath(pluginsRoot.resolve("plugin-3"))); assertFalse(instance.deletePluginPath(pluginsRoot.resolve("plugin-4"))); + assertTrue(instance.deletePluginPath(pluginsRoot.resolve("target"))); + assertTrue(instance.deletePluginPath(pluginsRoot.resolve("build"))); List result = instance.getPluginPaths(); @@ -92,6 +114,10 @@ public class DefaultPluginRepositoryTest { assertTrue("The directory must contain the file " + path, paths.contains(path)); } + private void assertPathDoesNotExists(List paths, Path path) { + assertFalse("The directory must not contain the file " + path, paths.contains(path)); + } + private Path getPluginsRoot() { return testFolder.getRoot().toPath(); }