Browse Source

[Improvement] The newly introduced spi pugin support work in windows os

The newly introduced spi can't work in windows os.
2.0.7-release
kyoty 3 years ago committed by GitHub
parent
commit
b05957db41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginDiscovery.java

12
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginDiscovery.java

@ -36,6 +36,7 @@ import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Collectors;
import org.objectweb.asm.ClassReader;
@ -49,8 +50,15 @@ import com.google.common.io.ByteStreams;
* The role of this class is to load the plugin class during development
*/
final class DolphinPluginDiscovery {
// Windows: \target\classes, Unix-like: /target/classes
private static final String ARTIFACT_DIR = new StringJoiner(File.separator, File.separator, "")
.add("target").add("classes").toString();
private static final String JAVA_CLASS_FILE_SUFFIX = ".class";
private static final String PLUGIN_SERVICES_FILE = "META-INF/services/" + DolphinSchedulerPlugin.class.getName();
// Windows: "META-INF\services\" + DolphinSchedulerPlugin.class.getName()
// Unix-like: "META-INF/services/" + DolphinSchedulerPlugin.class.getName()
private static final String PLUGIN_SERVICES_FILE = String.join(File.separator, "META-INF",
"services", DolphinSchedulerPlugin.class.getName());
private DolphinPluginDiscovery() {
}
@ -62,7 +70,7 @@ final class DolphinPluginDiscovery {
}
File file = artifact.getFile();
if (!file.getPath().endsWith("/target/classes")) {
if (!file.getPath().endsWith(ARTIFACT_DIR)) {
throw new RuntimeException("Unexpected file for main artifact: " + file);
}
if (!file.isDirectory()) {

Loading…
Cancel
Save