[英]How to use Ivy to get artifacts other than JARs?
There is a Java library I want to use as part of my build, but it contains an external resources/
directory that has to be visible to the runtime classpath in order to work. 我想将一个Java库用作构建的一部分,但它包含一个外部resources/
目录,必须对运行时类路径可见才能工作。 I'd like to be able to store it as an artifact inside my Ivy repository, but not sure if Ivy can handle this, and if so, how to rig-up the ivy.xml
, ivy-settings.xml
files, as well as the repo itself. 我希望能够将它作为一个工件存储在我的Ivy存储库中,但不确定Ivy是否可以处理这个问题,如果是的话,如何安装ivy.xml
, ivy-settings.xml
文件,以及作为回购本身。
My repo is actually an Artifactory server and I store artifacts and their ivy files right next to each other: 我的repo实际上是一个Artifactory服务器,我将工件和它们的常春藤文件存储在彼此旁边:
http://myrepo.com:8080/artifactory/simple/myrepo/
google/
guice/
3.0/
guice-3.0.jar
ivy.xml
Etc. I guess I'm looking for a similar setup here: 等等我猜我在这里寻找类似的设置:
http://myrepo.com:8080/artifactory/simple/myrepo/
fizz/
buzz/
1.7/
buzz-1.7.jar
resources/
ivy.xml
...and somehow pull down both the jar and its resources/
directory as part of the Ivy resolve/retrieve pattern, and then place resources/
where I need it to be from there. ...并以某种方式将jar及其resources/
目录下拉为常春藤解析/检索模式的一部分,然后将resources/
放置在需要它的位置。
Is this possible? 这可能吗? Any ideas? 有任何想法吗? Thanks in advance! 提前致谢!
Edit - If the fact that resources/
is a directory causes a problem, I don't mind zipping it up as resources.zip
, and then resolving/retrieving it into my project at buildtime, and then unzipping it. 编辑 - 如果resources/
是一个目录导致问题,我不介意将其压缩为resources.zip
,然后在构建时将其解析/检索到我的项目中,然后解压缩它。 That's just more work to do, if Ivy can't handle directory-artifacts out of the box. 如果Ivy无法处理开箱即用的目录工件,那还有更多工作要做。
You should zip/tar the directory and create the following setup: 您应该zip / tar目录并创建以下设置:
http://myrepo.com:8080/artifactory/simple/myrepo/
fizz/
buzz/
1.7/
buzz-1.7.jar
resources-1.7.zip
ivy-1.7.xml
In your ivy.xml you would then declare each file as a publication of this module like this: 在您的ivy.xml中,您将每个文件声明为此模块的发布,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info organisation="fizz"
module="buzz"
revision="1.7"
status="release"
publication="20110531150115"
default="true"
/>
<configurations>
<conf name="default" visibility="public"/>
</configurations>
<publications>
<artifact name="buzz" type="jar" />
<artifact name="resources" type="zip" />
</publications>
</ivy-module>
And if needed you could define separate configurations like: 如果需要,您可以定义单独的配置,例如:
<configurations>
<conf name="default" extends="jar, resources" visibility="public"/>
<conf name="jar" visibility="public"/>
<conf name="resources" visibility="public"/>
</configurations>
<publications>
<artifact name="buzz" type="jar" conf="jar"/>
<artifact name="resources" type="zip" conf="resources"/>
</publications>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.