我正在尝试为个人项目设置 Ant + Ivy 构建。在我到达 LWJGL 之前,一切都很有意义,并且运行良好。 LWJGL 的一切都已解决,除了本地人。
Readme.md在他们的网站上看起来似乎可以通过 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
我想要的文件肯定在maven central repository上,所以一定有办法让他们通过 Ivy 大学。我已经像这样设置了 ivy.xml 文件:
<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>
我在 ant 中的解析任务:
<target name="resolve" description="Retrive dependencies with Ivy">
<ivy:retrieve/>
</target>
出于某种原因,这会从“org.lwjgl:lwjgl:3.0.0a”下载所有工件(jar、javadoc 和源代码),但不会从“org.lwjgl:lwjgl-platform”下载任何 native :3.0.0a”。我在Google上花了很长时间,终于在Github上别人的ivy.xml文件中找到了“extra:classifier”语法,但没有成功(我的希望太早了)。肯定有什么东西我错过了,所以我希望 SO 上的人可以提供帮助。
最佳答案
Maven 模块中的额外工件必须在 ivy 依赖项声明中显式检索。
您还需要指定检索任务中使用的模式,因为“classifier”是 Maven 特定标记并且是可选的。
示例
├── 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>
关于ant - 使用 Ivy 下载 LWJGL native ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35052763/