常春藤:使用分类器从maven安装 [英] ivy:install from maven with classifiers

查看:197
本文介绍了常春藤:使用分类器从maven安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试常春藤:将maven的jogl和gluegen安装到我当地的存放处。我无法正确安装本机依赖项。

I'm trying to ivy:install jogl and gluegen from maven to my local depository. I cannot get the native dependencies to install correctly.

我的ivysettings是

My ivysettings is

<ivysettings>
    <settings defaultResolver="central"
            defaultConflictManager="all"
    />
    <caches defaultCacheDir="${ivy.cache.dir}"
            artifactPattern="[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]" 
    />
    <resolvers>
        <ibiblio name="central" m2compatible="true"
                 pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
        />
        <filesystem name="depository">
            <ivy pattern="${dest.repo.dir}/[organisation]/[module]/ivys/ivy-[revision](-[classifier]).xml" />
            <artifact pattern="${dest.repo.dir}/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]" />
        </filesystem>
    </resolvers>
</ivysettings>

我的安装目标是

<ivy:install settingsRef="ivy.settings" 
    organisation="org.jogamp.jogl" module="jogl-all-main" revision="2.1.5-01"
    from="${from.resolver}" to="${to.resolver}" transitive="true" overwrite="true" />

其中from.resolver central 和.resolver depository

where from.resolver is central and to.resolver is depository.

分类器例如是native-windows-i586,native-linux-armv6,有问题的pom文件位于 http://repo1.maven.org/maven2/org/jogamp/jogl/jogl-all-main/2.1.5-01/jogl-all-main-2.1.5-01 .pom

The classifiers are e.g., native-windows-i586, native-linux-armv6, etc. The pom file in question is at http://repo1.maven.org/maven2/org/jogamp/jogl/jogl-all-main/2.1.5-01/jogl-all-main-2.1.5-01.pom

我正确解决了jogl-all-main问题。解析依赖关系后,只解析pom文件中的最后一个,即jogl-all-2.1.5-01-natives-windows-i586.jar。有没有办法使用常春藤:安装任务从maven中央存储库安装到我的本地存储区?

I correctly resolve jogl-all-main. When the dependencies are resolved, only the last one in the pom file is resolved, namely jogl-all-2.1.5-01-natives-windows-i586.jar. Is there any way to use the ivy:install task to install to my local depository from the maven central repository?

推荐答案

简短答案是,ivy对与Maven模块相关的其他工件文件的支持非常有限。

The short answer is that ivy has very limited support for additional artifact files associated with a Maven module.

我为重复自己而道歉,但最好建议您运行Maven存储库管理器来缓存远程Maven存储库。这避免了在不同格式之间进行折衷的必要性。

I apologise for repeating myself, but you are best advised to run a Maven repository manager to cache remote Maven repositories. This avoids the necessity to compromise between differing formats.

远程Maven POM未明确列出其模块的工件。可能的分类器值的数量没有限制....可以做出的唯一假设是模块可能包含额外的javadoc或sources工件。 (在开源项目中很常见)。

A remote Maven POM does not explicitly list its module's artifacts. There is no limit on the number of possible classifier values.... The only assumption that can be made is that the module might contain an additional "javadoc" or "sources" artifact. (Common in open source projects).

Maven文档描述了如下分类器:


分类器:分类器允许区分工件这是从同一个POM构建的
,但内容不同。它是一些
可选和任意字符串 - 如果存在 - 被附加到版本号后面的
工件名称。

classifier: The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.

作为动机对于这个元素,考虑一个项目,例如
提供了一个针对JRE 1.5的工件,但同时也是一个仍然支持JRE 1.4的
工件。第一个神器可能是
配备分类器jdk15,第二个神器可以是jdk14,如
,客户可以选择使用哪一个。

As a motivation for this element, consider for example a project that offers an artifact targeting JRE 1.5 but at the same time also an artifact that still supports JRE 1.4. The first artifact could be equipped with the classifier jdk15 and the second one with jdk14 such that clients can choose which one to use.

另一个分类器的常见用例是需要将
辅助工件附加到项目的主工件。如果您浏览
Maven中央存储库,您会注意到分类器源
和javadoc用于部署项目源代码和API文档
以及打包的类文件。

Another common use case for classifiers is the need to attach secondary artifacts to the project’s main artifact. If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files.

常春藤存储库的工作方式不同。该模块的常春藤文件有一个明确的出版物部分列出模块的内容。

Ivy repositories work differently. The module's ivy file has a publications section that explicitly lists the module's contents.

为了更深入地了解常春藤如何解释Maven存储库,我建议以下发布。

For a greater insight into how ivy interprets Maven repositories I would recommend the following posting.

  • How are maven scopes mapped to ivy configurations by ivy

以下示例使用检索将下载的依赖项写入所需的存储库格式的任务。结果是缺少校验和文件,但这可能无关紧要。

The following example uses the retrieve task to write out the downloaded dependencies into the desired repository format. The result is missing checksum files, but that may not matter.

├── build.xml
├── ivy.xml
└── target
    └── repo
        └── org
            └── jogamp
                └── jogl
                    ├── jogl-all
                    │   └── 2.1.5-01
                    │       ├── jogl-all-2.1.5-01.jar
                    │       ├── jogl-all-2.1.5-01-javadoc.jar
                    │       ├── jogl-all-2.1.5-01-natives-android-armv6.jar
                    │       ├── jogl-all-2.1.5-01-natives-linux-amd64.jar
                    │       ├── jogl-all-2.1.5-01-natives-linux-armv6hf.jar
                    │       ├── jogl-all-2.1.5-01-natives-linux-armv6.jar
                    │       ├── jogl-all-2.1.5-01-natives-linux-i586.jar
                    │       ├── jogl-all-2.1.5-01-natives-macosx-universal.jar
                    │       ├── jogl-all-2.1.5-01-natives-solaris-amd64.jar
                    │       ├── jogl-all-2.1.5-01-natives-solaris-i586.jar
                    │       ├── jogl-all-2.1.5-01-natives-windows-amd64.jar
                    │       ├── jogl-all-2.1.5-01-natives-windows-i586.jar
                    │       └── jogl-all-2.1.5-01-sources.jar
                    └── jogl-all-main
                        └── 2.1.5-01
                            ├── jogl-all-main-2.1.5-01.jar
                            ├── jogl-all-main-2.1.5-01-javadoc.jar
                            └── jogl-all-main-2.1.5-01-sources.jar



ivy.xml



ivy.xml

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

    <configurations>
        <conf name="repo" description="Artifacts that make up local repository"/>
    </configurations>

    <dependencies>
        <dependency org="org.jogamp.jogl" name="jogl-all-main" rev="2.1.5-01" conf="repo->default">
            <artifact name="jogl-all-main"/>
            <artifact name="jogl-all-main" e:classifier="sources"/>
            <artifact name="jogl-all-main" e:classifier="javadoc"/>
        </dependency>

        <dependency org="org.jogamp.jogl" name="jogl-all" rev="2.1.5-01" conf="repo->default">
            <artifact name="jogl-all"/>
            <artifact name="jogl-all" e:classifier="sources"/>
            <artifact name="jogl-all" e:classifier="javadoc"/>
            <artifact name="jogl-all" e:classifier="natives-android-armv6"/>
            <artifact name="jogl-all" e:classifier="natives-linux-amd64"/>
            <artifact name="jogl-all" e:classifier="natives-linux-armv6"/>
            <artifact name="jogl-all" e:classifier="natives-linux-armv6hf"/>
            <artifact name="jogl-all" e:classifier="natives-linux-i586"/>
            <artifact name="jogl-all" e:classifier="natives-macosx-universal"/>
            <artifact name="jogl-all" e:classifier="natives-solaris-amd64"/>
            <artifact name="jogl-all" e:classifier="natives-solaris-i586"/>
            <artifact name="jogl-all" e:classifier="natives-windows-amd64"/>
            <artifact name="jogl-all" e:classifier="natives-windows-i586"/>
        </dependency>
    </dependencies>

</ivy-module>

注意:


  • 需要明确列出要下载的每个所需工件。如上所述,只能假定javadoc和sources分类符。

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

    <!--
    ================
    Build properties
    ================
    -->
    <property name="repo.dir" location="target"/>

    <!--
    ===========
    Build repo
    ===========
    -->
    <target name="install" description="Download and install dependencies">
        <ivy:retrieve pattern="${repo.dir}/[conf]/[orgPath]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
    </target>

</project>

这篇关于常春藤:使用分类器从maven安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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