如何将自定义jar发布到本地Apache Ivy存储库 [英] How to publish custom jars to local Apache Ivy repository

查看:114
本文介绍了如何将自定义jar发布到本地Apache Ivy存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经阅读了所有教程和示例,但仍然无法在本地Ivy存储库中发布一组自定义jar.
基本上,我想要与maven-install-plugin相同的行为.
这是我的设置.我有一个Ant任务,可以在给定的文件夹中生成罐子.文件夹名称不是固定的,而是作为文件中的属性传递的.我想将所有jar放在此文件夹中,然后将它们安装在我的本地Ivy存储库中,以便我可以在下一步中使用它们.
这是我叫常春藤的蚂蚁:发布:


I've read all the tutorials and examples, and still cannot publish a set of custom jars in my local Ivy repository.
Basically I want the same behavior as maven-install-plugin.
Here's my setup. I have an Ant task which produces the jars in a given folder. The folder name is not fixed but rather passed as a property in file. I want to get all the jars in this folder and install them in my local Ivy repo so that I can use them on a next step.
Here is my Ant from where I call the ivy:publish:

<project name="Install Ivy Dependencies" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." default="publish">

    <loadproperties srcFile="path_to_folder.properties"/>

 <property name="file_pattern" value="${path_to_folder}/[artifact].[ext]" />
 <property name="pub_revision" value="1.0.0" />

   <target name="resolve">
        <ivy:configure file="ivysettings.xml" />
        <ivy:resolve file="ivy.xml" />
  </target>

 <target name="retrieve-all" depends="resolve">
        <ivy:retrieve pattern="${file_pattern}" conf="*" />
 </target>

 <target name="publish"  depends="retrieve-all">
        <ivy:publish resolver="local" organisation="myOrg" update="true" overwrite="true" pubrevision="${pub_revision}">
           <artifacts pattern="${file_pattern}"/>
        </ivy:publish>
 </target>
</project>


这是我的ivysettings.xml:


Here's my ivysettings.xml:

<ivysettings>
  <resolvers>
      <filesystem name="local" local="true"/>
    </resolvers>
</ivysettings>


和ivy.xml:


And the ivy.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

  <info organisation="myOrg" module="myModule" revision="1.0.0"/>
  <publications>
    <artifact name="my-custom-jar" ext="jar" type="jar"/>
    <artifact name="my-custom-jar-source" ext="jar" type="source"/>
  </publications>
</ivy-module>

调用ant任务时遇到的错误是:
无法发布myOrg#myModule; 1.0.0的工件:java.lang.IllegalStateException:不可能使用本地发布myOrg#myModule; 1.0.0!my-custom-jar.jar :未定义工件模式

The error that I am getting when I call the ant task is:
impossible to publish artifacts for myOrg#myModule;1.0.0: java.lang.IllegalStateException: impossible to publish myOrg#myModule;1.0.0!my-custom-jar.jar using local: no artifact pattern defined

推荐答案

我已经设法运行我的方案并使用此

I've managed to run my scenario and to resolve my issues using this tutorial There were two major issues in my code/integration.
First one is that you cannot tell Ivy to publish the artifacts in its repository without providing a path to it. I did this with the filesystem resolver:

<filesystem name="local" local="true" transactional="local">
      <ivy pattern="${ivy.default.ivy.user.dir}/local/[module]/ivy-[revision].xml" />
      <artifact pattern="${ivy.default.ivy.user.dir}/local/[module]/[artifact]-[revision].[ext]" />
</filesystem>

愚蠢的想法是应该将其内置.如果您照原样复制它,则一切正常.如果配置不同,或指向其他位置,则没有任何效果,并且不会告诉您原因.我阅读了大量有关Apache Ivy的文档,但没有人提到这些模式应指向本地Ivy存储库.我认为这些是应该从罐子中取出的路径.我实际上对此有所抱怨,但是常春藤文档非常令人困惑.另外,我认为示例是错误的.谁想要在其ivy.settings.dir中发布这些工件.就我而言,该目录在我的存储库中!

The stupid think about it is this should be build in. If you copy it as is, then everything works. If the config is different, or pointing to a different location - nothing works and you are not told why. I read tons of docs about Apache Ivy and it was nowhere mentioned that these patterns should point to the local Ivy repository. I thought these were the paths from where the jars should be taken. I actually complained about this, but the Ivy documentation is very confusing. Also I think the examples there are wrong. Who would like to publish the artifacts in their ivy.settings.dir. In my case this directory was in my repository!

还有第二个问题.它很小,很难看和修复.版本参数出了点问题,文档又被弄乱了.如果为修订版和发布修订版指定一个相同的字符串,则不会发布任何解释,而不会解释原因.我通过从ivy.xml文件中删除修订来修复它.

There was a second issue. It is a smaller one and again very hard to see and fix. There's something wrong the revision param and again the documentation is messed up. If you specify one and the same string for the revision and pub revision the artifacts aren't publish without any explanation why. I fixed it by removing the revision from ivy.xml file.

最后但并非最不重要的一点是,我没有成功地将事物"作为Ant任务运行,但是使用了java -jar $ IVY_JAR ...也许是由于版本问题,但是我太累了,以至于尝试修复. P.S. @ cantSleepNow感谢您的帮助.

Last, but not least, I didn't manage to run successfully the "thing" as Ant task, but with java -jar $IVY_JAR ... Maybe the issue was because of the versions, but I was too tired to try it with the fix. P.S.@cantSleepNow thanks for the help.

这篇关于如何将自定义jar发布到本地Apache Ivy存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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