通过Maven插件注入依赖项 [英] Injecting a dependency via a maven plugin

查看:100
本文介绍了通过Maven插件注入依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个接受插件的系统,以使用户可以向管理系统添加功能.该插件基本上只是一个具有特定格式的zip文件(即,该目录中的文件x,该目录中的y).目前,我使用maven-assembly-plugin插件来制作zip.

I have a system that accepts plugins to let users add functionality to a management system. The plugin is basically just a zip file with in a certain format (ie file x in this dir, y in that dir). Currently I use the maven-assembly-plugin plugin to make the zip.

问题在于,使我所有的插件保持同步并让其他人创建插件很尴尬,因为他们需要正确的assembly.xml

The problem is that it is awkward to keep all my plugins in sync and to let others make a plugin since they need the correct assembly.xml

因此,我一直在尝试创建自定义包装类型,以便开发人员可以制作这样的插件:

Therefore I've been trying to make a custom packaging type so developers can make a plugin like this:

<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>plugin</packaging> //not a standard type

这通常可以正常工作,但现在的丑陋之处在于每个插件始终依赖于核心系统中的某些API.因此,它们基本上都具有相同的依赖性.

This is mostly working but the ugly thing now is that each plugin always depends on certain APIs in the core system. Therefore they all basically have the same dependencies.

mojo是否有可能将依赖项注入到mojo的用户中? http://maven.40175 .n5.nabble.com/How-to-inject-dependencies-from-a-mojo-td83025.html

推荐答案

已获得注释:

我遇到了一个非常明显而简单的解决方案.我做一个绒球" 包含依赖项的项目,并要求开发人员 包括该pom作为依赖项.这很好地解决了我的问题,因为我 可以将依赖关系集中在一个地方,并且每个插件"都可以 如果需要,可传递地获取核心api依赖项.简单 快点– mlathe 13年3月27日在22:12

I came across a pretty obvious and simple solution. I make a "pom" project that contains the dependencies, and ask that the developer includes that pom as a dependency. That solves my issue nicely since i can centralize the dependencies in one place and each "plugin" can transitively get to the core api dependencies if they want. Easy Peasy. – mlathe Mar 27 '13 at 22:12

这篇关于通过Maven插件注入依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆