Ivy:获取 Javadoc 和源代码 [英] Ivy: Fetching Javadocs and Sources

查看:25
本文介绍了Ivy:获取 Javadoc 和源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Ivy 还很陌生,但已经让它与 jar 依赖项一起工作.问题是尝试设置它,因此我可以独立于 jar 获取 javadoc 和源.

I'm fairly new to Ivy, but have gotten it to work with jar dependencies. The problem is trying to set it up, so I can fetch javadocs and sources independently of jars.

我有一个简单的测试项目,但无论我在做什么,我都会获取包含类文件的 jar.

I have a simple test project, but no matter what I'm doing, I'm fetching the jar with the class files in it.

我有以下 ivy.xml 文件:

<ivy-module version="1.0">
    <info
        organisation="com.vegicorp"
        module="test"
        revision="1.0"
        status="release"/>

    <configurations>
        <conf name="default" visibility="public" extends="runtime,master"/>
        <conf name="master" visibility="public"/>
        <conf name="compile" visibility="public"/>
        <conf name="provided" visibility="public"/>
        <conf name="runtime" visibility="public" extends="compile"/>
        <conf name="test" visibility="private" extends="runtime"/>
        <conf name="system" visibility="public"/>
        <conf name="sources" visibility="public"/>
        <conf name="javadoc" visibility="public"/>
        <conf name="optional" visibility="public"/>
    </configurations>

    <dependencies>
        <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
            conf="compile->default"/>
        <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
            conf="sources->default">
            <artifact name="commons-logging" type="sources" ext="jar"/>
        </dependency>
        <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
            conf="javadoc->default">
            <artifact name="commons-logging" type="javadoc" ext="jar"/>
        </dependency>
    </dependencies>
</ivy-module>

还有下面的build.xml:

<project name="ivy-test" default="default" basedir="."
    xmlns:ivy="http://ant.apache.org/ivy">

    <property name="ivy.dir" value="${basedir}/ivy.dir"/>
    <import file="${ivy.dir}/ivy.tasks.xml"/>

    <property name="target.dir" value="${basedir}/lib"/>
    <target name="-resolve">
        <ivy:resolve/>
    </target>

    <target name="clean">
        <delete dir="${target.dir}"/>
        <ivy:cleancache/>
    </target>

    <target name="default"
        depends="-resolve">

        <fail message="ivy.conf is not defined">
            <condition>
                <not>
                    <isset property="ivy.conf"/>
                </not>
            </condition>
        </fail>

        <delete dir="${target.dir}"/>
        <mkdir dir="${target.dir}"/>
        <ivy:retrieve conf="${ivy.conf}"
            pattern="${target.dir}/[artifact]-[revision].[ext]"/>
    </target>
</project>

在命令行,我会输入:

$ ant -Divy.conf=compile

而且,应该下载带有类的 jarfile.

And, that should download the jarfile with the classes.

但是如果我输入:

$ ant -Divy.conf=sources

我想要包含源代码而不是类的 jar 文件,当我输入时:

I want the jar file that contains the sources and not the classes, and when I type this:

$ ant -Divy.conf=javadoc

我想要包含 javadoc 而不是源代码的 jar 文件.

I want the jar file that contains the javadoc and not the sources.

我很确定是我的 ivy.xml 不太正确.我最初尝试过这个:

I'm pretty sure it's my ivy.xml that's not quite right. I originally tried this:

<dependencies>
    <dependency org="commons-logging" name="commons-logging" rev="1.1.1">
        <artifact name="commons-logging" type="jar" ext="jar" conf="compile->default"/>
        <artifact name="commons-logging" type="sources" ext="jar" conf="sources->default"/>
        <artifact name="commons-logging" type="javadoc" ext="jar" conf="javadoc->default"/>
    </dependency>

下载了 jar、源代码和 javadoc,但无论我尝试哪种配置,都一次性下载.

That downloaded the jar, the sources, and javadoc, but all at once no matter which configuration I tried.

推荐答案

好吧,我想我已经想通了.整个过程我都想多了.我的 部分应如下所示:

Okay, I think I've figured it out. I was over thinking this whole process. My <dependencies> section should look like this:

<dependencies>
    <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
        conf="javadoc->javadoc;sources->sources;compile->default"/>
</dependencies>

这将我的 javadoc 映射到 Maven 的 javadoc,将我的 sources 映射到 Maven 的 sources.当我映射 conf="sources->default" 时,它将我的 sources 映射到 Maven 的 default ,这是编译依赖项.

This maps my javadoc to Maven's javadoc and my sources to Maven's sources. When I mapped conf="sources->default", it was mapping my sources to Maven's default which is the compile dependencies.

我可以在一行中指定所有配置,并且不需要单独的 实体.

I can specify all the configurations in one line, and I don't need separate <artifact> entities.

这篇关于Ivy:获取 Javadoc 和源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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