lundi 10 août 2020

Arquillian ShrinkWrapper add library/dependency from other module

I am working on a multi module maven project, using Arquillian for testing. I figured out to add all needed and transitive dependencies like this:

@Deployment(testable = false)
public static Archive<?> createTestArchive() {


File[] files =
    Maven.resolver()
        .loadPomFromFile("pom.xml")
        .importRuntimeDependencies()
        .resolve()
        .withTransitivity()
        .asFile();

 return ShrinkWrap.create(WebArchive.class, "taskana.war")
           .addAsLibraries(files);

This is working well. Now I have some tests that actually need dependencies from other modules in the project. I don't want these in the pom because they are not generally needed, only in these few test cases. Is this possible? I can use:

 .addAsLibrary()

and provide a String or a file, but this results in an IllegalArgumentException, telling me the file doesn't exist or can't be accessed.

How do I add a jar from another module here?

Aucun commentaire:

Enregistrer un commentaire