How to configure Maven dependencies between test folders in two projects?

I have a project setup as follows:

parent |_____project-a |_____project-b 

I want the classes in the test folder of project-b to allow classes in the test folder of project-a.

In fact, I want to access both classes from the main folder and the material from the test folder.

Is it possible?

thanks

+6
source share
2 answers

You can build project A using the target test banner

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> 

Then enable it with type test-jar in project B:

  <dependency> <groupId>com.example</groupId> <artifactId>project-a</artifactId> <type>test-jar</type> <version>1.0-SNAPSHOT</version> <scope>test</scope> </dependency> 
+9
source

Since the contents of the test folder are not included in the target project, it cannot be used externally. The best way, in my opinion, is to move the common classes to the project as "project-testcommons" and use it in projects-a and project-b with the scope "test".

+5
source

Source: https://habr.com/ru/post/909253/


All Articles