diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2018-05-25 21:58:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-25 21:58:03 +0300 |
commit | 291d1b8b88cf42825d3391bbb9ce78bba31fa384 (patch) | |
tree | b892e1ed499ddccd30a85f97b5100ab202931669 | |
parent | c2f888d9acd5f58e8bf18b083db46605a1f4ede2 (diff) | |
download | pf4j-291d1b8b88cf42825d3391bbb9ce78bba31fa384.tar.gz pf4j-291d1b8b88cf42825d3391bbb9ce78bba31fa384.zip |
Improve DevelopmentPluginClasspath according #195 (#219)
-rw-r--r-- | pf4j/src/main/java/org/pf4j/DevelopmentPluginClasspath.java | 32 | ||||
-rw-r--r-- | pf4j/src/main/java/org/pf4j/PluginClasspath.java | 48 |
2 files changed, 55 insertions, 25 deletions
diff --git a/pf4j/src/main/java/org/pf4j/DevelopmentPluginClasspath.java b/pf4j/src/main/java/org/pf4j/DevelopmentPluginClasspath.java index ba86bf5..15da659 100644 --- a/pf4j/src/main/java/org/pf4j/DevelopmentPluginClasspath.java +++ b/pf4j/src/main/java/org/pf4j/DevelopmentPluginClasspath.java @@ -16,17 +16,39 @@ package org.pf4j; /** - * Overwrite classes directories to {@code target/classes} and lib directories to {@code target/lib}. + * It's a compound {@link PluginClasspath} ({@link #MAVEN} + {@link #GRADLE} + {@link #KOTLIN}) + * used in development mode ({@link RuntimeMode#DEVELOPMENT}). * * @author Decebal Suiu */ public class DevelopmentPluginClasspath extends PluginClasspath { - public DevelopmentPluginClasspath() { - super(); + /** + * The development plugin classpath for <a href="https://maven.apache.org">Maven</a>. + * The classes directory is {@code target/classes} and the lib directory is {@code target/lib}. + */ + public static final PluginClasspath MAVEN = new PluginClasspath().addClassesDirectories("target/classes").addLibDirectories("target/lib"); - addClassesDirectories("target/classes"); - addLibDirectories("target/lib"); + /** + * The development plugin classpath for <a href="https://gradle.org">Gradle</a>. + * The classes directories are {@code build/classes/java/main, build/resources/main}. + */ + public static final PluginClasspath GRADLE = new PluginClasspath().addClassesDirectories("build/classes/java/main", "build/resources/main"); + + /** + * The development plugin classpath for <a href="https://kotlinlang.org">Kotlin</a>. + * The classes directories are {@code build/classes/kotlin/main", build/resources/main, build/tmp/kapt3/classes/main}. + */ + public static final PluginClasspath KOTLIN = new PluginClasspath().addClassesDirectories("build/classes/kotlin/main", "build/resources/main", "build/tmp/kapt3/classes/main"); + + public DevelopmentPluginClasspath() { + addClassesDirectories(MAVEN.getClassesDirectories()); + addClassesDirectories(GRADLE.getClassesDirectories()); + addClassesDirectories(KOTLIN.getClassesDirectories()); + + addLibDirectories(MAVEN.getLibDirectories()); + addLibDirectories(GRADLE.getLibDirectories()); + addLibDirectories(KOTLIN.getLibDirectories()); } } diff --git a/pf4j/src/main/java/org/pf4j/PluginClasspath.java b/pf4j/src/main/java/org/pf4j/PluginClasspath.java index 2a6f2cc..57ff9bf 100644 --- a/pf4j/src/main/java/org/pf4j/PluginClasspath.java +++ b/pf4j/src/main/java/org/pf4j/PluginClasspath.java @@ -15,9 +15,10 @@ */ package org.pf4j; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; /** * The classpath of the plugin. @@ -27,28 +28,35 @@ import java.util.List; */ public class PluginClasspath { - private List<String> classesDirectories; - private List<String> libDirectories; + private Set<String> classesDirectories = new HashSet<>(); + private Set<String> libDirectories = new HashSet<>(); - public PluginClasspath() { - classesDirectories = new ArrayList<>(); - libDirectories = new ArrayList<>(); - } + public Set<String> getClassesDirectories() { + return classesDirectories; + } - public List<String> getClassesDirectories() { - return classesDirectories; - } + public PluginClasspath addClassesDirectories(String... classesDirectories) { + return addClassesDirectories(Arrays.asList(classesDirectories)); + } - public void addClassesDirectories(String... classesDirectories) { - this.classesDirectories.addAll(Arrays.asList(classesDirectories)); - } + public PluginClasspath addClassesDirectories(Collection<String> classesDirectories) { + this.classesDirectories.addAll(classesDirectories); - public List<String> getLibDirectories() { - return libDirectories; - } + return this; + } - public void addLibDirectories(String... libDirectories) { - this.libDirectories.addAll(Arrays.asList(libDirectories)); - } + public Set<String> getLibDirectories() { + return libDirectories; + } + + public PluginClasspath addLibDirectories(String... libDirectories) { + return addLibDirectories(Arrays.asList(libDirectories)); + } + + public PluginClasspath addLibDirectories(Collection<String> libDirectories) { + this.libDirectories.addAll(libDirectories); + + return this; + } } |