I have this pair of dependencies in my pom.xml
:
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.6.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.6.7</version>
<scope>compile</scope>
</dependency>
You can see that it's the same dependency, only under two different scopes. It would be perfect if Maven allowed for something like <scope>test,compile</scope>
but, alas, it does not.
Since both my IDE and Maven warn me about duplicate dependencies, I was wondering whether there is any way for me to compress these dependency declarations into one.
If you need to copy the maven warning, here you go:
[WARNING] Some problems were encountered while building the effective model for org.finra.mdrepo.apollo:moonshot:jar:0.1
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:jar -> duplicate declaration of version 2.6.7 @ line 563, column 17
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
This SO post details that the runtime
scope implies the test
scope, but it also seems to be used entirely separately from the compile
scope (which makes sense). So the solution of just using runtime
would not work for me.