解决与蚂蚁和常春藤Javadoc文件 [英] resolving javadoc files with Ant and Ivy

查看:110
本文介绍了解决与蚂蚁和常春藤Javadoc文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想艾维获取两个log4j的.jar和的JavaDoc。现在,我在一个死胡同。当如果我在的ivy.xml使用...

I'd like Ivy to fetch both the log4j .jar and JavaDocs. Right now, I am at a dead end. When If I use this in my ivy.xml ...

<dependency org="log4j" name="log4j" rev="1.2.16"/>

...然后我刚才得到的.jar文件。但是使用这个ivysettings.xml时...

... then I just get the .jar file. But when using this ivysettings.xml ...

<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
    <settings  
            defaultResolver="default"
            defaultConflictManager="all" />
    <resolvers>
        <url name="default" m2compatible="true">
            <artifact pattern="http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
            <artifact pattern="http://repo2.maven.org/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
        </url>
    </resolvers>
</ivysettings>

...这...的ivy.xml

... and this ivy.xml ...

<?xml version="1.0" encoding="UTF-8"?>
<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="foo" module="bar"/>
    <dependencies>
        <dependency org="log4j" name="log4j" rev="1.2.16">
            <artifact name="log4j" type="jar" ext="jar"/>
            <artifact name="log4j" type="javadoc" ext="jar"/> 
        </dependency>
    </dependencies>
</ivy-module>

...然后我收到此错误信息:
了java.lang.RuntimeException:模块的log4j#的log4j的多个文物; 1.2.16检索到同一个文件!更新检索模式来解决这个错误。

我是缺少在这里?我怎样才能得到常春藤来解决双方的JavaDoc和.jar文件?

What I am missing here? How can I get Ivy to resolve both the JavaDoc and the .jar files?

编辑:
感谢所有迄今快,详尽的答复。这是我更新的ivy.xml:

edit: Thanks for all the fast and detailed responses so far. This is my updated ivy.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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="foo" module="bar"/>
    <configurations>
        <conf name="default" visibility="public"/>
        <conf name="compile" visibility="public"/>
        <conf name="master"  visibility="public"/>
        <conf name="javadoc" visibility="public"/>
    </configurations>

    <dependencies>
        <dependency org="log4j"             name="log4j"       rev="1.2.16" conf="default->master,javadoc"/>
        <dependency org="javax.servlet"     name="servlet-api" rev="2.5" />
        <dependency org="com.someother"     name="proprietary-core" rev="1.2.3" force="true"/>
        <dependency org="com.someother"     name="proprietary" rev="1.2.3" force="true"/>
        <dependency org="com.someother"     name="scanner"     rev="1.0"   force="true"/>
    </dependencies>
</ivy-module>

现在我收到此错误信息:

Now I get this error message:

Buildfile: D:\workspace\foobar\build.xml

resolve:
[ivy:retrieve] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: file = D:\workspace\foobar\ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: foo#bar;working@myhost
[ivy:retrieve]  confs: [default, compile, master, javadoc]
[ivy:retrieve]  found log4j#log4j;1.2.16 in internal
[ivy:retrieve]  found javax.servlet#servlet-api;2.5 in internal
[ivy:retrieve]  found com.someother#proprietary-core;1.2.3 in internal
[ivy:retrieve]  found com.someother#proprietary;1.2.3 in internal
[ivy:retrieve]  found com.someother#scanner;1.0 in internal
[ivy:retrieve] :: resolution report :: resolve 332ms :: artifacts dl 10ms
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |   5   |   0   |   0   |   0   ||   4   |   0   |
    |      compile     |   4   |   0   |   0   |   0   ||   4   |   0   |
    |      master      |   4   |   0   |   0   |   0   ||   4   |   0   |
    |      javadoc     |   4   |   0   |   0   |   0   ||   4   |   0   |
    ---------------------------------------------------------------------
[ivy:retrieve] 
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]      ::          UNRESOLVED DEPENDENCIES         ::
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]      :: log4j#log4j;1.2.16: configuration not found in log4j#log4j;1.2.16: 'master'. It was required from foo#bar;working@myhost default
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] 
[ivy:retrieve] 
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS

有似乎是使用Maven范围的问题。但究竟我在这里丢失?

There seems to be a problem with the Maven scopes. But what exactly am I missing here?

推荐答案

现在的问题是,你正在使用的常春藤检索任务模式。它需要包括可选的分类属性,以确保文件名是唯一的:

The problem is the pattern you are using in the ivy retrieve task. It needs to include the optional "classifier" attribute to ensure the file name is unique:

<ivy:retrieve pattern="lib/[conf]/[artifact](-[classifier]).[ext]"/>

分类器是一个Maven东西,被用于标识与一个Maven模块相关联的附加假象。

Classifier is a Maven thing, is used to identify additional artefacts associated with a Maven module.

无需复杂的设置,常春藤。该文物是从其他模块下载配置映射控制。

No need for complicated ivy settings. Configuration mappings control which artefacts are downloaded from other modules.

删除 ivysettings.xml 文件,并尝试在以下您的的ivy.xml

Remove the ivysettings.xml file and try the following in your ivy.xml:

<dependency org="log4j" name="log4j" rev="1.2.16" conf="default->master,javadoc"/>

这导致下列文件被下载:

This results in the following files being downloaded:


  • 的log4j-1.2.16.jar

  • 的log4j-1.2.16-javadoc.jar

它是如何工作的?

有关Maven的模块创建常春藤匹配每一个标准的Maven范围的配置:

For Maven modules ivy creates a configuration matching each of the standard Maven scopes:


  • 主:主罐只有

  • 编译:主缸,再加上用于编译瓶子(这也是默认范围内)

  • 运行时:主缸,罐以及用于编译,运行时间

  • 测试:主要罐子,罐子加上用于编译,运行,试验

和还为每个额外的人工制品(或分类)的模块发布的配置:

and additionally creates a configuration for each additional artefact (or classifier) published by the module:


  • 来源

  • 的javadoc

这使您可以混合和匹配。

This enables you to mix and match.

这篇关于解决与蚂蚁和常春藤Javadoc文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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