summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2019-04-12 21:29:50 +0300
committerDecebal Suiu <decebal.suiu@gmail.com>2019-04-12 21:29:50 +0300
commit78a7802793806c84546a1f3b874e70b91b025829 (patch)
tree48c09de8c9e5daa4f14e40da7b263f1a23fdecaf
parent363fdc85afe47b3d878511c33f693681769e8d35 (diff)
downloadpf4j-78a7802793806c84546a1f3b874e70b91b025829.tar.gz
pf4j-78a7802793806c84546a1f3b874e70b91b025829.zip
Add possibility to add extra properties
-rw-r--r--pf4j/src/test/java/org/pf4j/plugin/PluginZip.java28
1 files changed, 21 insertions, 7 deletions
diff --git a/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java b/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java
index 72e3241..ee665d7 100644
--- a/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java
+++ b/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java
@@ -18,13 +18,14 @@ package org.pf4j.plugin;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
+import java.util.Map;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
- * Represents a plugin zip/jar file.
- * The "plugin.properties" file is created on the fly from the information supplied in Builder.
+ * Represents a plugin {@code zip} file.
+ * The {@code plugin.properties} file is created on the fly from the information supplied in {@link Builder}.
*
* @author Decebal Suiu
*/
@@ -65,6 +66,7 @@ public class PluginZip {
private final String pluginId;
private String pluginVersion;
+ private Map<String, String> properties;
public Builder(Path path, String pluginId) {
this.path = path;
@@ -77,6 +79,15 @@ public class PluginZip {
return this;
}
+ /**
+ * Add extra properties to the {@code properties} file.
+ */
+ public Builder properties(Map<String, String> properties) {
+ this.properties = properties;
+
+ return this;
+ }
+
public PluginZip build() throws IOException {
createPropertiesFile();
@@ -84,15 +95,18 @@ public class PluginZip {
}
protected void createPropertiesFile() throws IOException {
- Properties properties = new Properties();
- properties.setProperty("plugin.id", pluginId);
- properties.setProperty("plugin.version", pluginVersion);
- properties.setProperty("plugin.class", "org.pf4j.plugin.TestPlugin");
+ Properties props = new Properties();
+ props.setProperty("plugin.id", pluginId);
+ props.setProperty("plugin.version", pluginVersion);
+ props.setProperty("plugin.class", "org.pf4j.plugin.TestPlugin");
+ if (properties != null) {
+ props.putAll(properties);
+ }
ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(path.toFile()));
ZipEntry propertiesFile = new ZipEntry("plugin.properties");
outputStream.putNextEntry(propertiesFile);
- properties.store(outputStream, "");
+ props.store(outputStream, "");
outputStream.closeEntry();
outputStream.close();
}