Browse Source

Improving development mode experience for Gradle users #195 (#221)

pull/222/head
Shawn Sherwood 7 years ago committed by Decebal Suiu
parent
commit
4a6d840057
  1. 5
      pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java
  2. 28
      pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java

5
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;

28
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<Path> 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<Path> 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<Path> 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<Path> paths, Path path) {
assertFalse("The directory must not contain the file " + path, paths.contains(path));
}
private Path getPluginsRoot() {
return testFolder.getRoot().toPath();
}

Loading…
Cancel
Save