From 49bd1f59964355ced04f97079d1349227b0f69f3 Mon Sep 17 00:00:00 2001 From: COLLIGNON Thomas Date: Thu, 6 Jul 2017 10:40:24 +0200 Subject: [PATCH] =?UTF-8?q?Refactor=20ManifestPluginDescriptorFinder=20to?= =?UTF-8?q?=20allow=20custom=20managing=20of=20V=E2=80=A6=20(#154)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pf4j/ManifestPluginDescriptorFinder.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java index de0f84e..394773c 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java @@ -58,7 +58,7 @@ public abstract class ManifestPluginDescriptorFinder implements PluginDescriptor String version = attributes.getValue("Plugin-Version"); if (StringUtils.isNotEmpty(version)) { - pluginDescriptor.setPluginVersion(Version.valueOf(version)); + pluginDescriptor.setPluginVersion(createPluginVersion(version)); } String provider = attributes.getValue("Plugin-Provider"); @@ -76,6 +76,17 @@ public abstract class ManifestPluginDescriptorFinder implements PluginDescriptor return pluginDescriptor; } + /** + * Parse version to semver {@link Version} object. + * Example : 1.1.1.RC1 -> 1.1.1-RC1. + * This may be override to use a custom parsing to semver Version. + * @param version given string to be the plugin version + * @return a semver version + */ + protected Version createPluginVersion(String version) { + return Version.valueOf(version); + } + protected PluginDescriptor createPluginDescriptorInstance() { return new PluginDescriptor(); }