sha*_*hay 5 java dependencies jar ivy
我需要帮助使用IVY作为依赖项管理器
我的应用程序需要在RUN-TIME加载插件
意味着在核心应用程序运行时,用户可以请求新的插件
并安装它们,
我希望管理所有已安装的插件使用核心应用程序DB.
我想从我的插件服务器(或其他描述符)获取一个pom,
并要求IVY告诉我什么是依赖项或让IVY根据我的应用程序的当前状态安装插件和依赖项.
(我现在有什么,
1.jar被核心应用程序
2.jar用于当前安装的插件)
我希望每个插件
在我的应用程序所在的某个文件夹下具有独立目录(不是共享目录)
事情是我不知道从哪里开始
我注意到没有编程API
我找到一个链接通过网络尝试类似的东西,
但看起来像代码没有完成,或一些变量丢失,我不知道如何完成其余的原因湖编程文档
http://www.mail-archive .com/ivy-user @ ant.apache.org/msg03228.html
(其中变量"art"来自......)
能帮帮我吗...谢谢大家
UPDATE
好吧,这就是我现在正在尝试的.我收到一些错误加上我不知道如何定义我的archiva服务器
IvySettings settings = new IvySettings();
settings.setDefaultIvyUserDir(new File("D:/programming/eclipse_projects/ivyTest/repo/"));
settings.setDefaultCache(new File("D:/programming/eclipse_projects/ivyTest/repo/cache/"));
settings.setDefaultCacheArtifactPattern("[module]/[revision]/[module]-[revision](-[classifier]");
Ivy ivy = Ivy.newInstance(settings);
ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_VERBOSE));
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), new File("src/movies.pom").toURL(), true);
RetrieveOptions retriveOptions = new RetrieveOptions();
retriveOptions.setUseOrigin(true);
retriveOptions.setConfs(md.getConfigurationsNames());
ivy.retrieve(md.getModuleRevisionId(), "lib/[conf]/[artifact].[ext]", etriveOptions);
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误
:: loading settings :: url = jar:file:/D:/programming/eclipse_projects/ivyTest/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: retrieving :: org.jtpc#movies
checkUpToDate=true
confs: [default, master, compile, provided, runtime, test, system, sources, javadoc, optional]
java.lang.RuntimeException: problem during retrieve of org.jtpc#movies: java.lang.IllegalStateException: Report file 'D:\programming\eclipse_projects\ivyTest\repo\cache\org.jtpc-movies-default.xml' does not exist.
at org.apache.ivy.core.retrieve.RetrieveEngine.retrieve(RetrieveEngine.java:206)
at org.apache.ivy.Ivy.retrieve(Ivy.java:540)
at Test.main(Test.java:52)
Caused by: java.lang.IllegalStateException: Report file 'D:\programming\eclipse_projects\ivyTest\repo\cache\org.jtpc-movies-default.xml' does not exist.
at org.apache.ivy.plugins.report.XmlReportParser.parse(XmlReportParser.java:294)
at org.apache.ivy.core.retrieve.RetrieveEngine.determineArtifactsToCopy(RetrieveEngine.java:288)
at org.apache.ivy.core.retrieve.RetrieveEngine.retrieve(RetrieveEngine.java:104)
... 2 more
Run Code Online (Sandbox Code Playgroud)
Ivy可以用作独立的 java程序:
java -jar ivy.jar -retrieve "lib/[conf]/[artifact].[ext]"
Run Code Online (Sandbox Code Playgroud)
的检索模式可以随后用于确定在何处文件安装的基础上,常春藤配置设置
$ find lib -type f
lib/core/commons-lang.jar
lib/plugin1/commons-logging.jar
lib/plugin1/commons-codec.jar
lib/plugin2/commons-logging.jar
lib/plugin2/commons-cli.jar
lib/plugin3/commons-logging.jar
Run Code Online (Sandbox Code Playgroud)
配置用作集合标签或依赖关系组.它们类似于Maven范围,但更灵活:
<ivy-module version="2.0">
<info organisation="com.myspotontheweb" module="demo"/>
<configurations>
<conf name="core" description="Core application dependencies"/>
<conf name="plugin1" description="Plugin 1 dependencies"/>
<conf name="plugin2" description="Plugin 2 dependencies"/>
<conf name="plugin3" description="Plugin 3 dependencies"/>
</configurations>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.5" conf="core->default"/>
<dependency org="commons-codec" name="commons-codec" rev="1.4" conf="plugin1->default"/>
<dependency org="commons-cli" name="commons-cli" rev="1.2" conf="plugin2->default"/>
<dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="plugin1,plugin2,plugin3->default"/>
</dependencies>
</ivy-module>
Run Code Online (Sandbox Code Playgroud)
如果您只想下载并安装一组jar,在指定的目录中可以使用confs参数:
java -jar ivy.jar -retrieve "plugin1/[artifact].[ext]" -confs plugin1
Run Code Online (Sandbox Code Playgroud)
最后,如果您仍想使用编程API,则可以调用主类调用的run方法
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/Main.java?view=markup
Groovy已经内置支持调用常春藤任务
import groovy.xml.NamespaceBuilder
def ant = new AntBuilder()
def ivy = NamespaceBuilder.newInstance(ant, 'antlib:org.apache.ivy.ant')
ivy.settings(file:"ivysettings.xml")
ivy.retrieve(pattern:"lib/[conf]/[artifact].[ext]")
ivy.report(toDir:'reports', graph:false)
Run Code Online (Sandbox Code Playgroud)
要设置本地Maven存储库的位置,您需要使用ivysettings.xml文件.
<ivysettings>
<settings defaultResolver='nexus' />
<resolvers>
<ibiblio name='nexus' root='http://myhost.mydomanin.com:8081/nexus' m2compatible='true' />
</resolvers>
</ivysettings>
Run Code Online (Sandbox Code Playgroud)
刚刚找到一篇文章,详细介绍了如何从Java调用Ivy
| 归档时间: |
|
| 查看次数: |
5300 次 |
| 最近记录: |