-
-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin manifest issues #70
Comments
Could be a bigger change for pf4j ... So in the meantime I worked around it by implementing PluginDescriptorFinder and overwriting PluginDescriptor. The custom PluginDescriptorFinder reads my prefixed manifest entries/properties and uses a custom PluginDescriptor which ignores all the setters and use the constructor for setting the values instead. It's far away from beautiful, but works. |
We can add a new method in each class. |
improve PluginDescriptorFinder implementations (see #70)
As explained in another issue/post, I create my plugins not as ZIP but as a single jar containing all dependencies.
For that I use the following build-plugin with maven:
Works quite well. Now I wanted to have the plugin-properties not in pom.xml
but in an external plugin.properties file (makes life easier when using development-runtimemode). To not need to define plugin-properties twice (pom + properties), I used the following maven-build-plugin to read it from properties-file and use it in pom:
Works in principle, but creates an name-conflict... It tooks me 2hrs to find the root-cause:
The pom variable ${plugin.id} is not only used by pf4j/it's plugin-configuration, but also by the maven assembly plugin... BUT: This only get's visible when reading the properties from properties-file. As long as you define the properties directly in pom.xml, ${plugin.id} will have the value we defined by outselves, don't matter where in the pom-file you use it.
If the property is read from propert-file (not direclty defined in pom), ${plugin.id} will contain the plugin-id of the build-plugin you're currenty configuring. In this case, it is "org.apache.maven.plugins:maven-assembly-plugin:2.5.5".
And it's getting further:
With ${plugin.class} you get an exception when running maven build:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (make-plugin-assembly) on project logicplugin: A type incompatibility occured while executing org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single: java.lang.Class cannot be cast to java.lang.String
So ${plugin.class} at this point is not containing the plugin-class-string, but the plugin class object...
Maybe this is a kind of special case, as most users will not do that "advanced stuff" that I do.
But I recommend anyway to not use conflicting names.
Maybe prefix all the plugin-property-names with "pf4j." ....
I tried to overcome this issue with having my own manifestPluginDescriptorFinder... But again, some "private" tags prevent me from doing this... :-(
The ManifestPluginDescriptorFinder itself can be overwritten, but it depends on the Plugindescriptor, which has the "setXYZ()" methods package-private :-(
I would overcome also this by overwriting it and having a large constructor instead of using all the package-private setter... But this would be more a hack than "good code".
So, finally, two things should change:
br,
Alex
The text was updated successfully, but these errors were encountered: