【问题标题】:How do I configure my ivy.xml for guice 3.0 to use the no aop jar?如何为 guice 3.0 配置我的 ivy.xml 以使用 no aop jar?
【发布时间】:2012-08-20 14:17:57
【问题描述】:

Guice 3.0 的 ivy 文件包含一个 guice-3.0-no_aop.jar。由于我正在创建一个 Android 应用程序,因此我想配置我的 ivy 文件以使用该 jar 而不是 guice-3.0.jar

<ivy-module version="1.0">
    <info organisation="com.myapp.android" module="appname"/>
    <dependencies>
        <!-- other dependencies -->
        <dependency org="org.roboguice" name="roboguice" rev="2.0"
          transitive="false" />
        <dependency org="com.google.inject" name="guice" rev="3.0"
          transitive="false">
            <artifact name="guice-3.0-no_aop" type="jar" />
        </dependency>
    </dependencies>
</ivy-module>

当我使用上述配置及其派生时,我收到此错误或类似错误:

Some projects fail to be resolved
 Impossible to resolve dependencies of com.mystuff.android#myapp;working@computer
  download failed: com.google.inject#guice;3.0!guice-3.0-no_aop.jar

我的配置有什么问题?我应该如何配置我的依赖项以使用
guice-3.0-no_aop.jar

编辑
为了清楚起见,我尝试以最简单的方式配置 Guice 3.0:

<dependency org="com.google.inject" name="guice" rev="3.0"
              transitive="false">

不幸的是,这导致常春藤只使用guice-3.0.jar。我需要将其配置为使用已下载但未使用的guice-3.0-no_aop.jar

编辑
这里要求的是 Guice 3.0 的 ivy.xml 的内容:

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
    <info organisation="com.google.inject"
        module="guice"
        revision="3.0"
        status="release"
        publication="20110325121947"
    >
        <description homepage="" />
        <m:properties__guice.with.no_aop>true</m:properties__guice.with.no_aop>
        <m:properties__project.build.sourceEncoding>UTF-8</m:properties__project.build.sourceEncoding>
        <m:properties__guice.api.version>1.3</m:properties__guice.api.version>
        <m:properties__cglib.version>2.2.1-v20090111</m:properties__cglib.version>
        <m:properties__guice.with.jarjar>true</m:properties__guice.with.jarjar>
        <m:maven.plugins>null__maven-remote-resources-plugin__null|org.codehaus.mojo__animal-sniffer-maven-plugin__null|null__maven-surefire-plugin__null|org.apache.felix__maven-bundle-plugin__null|null__maven-jar-plugin__null</m:maven.plugins>
    </info>
    <configurations>
        <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
        <conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
        <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
        <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
        <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
        <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
        <conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository."/>
        <conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
        <conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
        <conf name="optional" visibility="public" description="contains all optional dependencies"/>
    </configurations>
    <publications>
        <artifact name="guice" type="jar" ext="jar" conf="master"/>
        <artifact name="guice" type="source" ext="jar" conf="sources" m:classifier="sources"/>
        <artifact name="guice" type="javadoc" ext="jar" conf="javadoc" m:classifier="javadoc"/>
    </publications>
    <dependencies>
        <dependency org="javax.inject" name="javax.inject" rev="1" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <dependency org="aopalliance" name="aopalliance" rev="1.0" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <dependency org="org.sonatype.sisu.inject" name="cglib" rev="2.2.1-v20090111" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <dependency org="javax.inject" name="javax.inject-tck" rev="1" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.springframework" name="spring-beans" rev="3.0.5.RELEASE" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="biz.aQute" name="bnd" rev="0.0.384" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.apache.felix" name="org.apache.felix.framework" rev="3.0.5" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.testng" name="testng" rev="5.11" force="true" conf="test->runtime(*),master(*)">
            <artifact name="testng" type="jar" ext="jar" conf="" m:classifier="jdk15"/>
        </dependency>
    </dependencies>
</ivy-module>

【问题讨论】:

  • 能把guice 3.0的ivy.file贴出来吗?
  • @oers 我为 Guice 3.0 添加了 ivy.xml。

标签: android guice ivy roboguice aopalliance


【解决方案1】:

似乎 ivy 文件包含一些 maven 属性,其中一个说:

<m:properties__guice.with.no_aop>true</m:properties__guice.with.no_aop>

所以这个工件已经没有aop了。

所以你可以省略:

<artifact name="guice-3.0-no_aop" type="jar" />

并通过以下方式解决guice:

<dependency org="com.google.inject" name="guice" rev="3.0"
          transitive="false"/>

【讨论】:

  • 当我使用你建议的配置时,常春藤包括guice-3.0.jar,我需要使用guice-3.0-no_aop.jar。正在下载适当的 jar,只是未使用。我错过了什么?
  • @ahsteele ivy.xml 不提供工件 guice-3.0-no_aop.jar。你确定 guice-3.0.jar 不是 guice-3.0-no_aop.jar (刚刚重命名)。
  • 我确定。两者提供的行为非常不同。除非您使用 no_aop 版本,否则基本上 guice 在 Android 上是不可用的。但如果我明白你在说什么,常春藤配置没有提供任何机制来获取罐子。
  • @ahsteel is this the pom? ? no_aop 配置文件似乎确实创建了一个 no_aop.jar,但常春藤翻译不提供此选项(?)。
  • 我认为这正是正在发生的事情。 jar 已创建,但 ivy 不提供使用它的方法。我希望有某种解决方法。正如我所说,guice-3.0-no_aop.jar 是下载的,但据我所知,无法通过 ivy 访问。
【解决方案2】:

在修改了很多帖子并进行了大量试验和错误之后,我得到了这个工作:

<dependency org="com.google.inject" name="guice" rev="3.0">
   <artifact name="guice"  m:classifier="no_aop" type="jar" />
</dependency>

您可以使用 AOP 检查下载的文件大小以确认它小于默认 jar。此外,您可以更改检索模式以包含可选的分类器属性,因此您将看到文件名更改:

<ivy:retrieve 
    pattern="lib/[artifact]-[revision](-[classifier]).[ext]" />

一个相关的 SO 问题How to dowload multiple Maven dependencies in Ivy with different classifiers?

这也可能有效:http://mail-archives.apache.org/mod_mbox/ant-ivy-user/200905.mbox/%3CCAD31248BE809F4A869854C597A558EE0AC62344@TROUX-EX01.hq.troux.com%3E

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多