6 Replies Latest reply on Aug 5, 2011 7:24 AM by htfv

    Resolving artifacts from Maven reactor

    htfv

      Hello everyone!

       

      Is it possible to resolve artifacts from reactor, which are not installed to the local maven repository? I have the following project structure:

       

      parent

      + utils

      + integration-tests

       

      I want to include utils in deployed archive, but it does not work:

       

      return ShrinkWrap.create(WebArchive.class)

              .addAsLibraries(DependencyResolvers

                      .use(MavenDependencyResolver.class)

                      .artifact("com.example:utils:1.0.0-SNAPSHOT")

                      .resolveAsFiles());

       

      Is it not supported, or am I doing something wrong? Is there a workaround? I'm using Arquillian 1.0.0.CR1 and ShrinkWrap 1.0.0-beta-2.

       

      As far as I understand, the artifact is on the class path when test is executed. Is it possible to include the jar file on the class path as web archive library?

       

      Greets,

      Aliaksei

        • 1. Re: Resolving artifacts from Maven reactor
          aslak

          It should be possible to include utils via the Maven resolver as long as the utils has been installed in your local repo first.

          • 2. Re: Resolving artifacts from Maven reactor
            htfv

            Well... You are certainly right, but that's not the point. The test phase comes before the install phase with the idea that no untested artifact goes to repository. Maven itself has no problems resolving artifact from reactor. (Imagine that you have to install every artifact from the multi-module projects before building its dependents - no one would like it.)

             

            In my scenario, by the time integration-tests start, the utils module is built and available. Is it possible to make Maven dependency resolver also find artifacts in reactor, just as Maven itself does it?

            • 3. Re: Resolving artifacts from Maven reactor
              aslak

              Aa, no, that's currently not possible via the Maven Resolver. The Maven Resolver use the API that Maven use for the repositories, which is not the same as the 'within' same reactor api.

               

              You can import the utils based on a known path, tho not a very good solution.

               

              e.g.

               

              ShrinkWrap.create(ZipImporter.class, "utils.jar")

                .importFrom(new File("../utils/target/utils-1.0.0-SNAPSHOT.jar"))

                .as(JavaArchive.class);

               

               

              You can file a Feature Request for it on ShrinkWrap: https://issues.jboss.org/browse/SHRINKWRAP

              Use hte ext-resolver component

              • 4. Re: Resolving artifacts from Maven reactor
                htfv

                I only now realized, that I made a mistake. The Maven test phase is executed before the package phase. This means that in clean project and empty repository the artifacts are not created by the time tests are executed. Installing artifacts in local repository and then executing the tests would be the simplest.

                • 5. Re: Resolving artifacts from Maven reactor
                  aslak

                  you could possible bing surefire to the integration-test phase instead, that should be after package but before install

                  • 6. Re: Resolving artifacts from Maven reactor
                    htfv

                    Well, sure, I just don't want to do it ))