1

我的常春藤依赖:

<dependency org="googlecode.com" name="jslint4java" rev="2.0.1" e:suffix="-src">
  <artifact name="jslint4java" type="zip"/>
</dependency>

我的常春藤设置:

<url name="googlecode">
  <artifact pattern="http://[module].[organization]/files/[artifact]-[revision][suffix].[ext]"/>
</url>

...

<module organisation="googlecode.com" resolver="googlecode"/>

当我尝试解决依赖关系时,出现以下错误:

[ivy:retrieve] == 解决依赖关系

...#blog;working@...->googlecode.com#jslint4java;2.0.2

[default->*] [ivy:retrieve] 试过

http://jslint4java.googlecode.com/files/jslint4java-2.0.2-dist.zip

[ivy:retrieve]客户端错误:未找到

url=http://jslint4java.googlecode.com/files/jslint4java-2.0.2-dist.zip

[ivy:retrieve] googlecode:找不到常春藤文件或工件

googlecode.com#jslint4java;2.0.2 [ivy:retrieve] 警告:找不到模块:googlecode.com#jslint4java;2.0.2 [ivy:retrieve] 警告:====

googlecode: 试过 [ivy:retrieve] WARN: -- artifact

googlecode.com#jslint4java;2.0.2!jslint4java.zip: [ivy:retrieve] 警告:

http://jslint4java.googlecode.com/files/jslint4java-2.0.2-dist.zip

我尝试通过使用最后一行中的 url 来 d/l 文件,wget并且它运行良好。

但我无法弄清楚为什么 ivy 无法 d/l 文件。

4

2 回答 2

1

因此,我使用 -d 标志运行了 ant 任务以检查更多信息,结果如下:

[ivy:resolve] HTTP response status: 404 url=http://jslint4java.googlecode.com/files/jslint4java-2.0.1-src.zip.sha1
[ivy:resolve] CLIENT ERROR: Not Found url=http://jslint4java.googlecode.com/files/jslint4java-2.0.1-src.zip.sha1
[ivy:resolve] HTTP response status: 404 url=http://jslint4java.googlecode.com/files/jslint4java-2.0.1-src.zip.md5
[ivy:resolve] CLIENT ERROR: Not Found url=http://jslint4java.googlecode.com/files/jslint4java-2.0.1-src.zip.md5

请注意 md5 不存在,您必须覆盖解析器中的校验和选项。

<url name="googlecode" checksums="sha1">

我只尝试了 sha1(默认为 sha1,md5)并且它工作,即使 sha1 也无法下载。

尝试在该领域进行实验。

于 2012-09-16T09:05:55.230 回答
0

我建议你在你的 ivy 文件中设置一个配置。

例子

运行构建后,存在以下文件:

|-- build.xml
|-- ivysettings.xml
|-- ivy.xml
`-- lib
    `-- jslint4java-2.0.1-src.zip

常春藤.xml

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="source"  description="source code distro"/>
    </configurations>

    <dependencies>
        <dependency org="googlecode.com" name="jslint4java" rev="2.0.1" e:suffix="src" conf="source->default">
            <artifact name="jslint4java" type="zip"/>
        </dependency>
    </dependencies>

</ivy-module>

笔记:

  • 添加了“源”配置。我的常春藤项目中的逻辑分组以区别于其他类型的依赖。
  • 请注意依赖项上的额外“conf”属性。映射到远程“默认”配置。除非远程模块有 ivy 或 POM 文件,否则默认是最安全的选项。
  • 修改了额外的属性“后缀”。删除了“-”字符。技术上没什么大不了的,我只是认为最好不要包含在依赖声明中。

常春藤设置.xml

<ivysettings>
  <settings defaultResolver="googlecode" />
  <resolvers>
    <url name="googlecode">
      <artifact pattern="http://[module].[organization]/files/[artifact]-[revision]-[suffix].[ext]"/>
    </url>
  </resolvers>
</ivysettings>

笔记:

构建.xml

<project name="demo" default="retrieve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="retrieve" description="Use ivy to retrieve artifacts">
        <ivy:retrieve pattern="lib/[artifact]-[revision](-[suffix]).[ext]" conf="source"/>
    </target>

    <target name="clean" description="Cleanup build files">
        <delete dir="lib"/>
    </target>

    <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
        <ivy:cleancache/>
    </target>

</project>

笔记:

  • 请注意“后缀”属性是如何括在括号中的。这是一个可选的额外参数,可能不是依赖项的一部分。
于 2012-09-16T14:53:30.393 回答