【问题标题】:ivy cannot d/l file but wget canivy 不能 d/l 文件,但 wget 可以
【发布时间】:2012-09-08 07:13:51
【问题描述】:

我的常春藤依赖:

<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:找不到 ivy 文件或工件

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

我尝试通过使用wget 的最后一行中的 url 来 d/l 文件,并且进展顺利。

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

【问题讨论】:

    标签: ant build ivy


    【解决方案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 也无法下载。

    尝试在该领域进行实验。

    【讨论】:

    • hmmm...为什么我没有注意到 ivy 正在尝试删除摘要。我会再次检查。谢谢:)
    【解决方案2】:

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

    示例

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

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

    ivy.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 文件,否则默认是最安全的选项。
    • 修改了额外的属性“suffix”。删除了“-”字符。技术上没什么大不了的,我只是觉得最好不要包含在依赖声明中。

    ivysettings.xml

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

    注意事项:

    build.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>
    

    注意事项:

    • 注意“后缀”属性是如何括在括号中的。这是一个可选的额外参数,可能不是依赖项的一部分。

    【讨论】:

      猜你喜欢
      • 2017-10-02
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 2019-01-07
      • 2017-04-02
      相关资源
      最近更新 更多