【问题标题】:Artifactory+Ivy missing artifact org.apacheArtifactory+Ivy 缺少神器 org.apache
【发布时间】:2014-05-11 23:25:21
【问题描述】:

我在我的项目中使用Ant+Ivy+Artifactory,我尝试发布自己的仓库,我的build.xml是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<project name="hello-world-ant" basedir="." default="main" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Ant properties -->
<property name="src.dir"     value="src"/>
<property name="lib.dir"     value="lib"/>
<property name="build.dir"   value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir"     value="${build.dir}/jar"/>
<property name="main-class"  value="com.eureka.HelloWorld"/>

<ivy:settings file="./ivysettings.xml" />

<target name="clean">
  <delete dir="${build.dir}"/>
  <delete dir="${lib.dir}"/>
</target>

<target name="resolve">
  <ivy:retrieve/>
</target>    

<target name="report" depends="resolve">
  <ivy:report todir="${build.dir}"/>
</target>

<target name="compile" depends="report">
  <mkdir dir="${classes.dir}"/>
  <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
</target>

<target name="jar" depends="compile">
  <mkdir dir="${jar.dir}"/>
  <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
    <manifest>
      <attribute name="Main-Class" value="${main-class}"/>
    </manifest>
  </jar>
</target>

<target name="run" depends="jar">
  <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
</target>

<target name="ivy">
      <ivy:resolve />

      <!-- Possible ivy:report, ivy:retrieve and other
      elements for managing your dependencies go here -->

      <ivy:deliver conf="*(public)"/> 
  </target>

   <target name="publish" depends="jar">
    <ivy:retrieve/>
      <ivy:publish resolver="publish" overwrite="true"    artifactspattern="${jar.dir}/[artifact].[ext]" />
    </target>

  <target name="clean-build" depends="clean,jar"/>

  <target name="main" depends="clean,run"/>

</project>

而我的 ivysettings.xml 是这样的:

<credentials host="localhost" realm="Artifactory Realm" username="admin" passwd="password" />

<resolvers>
<chain name="main">
  <ibiblio name="artifactory" m2compatible="true" root="http://localhost:8081/artifactory/libs-releases" />
  <url name="publish">
    <!-- You can use  m2compatible="true" instead of specifying your own pattern -->
    <ivy pattern="http://localhost:8081/artifactory/test-snapshot-local/[organization]/[module]/[revision]/ivy-[revision].xml" />
    <artifact pattern="http://localhost:8081/artifactory/test-snapshot-local/[organization]/[module]/[revision]/[artifact].[ext]"/>
  </url>
</chain>

当我做ant 时没有问题,但当我做ant publish 时它显示问题:

BUILD FAILED
/Users/stage/Documents/workspace/test_ivy/build.xml:56: impossible to publish artifacts for org.apache#hello-ivy;working@pro-de-support.density.fr: java.io.IOException: missing artifact org.apache#hello-ivy;20140401102841!hello-ivy.jar

我是使用这些工具的新手,我想知道这里发生了什么...非常感谢~

【问题讨论】:

    标签: xml ant ivy artifactory


    【解决方案1】:

    假设您使用的是 Ivy 快速入门教程中提到的 hello-ivy 示例,ivy.xml 中定义的模块是 hello-ivy 而项目名称是您正在使用 hello-world-ant
    用于发布的artifactspattern${jar.dir}/[artifact].[ext],这意味着Ivy 将在您的构建创建一个名为hello-world-ant.jar (${ant.project.name}.jar) 的jar 时查找hello-ivy.jar
    ivy.xml 中的模块更改为“hello-world-ant”将解决此问题。

    【讨论】:

    • 这正是我所需要的。感谢您提供宝贵的解决方案。
    猜你喜欢
    • 2016-12-23
    • 1970-01-01
    • 2020-02-13
    • 2013-08-18
    • 2012-03-12
    • 2014-02-26
    • 1970-01-01
    • 2017-04-07
    • 2012-02-29
    相关资源
    最近更新 更多