I have a parent project which has dependencies with scope test
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.31.0</version>
<scope>test</scope>
</dependency>
Now I "mvn install"ed the parent project, when I include this parent project as dependency in my child project
<dependency>
<groupId>group</groupId>
<artifactId>parentproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
selenium-firefox-driver
is not available. The compile scoped dependencies are available.
How can I make it available? I won't change the scope neither in the parent project nor in the child project. Because I need some classes of the parent in at runtime
As outlined by Charlee Chitsuk in his answer, your scope (compile in the child project) will omit the test dependencies of the included project.
A clean solution would be to separate the concerns of the parent project into two separate projects:
selenium-firefox-driver
) with a compile scope. Additionally, this project contains all of your generic test resources, e.g. JUnit base classes, in src/main/java
. parent-test
here with test
scope.In your child project, you can now include parent-test
with scope test as well, giving you access to its resources with the right scope.
This setup will provide a clear project structure with clean scoping, avoiding issues like you have mentioned. Yes, it's a bit more complex due to the additional project, but it's a lot cleaner as well.
Instead of including the parent project as dependency in your child pom, you should make the parent project as the parent
of your child pom.
<parent>
<groupId>group</groupId>
<artifactId>parentproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
You cannot call it a parent project
otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With