4

The ivy file for Guice 3.0 includes a guice-3.0-no_aop.jar. Since I am creating an Android application I would like to configure my ivy file to make use of that jar instead of the 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>

When I use the above configuration and derivations thereof I receive this or similar errors:

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

What is wrong with my configuration? How should I configure my dependencies to use the
guice-3.0-no_aop.jar?

Edit
To be clear I have tried configuring Guice 3.0 in the simplest fashion:

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

Unfortunately this results in ivy just using the guice-3.0.jar. I need to configure it to use the downloaded but not used guice-3.0-no_aop.jar.

Edit
As requested here is the content of the ivy.xml for Guice 3.0:

<?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>
ahsteele
  • 26,243
  • 28
  • 134
  • 248

2 Answers2

1

It seems that the ivy file contains some maven properties and one says:

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

so this artifact is already without aop.

So you can just omit:

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

and resolve guice with:

<dependency org="com.google.inject" name="guice" rev="3.0"
          transitive="false"/>
oers
  • 18,436
  • 13
  • 66
  • 75
  • When I use your suggested configuration ivy includes the `guice-3.0.jar` I need to use the `guice-3.0-no_aop.jar`. The appropriate jar is being downloaded just not used. What am I missing? – ahsteele Aug 27 '12 at 06:37
  • @ahsteele the ivy.xml does not offer an artifact guice-3.0-no_aop.jar. Are you sure that guice-3.0.jar is not guice-3.0-no_aop.jar (just renamed). – oers Aug 27 '12 at 06:41
  • I am sure. Very different behavior provided by the two. Basically guice is unusable on Android unless you use the no_aop version. But if I understand what you are saying the ivy configuration provides no mechanism to get to the jar. – ahsteele Aug 27 '12 at 06:43
  • @ahsteel [is this the pom?](http://www.jarvana.com/jarvana/inspect-pom/com/google/inject/guice/3.0/guice-3.0.pom) ? The no_aop profile really seems to create a no_aop.jar, but the ivy translation does not offer this as a choice(?). – oers Aug 27 '12 at 06:47
  • I think that's exactly what is happening. The jar is created but ivy doesn't offer a means by which to use it. I was hoping for a workaround of some kind. As I said the `guice-3.0-no_aop.jar` is downloaded just not accessible via ivy from what I can tell. – ahsteele Aug 27 '12 at 07:08
  • @ahsteele I think it would be possible to use a [url resolver](https://ant.apache.org/ivy/history/2.2.0/resolver/url.html) to download the artifact directly, which repository do you use? – oers Aug 27 '12 at 08:20
1

After hacking around lots of posts, and a lot of trial and error, I got this working:

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

You may check the downloaded file size to confirm it is smaller than the default jar, with AOP. Also, you can change your retrieve pattern to include the optional classifier attribute, so you will se the filename change:

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

A related SO question How to dowload multiple Maven dependencies in Ivy with different classifiers?

This may also work: http://mail-archives.apache.org/mod_mbox/ant-ivy-user/200905.mbox/%3CCAD31248BE809F4A869854C597A558EE0AC62344@TROUX-EX01.hq.troux.com%3E

Community
  • 1
  • 1
Ronoaldo Pereira
  • 647
  • 7
  • 12