Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the dependencies should be set to <scope>provided</scope> #4

Open
pravsingh opened this issue Jul 5, 2018 · 2 comments
Open

the dependencies should be set to <scope>provided</scope> #4

pravsingh opened this issue Jul 5, 2018 · 2 comments

Comments

@pravsingh
Copy link

I'm trying to use it in my junit 5 based app and getting version conflicts. I had to exclude below to make it work:

<exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
@JensPiegsa
Copy link
Owner

To my knowledge (please correct me if I'm wrong) Maven's version picking is based on the distance in the dependency tree (see: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependencies). So, if you define a dependency in your pom.xml, its version declaration should win. If the distance of two transitive dependencies is the same, Maven picks the one that is declared first. To overrule this mechanism, add a <dependency> entry under <dependencyManagement> to choose the preferred version or in case of JUnit delegate the version management to a bom file:

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.junit</groupId>
			<artifactId>junit-bom</artifactId>
			<version>${junit.jupiter.version}</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

The exclusion approach seems a bit drastic here. It is only necessary, if your runtime already ships these libraries.

Reducing the scope to provided, like you've suggested, would force users to explicitly declare direct dependencies to all of them (and manually care for their version management).

Please provide some more information regarding your concrete issue. In the meantime I'll double-check the need for these dependencies. Maybe there are some other options.

@pravsingh
Copy link
Author

agree with you. However I found issues when started using https://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html plugin config.
Basically compilation failed with conflicting versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants