Pārlūkot izejas kodu

Improve PluginJar

tags/release-3.0.0
decebals pirms 5 gadiem
vecāks
revīzija
a8f00177d9
1 mainītis faili ar 23 papildinājumiem un 6 dzēšanām
  1. 23
    6
      pf4j/src/test/java/org/pf4j/plugin/PluginJar.java

+ 23
- 6
pf4j/src/test/java/org/pf4j/plugin/PluginJar.java Parādīt failu



import org.pf4j.ManifestPluginDescriptorFinder; import org.pf4j.ManifestPluginDescriptorFinder;


import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
return path; return path;
} }


public File file() {
return path.toFile();
}

public String pluginClass() { public String pluginClass() {
return pluginClass; return pluginClass;
} }


private String pluginClass; private String pluginClass;
private String pluginVersion; private String pluginVersion;
private Map<String, String> attributes;
private Map<String, String> manifestAttributes = new LinkedHashMap<>();


public Builder(Path path, String pluginId) { public Builder(Path path, String pluginId) {
this.path = path; this.path = path;


/** /**
* Add extra attributes to the {@code manifest} file. * Add extra attributes to the {@code manifest} file.
* As possible attribute name please see {@link ManifestPluginDescriptorFinder}.
*/
public Builder manifestAttributes(Map<String, String> manifestAttributes) {
this.manifestAttributes.putAll(manifestAttributes);

return this;
}

/**
* Add extra attribute to the {@code manifest} file.
* As possible attribute name please see {@link ManifestPluginDescriptorFinder}.
*/ */
public Builder attributes(Map<String, String> attributes) {
this.attributes = attributes;
public Builder manifestAttribute(String name, String value) {
manifestAttributes.put(name, value);


return this; return this;
} }
if (pluginClass != null) { if (pluginClass != null) {
map.put(ManifestPluginDescriptorFinder.PLUGIN_CLASS, pluginClass); map.put(ManifestPluginDescriptorFinder.PLUGIN_CLASS, pluginClass);
} }
if (attributes != null) {
map.putAll(attributes);
if (manifestAttributes != null) {
map.putAll(manifestAttributes);
} }


JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(path.toFile()), createManifest(map));
Manifest manifest = createManifest(map);
JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(path.toFile()), manifest);
outputStream.close(); outputStream.close();
} }



Notiek ielāde…
Atcelt
Saglabāt