Downloading LWJGL natives with Ivy

2019-07-20 15:33发布

I'm trying to set up an Ant + Ivy build for a personal project. Everything was making sense, and working nicely, until I got to LWJGL. Everything from LWJGL is resolved, except the natives.

The Readme.md on their website makes it seem that it is possible to get these through Ivy:

LWJGL 3 can be used with Maven/Gradle/Ivy, with the following dependencies:

  • org.lwjgl:lwjgl:${version}
  • org.lwjgl:lwjgl-platform:${version}:natives-windows
  • org.lwjgl:lwjgl-platform:${version}:natives-linux
  • org.lwjgl:lwjgl-platform:${version}:natives-osx

The files I want are definitely on the maven central repository, so there must be a way of getting them through Ivy. I have set up my ivy.xml file like so:

<ivy-module version="1.0" xmlns:extra="http://ant.apache.org/ivy/extra">
    <info organisation="foo" module="bar"/>
    <publications>
        <artifact name="baz" type="jar"/>
    </publications>
    <dependencies>
        <dependency org="org.lwjgl" name="lwjgl" rev="3.0.0a"/>
        <dependency org="org.lwjgl" name="lwjgl-platform" rev="3.0.0a" extra:classifier="natives-linux"/>
        <dependency org="org.lwjgl" name="lwjgl-platform" rev="3.0.0a" extra:classifier="natives-osx"/>
        <dependency org="org.lwjgl" name="lwjgl-platform" rev="3.0.0a" extra:classifier="natives-windows"/>
    </dependencies>
</ivy-module>

And my resolve task in ant:

<target name="resolve" description="Retrive dependencies with Ivy">
    <ivy:retrieve/>
</target>

For some reason, this downloads all the artifacts from "org.lwjgl:lwjgl:3.0.0a" (jar, javadoc, and sources), but does not download any of the natives from "org.lwjgl:lwjgl-platform:3.0.0a". I spent a long time on Google, and finally managed to find the "extra:classifier" syntax in someone else's ivy.xml file on Github, but to no avail (I got my hopes up too early). There must be something I'm missing, so I hope someone on SO can help.

1条回答
霸刀☆藐视天下
2楼-- · 2019-07-20 16:10

Extra artifacts in Maven modules must be explicitly retrieved in the ivy dependency declaration.

You'll also need to specify the pattern used in the retrieve task, because "classifier" is a Maven specific tag and optional.

Example

├── build.xml
├── ivy.xml
└── target
    └── lib
        ├── lwjgl-3.0.0a.jar
        ├── lwjgl-platform-3.0.0a-natives-linux.jar
        ├── lwjgl-platform-3.0.0a-natives-osx.jar
        └── lwjgl-platform-3.0.0a-natives-windows.jar

build.xml

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

    <property name="build.dir" location="target"/>

    <target name="resolve">
        <ivy:retrieve pattern="${build.dir}/lib/[artifact]-[revision](-[classifier]).[ext]"/>
    </target>

</project>

ivy.xml

<ivy-module version="1.0" xmlns:extra="http://ant.apache.org/ivy/extra">
  <info organisation="foo" module="bar"/>
  <dependencies>
    <dependency org="org.lwjgl" name="lwjgl" rev="3.0.0a" conf="default"/>

    <dependency org="org.lwjgl" name="lwjgl-platform" rev="3.0.0a">
      <artifact name="lwjgl-platform" type="jar" extra:classifier="natives-linux"/>
      <artifact name="lwjgl-platform" type="jar" extra:classifier="natives-osx"/>
      <artifact name="lwjgl-platform" type="jar" extra:classifier="natives-windows"/>
    </dependency>
  </dependencies>
</ivy-module>
查看更多
登录 后发表回答