2 Replies Latest reply on Jul 29, 2011 7:33 AM by Aliaksei Lahachou

    How can i add a jar to my war?

    gg cc Newbie

      Hi,

       

      I am trying to run my test with arquillian in jboss 6.0.

       

      Everything is working fine now but i would like to do another thing.

       

      I am using gson library and i would to like to add the jar to my test.war

       

      How can i do it?

       

      AddAsLibrary? AddAsWebInfResource???

       

      Thanks in advance.

        • 1. Re: How can i add a jar to my war?
          gg cc Newbie

          WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").

                                              addClasses(...).

                                                          addPackage(MalformedJsonException.class.getPackage()).

                                                          addPackage(SerializedName.class.getPackage()).

                                                          addPackage($Gson$Types.class.getPackage()).

                                                          addPackage(GsonBuilder.class.getPackage()).

                                                          addAsResource(new File("src/test/resources/persistence.xml"), ArchivePaths.create("META-INF/persistence.xml"));

           

          I would like to change the addPackages and to put only addJar or something similar....is it possible?

           

          thanks

          • 2. Re: How can i add a jar to my war?
            Aliaksei Lahachou Newbie

            You may use Maven dependency resolver. For example:

             

            WebArchive web = ShrinkWrap.create(WebArchive.class)

                    .addAsLibraries(DependencyResolvers

                            .use(MavenDependencyResolver.class)

                            .artifact("com.google.code.gson:gson:1.7.1")

                            .resolveAsFiles());