8 Replies Latest reply on Apr 15, 2011 4:55 AM by befield

    How to obtain an archive from a maven repo?

    juergen.zimmermann

      I want to obtain the JAR for DbUnit from the maven repository. So far I'm using the solution below. Is it the recommended usage or is there another recommendation on using the new API of Alpha 12?

       

      GenericArchive dbUnitJar = DependencyResolvers.use(MavenDependencyResolver.class)

                                                            .artifact("org.dbunit:dbunit:2.4.8")

                                                            .resolveAs(GenericArchive.class)

                                                            .iterator()

                                                            .next();

        • 1. Re: How to obtain an archive from a maven repo?
          aslak

          resolve will resolve all the dependencies of the Artifact as well, and you can add them directly to the Archive. e.g.

           

          WebArchive war = ShrinkWrap.create(WebArchive.class).addAsLibraries(
               DependencyResolvers.use(MavenDependencyResolver.class)
                    .artifact("org.apache.maven.plugins:maven-compiler-plugin:2.3.2")
                    .resolveAs(GenericArchive.class));
          
          
          
          • 2. Re: How to obtain an archive from a maven repo?
            alrubinger

            As an aside, I think I finally figured out what was bothering me with this API, and it wasn't until I saw Juergen's question that this becme apparent why.

             

            "Resolve" to me does not imply dependencies.  "I want a Maven Coordinate, gimme it", is what I think when I see "resolve".

             

            "Resolve With Dependencies" I think describes what we currently have.

             

            So what do we think of:

             

            <T extends Archive<T>> Iterable<T> MavenDependencyResolver.resolveWithDependenciesAs(T type);
            <T extends Archive<T>> T MavenDependencyResolver.resolveAs(T type);
            

             

            ...?

             

            S,

            ALR

            • 3. Re: How to obtain an archive from a maven repo?
              silenius

              I've been waiting for this feature for a long time... Maybe it's time for me to help implement it

               

              Andrew would you like to create an issue with this info and assign it to me?

              • 5. Re: How to obtain an archive from a maven repo?
                silenius

                Hi Aslak,

                 

                I've been following SHRINKWRAP-140 for some time

                 

                I purpose to implement what Andrew suggested:

                <T extends Archive<T>> Collection<T> MavenDependencyResolver.resolveWithDependenciesAs(T type);
                <T extends Archive<T>> T MavenDependencyResolver.resolveAs(T type);
                

                 

                And also a shorthand as requested by Nicklas at https://issues.jboss.org/browse/SHRINKWRAP-261.

                Thinking about something like MavenArtifact.resolve("joda-time:joda-time:1.6") which returns a GenericArchive.

                 

                I should implement it later this week if it's ok with both of you.

                • 6. Re: How to obtain an archive from a maven repo?
                  alrubinger

                  Great to see you've taken these.

                   

                  Let's see a proposal for SHRINKWRAP-261 before you dig in there, though?  I like to run all API changes through the wider community.  I think what we have in SHRINKWRAP-265 makes sense now.

                   

                  S,

                  ALR

                  • 7. Re: How to obtain an archive from a maven repo?
                    silenius

                    Hi Andrew,

                     

                    I've created a new discussion on the developer forum so we can discuss it further: http://community.jboss.org/thread/164679.

                    • 8. Re: How to obtain an archive from a maven repo?
                      befield

                      Hi

                       

                      First of all, I'd like to thank you for your really nice work!

                       

                      For the new project, we are switching from the old cactus test framework to arquilllian and shrinkwrap. Cool!

                       

                      The problen we have is related to this discussion. We don't know exactly how to load maven archives. According Aslak's proposal, we are able to optain the archive but it is not complete. The META-INF information are not present.

                       

                      The code snippet is:

                      ResourceAdapterArchive qfjJca = ShrinkWrap.create(ResourceAdapterArchive.class, "jca-qfj-adapter-sti-1_19-1.0.0.7.rar")

                                  .addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class)

                                  .configureFrom(System.getenv().get("M2_HOME") + "/conf/settings.xml")

                                  .loadReposFromPom("./pom.xml")

                                  .artifact("com.swx.jca.qfj:jca-qfj-adapter-sti-1_19:1.0.0.7")

                                  .resolveAs(ResourceAdapterArchive.class));

                       

                      Note that without 'configureFrom' our local repository is not found.

                       

                      Here is what the get:

                      jca-qfj-adapter-sti-1_19-1.0.0.7.rar:

                      /jca-qfj-adapter-sti-1_19-1.0.0.7.jar

                      /antlr-2.7.7.jar

                      /slf4j-jdk14-1.5.3.jar

                      /slf4j-api-1.5.3.jar

                      /stringtemplate-3.2.1.jar

                      /mina-core-1.1.0.jar

                      /quickfixj-1_4_0-sti-1_19-messages-1.0.0.0.jar

                      /quickfixj-core-1.4.0.swx1_swx.jar

                       

                      Here is what we should get:

                      jca-qfj-adapter-sti-1_19-1.0.0.7.rar:

                      /jca-qfj-adapter-sti-1_19-1.0.0.7.jar

                      /antlr-2.7.7.jar

                      /slf4j-jdk14-1.5.3.jar

                      /slf4j-api-1.5.3.jar

                      /stringtemplate-3.2.1.jar

                      /mina-core-1.1.0.jar

                      /jline-0.9.94.jar

                      /META-INF/

                      /META-INF/maven/

                      /META-INF/maven/com.swx.jca.qfj/

                      /META-INF/maven/com.swx.jca.qfj/jca-qfj-adapter-sti-1_19/

                      /META-INF/maven/com.swx.jca.qfj/jca-qfj-adapter-sti-1_19/pom.properties

                      /META-INF/maven/com.swx.jca.qfj/jca-qfj-adapter-sti-1_19/pom.xml

                      /META-INF/jca-qfj-version.txt

                      /META-INF/MANIFEST.MF

                      /META-INF/ra.xml

                      /META-INF/jca-qfj-version_template.txt

                      /quickfixj-1_4_0-sti-1_19-messages-1.0.0.0.jar

                      /quickfixj-core-1.4.0.swx1_swx.jar

                       

                      At the moment, we load this resource archive via zip importer.

                       

                      Do you have an idea, what we have to change?

                       

                      Thanks a lot Ralf