Gradle是否支持常春藤存储库的分类器?

时间:2013-09-11 09:04:37

标签: gradle

我正在尝试基于分类器从Ivy存储库(在Artifactory中)检索Gradle依赖项(过滤包含本机代码的DLL以获得相关处理器体系结构的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

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

1 个答案:

答案 0 :(得分:0)

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

你在哪里获得JOGL的常春藤定义?如果您自己创建,我会将配置更改为:

{{ "HOMETITLE" || translate }}

在Gradle中,您可以使用配置<script src="../libs/angular/angular.js"></script> <script src="../libs/angular-route/angular-route.js"></script> <script src="../libs/angular-resource/angular-resource.js"></script> <script src="../libs/angular-translate/angular-translate.js"></script> <script src="../libs/angular-translate-loader-partial/angular-translate-loader-partial.js"></script> <script src="../js/controllers/HomeCtrl.js"></script> <script src="../js/appRoutes.js"></script> <script src="../js/index.js"></script> 来获取所需的工件。

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