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

The newly introduced spi can't work in windows os.
This commit is contained in:
kyoty 2021-06-17 14:54:55 +08:00 committed by GitHub
parent 86ffc1f3f2
commit b05957db41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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()) {