开发者

Build webapp and its independent plugins with maven

I have a webapp, that I will call core, that can have plugins (not maven plugins) added to it, but it should run and build fine as a stand alone webapp. We have a plugin-lib that the core depends on and that all plugins developed to the core also depends on.开发者_如何转开发

Like this:

core    -> core-plugin-lib
plugins -> core-plugin-lib

My directory structure is simple:

root/
    core/
        pom.xml
    core-plugin-lib/
        pom.xml
    pluginA/
        pom.xml
    pluginB/
        pom.xml

My first problem is: can I build the core or any plugin and also build the dependent lib? I read about modules, but as you can see, the lib has 2 parents. What I would really want is to build core and also build the lib OR if I built any plugin, I would also like to build the lib independently. And mind also, that the core does not depend on any plugin.

The second problem is: how to build the core and also build the plugins, although the core does not depend on them, and the plugins should not be a module of the core. They could, it is not a requisite, but I'd rather not as I'd like to maintain as independent as possible.

As of now, when I build the plugin, it copies itself to a /plugin directory inside the core, and I have a distribution profile in the core pom to copy the existing plugins from this directory to inside the war of the webapp. So when I build the core with no profile, it does not copy its plugins, but when I run the distribution profile, yes. This works but it is tedious, as I have to build the lib, build the plugins and build core.

I would like to know if there is any pom structure that could solve the double dependency of my first problem, and if there is any way to handle the second problem and build the plugins through the core even though they are not dependent. And, if possible, if I could handle the second problem within a profile instead of a separate pom. This profile uses the maven-assembly-plugin to create a tar.gz with everything packed in it. I would also like to maintain that if possible.


I read about modules, but as you can see, the lib has 2 parents.

I think you mean that the lib has 2 projects that depend on it. A parent means something specific in Maven: A POM that is inherited by another. In this case, I think modules are what you are looking for.

As to whether you can build the lib with the core and the plugins, then yes, it's possible. Is it a good idea? I would say, no. The plugin lib defines a contract between the plugins and the core. Generally you want to know exactly which version you are depending on, and not necessarily the latest all the time. I would recommend you keep the version of the lib independent of the other projects, and build it as necessary. Then let your core and plugins depend on the version in the local (or remote) repository that you are targeting.

If you're determined to build them together, then simply define a separate, multi-module POM, perhaps next to the others, that includes both projects as modules.

Regarding the second question, you can certainly define a separate POM that builds both the core and the plugins together. Use the same multi-module technique.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜