Browse Source

Add constants for manifest's attributes names

async
Decebal Suiu 6 years ago
parent
commit
363fdc85af
  1. 25
      pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java

25
pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java

@ -37,6 +37,15 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
private static final Logger log = LoggerFactory.getLogger(ManifestPluginDescriptorFinder.class);
public static final String PLUGIN_ID = "Plugin-Id";
public static final String PLUGIN_DESCRIPTION = "Plugin-Description";
public static final String PLUGIN_CLASS = "Plugin-Class";
public static final String PLUGIN_VERSION = "Plugin-Version";
public static final String PLUGIN_PROVIDER = "Plugin-Provider";
public static final String PLUGIN_DEPENDENCIES = "Plugin-Dependencies";
public static final String PLUGIN_REQUIRES = "Plugin-Requires";
public static final String PLUGIN_LICENSE = "Plugin-License";
@Override
public boolean isApplicable(Path pluginPath) {
return Files.exists(pluginPath) && (Files.isDirectory(pluginPath) || FileUtils.isJarFile(pluginPath));
@ -92,37 +101,37 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
// TODO validate !!!
Attributes attributes = manifest.getMainAttributes();
String id = attributes.getValue("Plugin-Id");
String id = attributes.getValue(PLUGIN_ID);
pluginDescriptor.setPluginId(id);
String description = attributes.getValue("Plugin-Description");
String description = attributes.getValue(PLUGIN_DESCRIPTION);
if (StringUtils.isNullOrEmpty(description)) {
pluginDescriptor.setPluginDescription("");
} else {
pluginDescriptor.setPluginDescription(description);
}
String clazz = attributes.getValue("Plugin-Class");
String clazz = attributes.getValue(PLUGIN_CLASS);
if (StringUtils.isNotNullOrEmpty(clazz)) {
pluginDescriptor.setPluginClass(clazz);
}
String version = attributes.getValue("Plugin-Version");
String version = attributes.getValue(PLUGIN_VERSION);
if (StringUtils.isNotNullOrEmpty(version)) {
pluginDescriptor.setPluginVersion(version);
}
String provider = attributes.getValue("Plugin-Provider");
String provider = attributes.getValue(PLUGIN_PROVIDER);
pluginDescriptor.setProvider(provider);
String dependencies = attributes.getValue("Plugin-Dependencies");
String dependencies = attributes.getValue(PLUGIN_DEPENDENCIES);
pluginDescriptor.setDependencies(dependencies);
String requires = attributes.getValue("Plugin-Requires");
String requires = attributes.getValue(PLUGIN_REQUIRES);
if (StringUtils.isNotNullOrEmpty(requires)) {
pluginDescriptor.setRequires(requires);
}
pluginDescriptor.setLicense(attributes.getValue("Plugin-License"));
pluginDescriptor.setLicense(attributes.getValue(PLUGIN_LICENSE));
return pluginDescriptor;
}

Loading…
Cancel
Save