常春藤:使用分类器从maven安装

asm*_*ean 6 java jogl ivy maven

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

我的ivysettings是

<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>
Run Code Online (Sandbox Code Playgroud)

我的安装目标是

<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" />
Run Code Online (Sandbox Code Playgroud)

其中from.resolver central和to.resolver是depository.

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

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

Mar*_*nor 11

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

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

这个限制背后的起源

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

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

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

作为此元素的动机,请考虑一个项目,该项目提供针对JRE 1.5的工件,但同时也是一个仍支持JRE 1.4的工件.第一个工件可以配备分类器jdk15,第二个工件配备jdk14,以便客户端可以选择使用哪个.

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

常春藤存储库的工作方式不同.该模块的常春藤文件有一个发布部分,明确列出了模块的内容.

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

可能的解决方法

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

??? 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
Run Code Online (Sandbox Code Playgroud)

的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>
Run Code Online (Sandbox Code Playgroud)

笔记:

  • 需要明确列出要下载的每个所需工件.如上所述,只能假设"javadoc"和"sources"分类器.

build.xml文件

<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>
Run Code Online (Sandbox Code Playgroud)