12 Replies Latest reply on Dec 12, 2011 8:06 AM by aslak

    Dynamic deployments

    bmajsak

      Hi guys,

       

      I would like to achieve dynamic deployment. It might be really useful for persistence extension where each test might have different data sets and different formats which also affects dependencies which must be deployed along with the core extension (like Excel or Yaml parsers). I also don't want to force users to store their data sets in the fixed location and more importantly I don't want to make huge jar with stuff which not used at all

       

      If I understand correctly I cannot inject class under test to the AuxiliaryArchiveAppender. So I dig a little bit in the Arquillian code and found possible solution. I can listen for GenerateDeployment event after DeploymentGenerator, and inject in my dynamic appender:

      {code}@Inject @ClassScoped

      Instance<DeploymentScenario> deployment;{code}

      Then I can have access to list of all Deployments which contain of DeploymentDescription and thus all the archives which are generated.

       

      Is it the right direction? Or maybe I can achieve it in easier way?

       

      Thanks a lot for all suggestions!

        • 1. Re: Dynamic deployments
          aslak
          • 2. Re: Dynamic deployments
            bmajsak

            I was thinking about this one but wasn't certain if it's the right place to put dependencies which are used by the extension itself. I thought that the proper way is to append extension jar itself. But if it's the way to go then it's definitely easier! Thanks a lot!

            • 3. Re: Dynamic deployments
              aslak

              You should be able to @Inject Instance<TestClass> in the AuxilliaryArchiveAppender as well.

               

              AuxilliaryArchiveAppender's are more for static stuff at this point. The problem with them is that you can't control which to include when. So e.g. even if a JSFUnit is not used in a specific test, it's still bundled.

              • 4. Re: Dynamic deployments
                bmajsak

                In 1.0.0.CR5 I'm not able to @Inject Instance<TestClass> in the AuxilliaryArchiveAppender...

                 

                It always results with null. And I guess I cannot really use ApplicationArchiveProcessor to resolve dynamically which dependencies are needed hence they are actually used by the extension itself, not test.jar.

                 

                Does it mean that the only option is to bundle everything in AuxilliaryArchiveAppender?

                • 5. Re: Dynamic deployments
                  aslak

                  aa, sorry. You can in master.   I thought it was fixed earlier.

                  1 of 1 people found this helpful
                  • 6. Re: Dynamic deployments
                    bmajsak

                    Thanks a lot! It works with 1.0.0.Final-SNAPSHOT

                    • 7. Re: Dynamic deployments
                      bmajsak

                      Didn't really feel like it should be part of seperated thread so I decided to extend already existing one

                       

                      My problem now is - I moved logic to include datasets from extension jar itself to the test archive using ApplicationArchiveProcessor (as suggested). However this approach forces me to deal with different types of archive. My use case is - I want to add dataset files to root datasets folder (or any other defined by user). It works for JARs obviously, but for instance in case of WAR I need to put them under WEB-INF, and so on.

                       

                      So I was wondering if there is a way to include additional JAR with all dependencies I need (datasets in particular, but maybe also libraries dynamically determined), let's say arquillian-persistence-extension-deps.jar. I extended AnnotationDeploymentScenarioGenerator and created additional DeploymentDescriptor, but it's not visible for extension jar. Is there any way to put it on extension's classpath? Or maybe some other solution for my problem exists?

                      • 8. Re: Dynamic deployments
                        aslak

                        I think you should comply to the ResourceContainer interface, and in the case of ResourceContainer not being supported by the Archive(ear), you should pack your resources as a JavaArchive and comply with the LibraryContainer interface. ShrinkWrap should handle the underlying locations in the target Archive..

                         

                        or optinally the other way around, comply to LibraryContainer where supported, but if unsupported(jar) use as a ResourceContainer.

                        • 9. Re: Dynamic deployments
                          bmajsak

                          And still appending to test archive, right?

                          • 10. Re: Dynamic deployments
                            aslak

                            yes, but instead of checking if this is a WebArchive or a JavaArchive, see if the Archive support ResourceContianer or LibraryContianer

                            • 11. Re: Dynamic deployments
                              bmajsak

                              That's clear. Thx a lot!

                               

                              Is there any way to get rid off the AuxilliaryArchiveAppender's static nature in the next major release? I have a feeling that those dependencies would be more happy sitting within extension jar instead of test archive

                              • 12. Re: Dynamic deployments
                                aslak

                                Yeah, we need to rethink some of the packaging pipeline to make it more extension friendly. It a bit all or nothing atm.