3

我正在尝试基于分类器从 Ivy 存储库(在 Artifactory 中)检索 Gradle 依赖项(以过滤包含本机代码的 DLL 以获取相关处理器架构的那些)。我的 build.gradle 看起来像这样:

repositories {
   ivy {
      name 'prebuilts'
      url "${repositoryServer}/prebuilts"
      credentials {
         username artifactoryUser
         password artifactoryPassword
      }
      layout 'pattern', {
         artifact '[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]'
         ivy '[organisation]/[module]/[revision]/ivy-[revision].xml'
      }
   }
}

configurations {
    example
}

dependencies {
    example group: 'ThirdParty', name: 'jogl_JSR-231', version: '1.1.0.1', configuration: 'nativeRuntime', classifier: 'release_win32'
}

project.configurations.example.each {
    println it
}

该依赖项的 ivy.xml 如下所示:

     <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     <ivy-module version="2.0">
     <info organisation="ThirdParty" module="jogl_JSR-231" revision="1.1.0.1" status="release" publication="20130508143052"/>
     <configurations>
         <conf name="nativeRuntime" description="Native artifacts for running tests." visibility="public"/>
         <conf name="archives" description="Configuration for archive artifacts." visibility="public"/>
         <conf name="default" extends="runtime" description="Configuration for default artifacts." visibility="public"/>
         <conf name="compile" description="Classpath for compiling the main sources." visibility="private"/>
         <conf name="runtime" extends="compile" description="Classpath for running the compiled main classes." visibility="private"/>
         <conf name="testCompile" extends="compile" description="Classpath for compiling the test sources." visibility="private"/>
         <conf name="testRuntime" extends="runtime,testCompile" description="Classpath for running the compiled test classes." visibility="private"/>
         <conf name="cppCompile" description="Configuration for API artifacts (headers)." visibility="public"/>
         <conf name="nativeArchives" description="Configuration for native archive artifacts." visibility="public"/>
     </configurations>
     <publications>
         <artifact name="gluegen-rt" type="jar" ext="jar" conf="archives,runtime"/>
         <artifact name="jogl" type="jar" ext="jar" conf="archives,runtime"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="gluegen-rt" type="jar" ext="jar" conf="archives" m:classifier="sources"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl" type="jar" ext="jar" conf="archives" m:classifier="sources"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="gluegen-rt" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_win32"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_win32"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl_awt" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_win32"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl_cg" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_win32"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="gluegen-rt" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_x64"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_x64"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl_awt" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_x64"/>
         <artifact xmlns:m="http://ant.apache.org/ant/maven" name="jogl_cg" type="dll" ext="dll" conf="nativeArchives,nativeRuntime" m:classifier="release_x64"/>
         <artifact name="joglBuildRecord" type="txt" ext="txt" conf="archives"/>
     </publications>
     <dependencies/>
     </ivy-module>

我收到以下错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\tmp\gradle-scratch\dependencies-by-classifier\build.gradle' line: 25

* What went wrong:
A problem occurred evaluating root project 'dependencies-by-classifier'.
> Could not resolve all dependencies for configuration ':example'.
   > Artifact 'ThirdParty:jogl_JSR-231:1.1.0.1:release_win32@jar' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

我完全不确定我在这里做错了什么。是分类器吗?如果我删除它一切正常(尽管显然我没有得到我想要的)。

4

1 回答 1

0

Ivy 不支持分类器。在 Ivy 文档中查看 Ivy 模式的语法:http: //ant.apache.org/ivy/history/latest-milestone/concept.html#patterns

你从哪里得到 JOGL 的 Ivy 定义?如果您自己制作,我会将配置更改为:

<conf name="nativeRuntime32" .../>
<conf name="nativeRuntime64" .../>
<conf name="nativeRuntime" extends="nativeRuntime32,nativeRuntime64" .../>

在 Gradle 中,您可以使用配置nativeRuntime32来获取所需的工件。

如果您没有编写 Ivy 定义,您可能会考虑要求 JOGL 开发人员添加更灵活的 Ivy 配置,以便人们可以更轻松地选择他们需要的工件。

于 2015-07-30T17:56:54.250 回答