summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java2
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java19
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java2
-rw-r--r--pf4j/src/test/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinderTest.java2
-rw-r--r--pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java2
5 files changed, 24 insertions, 3 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
index fba63ea..f9ef927 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
@@ -74,6 +74,8 @@ public abstract class ManifestPluginDescriptorFinder implements PluginDescriptor
pluginDescriptor.setRequires(requires);
}
+ pluginDescriptor.setLicense(attributes.getValue("Plugin-License"));
+
return pluginDescriptor;
}
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
index 21ada3f..aa018a1 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
@@ -39,6 +39,7 @@ public class PluginDescriptor {
private Expression requires;
private String provider;
private List<PluginDependency> dependencies;
+ private String license;
public PluginDescriptor() {
requires = gte("0.0.0"); // Any
@@ -88,6 +89,13 @@ public class PluginDescriptor {
}
/**
+ * Returns the legal license of this plugin, e.g. "Apache-2.0", "MIT" etc
+ */
+ public String getLicense() {
+ return license;
+ }
+
+ /**
* Returns all dependencies declared by this plugin.
* Returns an empty array if this plugin does not declare any require.
*/
@@ -99,8 +107,9 @@ public class PluginDescriptor {
public String toString() {
return "PluginDescriptor [pluginId=" + pluginId + ", pluginClass="
+ pluginClass + ", version=" + version + ", provider="
- + provider + ", dependencies=" + dependencies
- + "]";
+ + provider + ", dependencies=" + dependencies + ", description="
+ + pluginDescription + ", requires=" + requires + ", license="
+ + license + "]";
}
void setPluginId(String pluginId) {
@@ -125,7 +134,7 @@ public class PluginDescriptor {
void setRequires(String requires) {
Parser<Expression> parser = ExpressionParser.newInstance();
- this.requires = parser.parse(requires);
+ setRequires(parser.parse(requires));
}
void setRequires(Expression requires) {
@@ -155,4 +164,8 @@ public class PluginDescriptor {
}
}
+ public void setLicense(String license) {
+ this.license = license;
+ }
+
}
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java
index b774cf9..ee47562 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinder.java
@@ -108,6 +108,8 @@ public class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder
pluginDescriptor.setRequires(requires);
}
+ pluginDescriptor.setLicense(properties.getProperty("plugin.license"));
+
return pluginDescriptor;
}
diff --git a/pf4j/src/test/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinderTest.java b/pf4j/src/test/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinderTest.java
index 0e94fcd..1ccaa22 100644
--- a/pf4j/src/test/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinderTest.java
+++ b/pf4j/src/test/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinderTest.java
@@ -90,6 +90,7 @@ public class ManifestPluginDescriptorFinderTest {
assertEquals("test-plugin-2", plugin1.getDependencies().get(0).getPluginId());
assertEquals("test-plugin-3", plugin1.getDependencies().get(1).getPluginId());
assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport());
+ assertEquals("Apache-2.0", plugin1.getLicense());
assertTrue(plugin1.getRequires().interpret(Version.valueOf("1.0.0")));
assertEquals("test-plugin-2", plugin2.getPluginId());
@@ -153,6 +154,7 @@ public class ManifestPluginDescriptorFinderTest {
+ "Plugin-Class: ro.fortsoft.pf4j.plugin.TestPlugin\n"
+ "Plugin-Dependencies: test-plugin-2,test-plugin-3@~1.0\n"
+ "Plugin-Requires: *\n"
+ + "Plugin-License: Apache-2.0\n"
+ "Created-By: Apache Maven 3.0.5\n"
+ "Build-Jdk: 1.8.0_45\n"
+ "Specification-Version: 0.10.0-SNAPSHOT\n"
diff --git a/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java b/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java
index c578c68..9afb636 100644
--- a/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java
+++ b/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java
@@ -78,6 +78,7 @@ public class PropertiesPluginDescriptorFinderTest {
assertEquals("test-plugin-2", plugin1.getDependencies().get(0).getPluginId());
assertEquals("test-plugin-3", plugin1.getDependencies().get(1).getPluginId());
assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport());
+ assertEquals("Apache-2.0", plugin1.getLicense());
assertTrue(plugin1.getRequires().interpret(Version.valueOf("1.0.0")));
assertEquals("test-plugin-2", plugin2.getPluginId());
@@ -122,6 +123,7 @@ public class PropertiesPluginDescriptorFinderTest {
+ "plugin.class=ro.fortsoft.pf4j.plugin.TestPlugin\n"
+ "plugin.dependencies=test-plugin-2,test-plugin-3@~1.0\n"
+ "plugin.requires=*\n"
+ + "plugin.license=Apache-2.0\n"
+ "\n"
+ ""
};