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

Classpath order is wrong #53

Open
tjonsson opened this issue Feb 9, 2017 · 1 comment
Open

Classpath order is wrong #53

tjonsson opened this issue Feb 9, 2017 · 1 comment

Comments

@tjonsson
Copy link

tjonsson commented Feb 9, 2017

It looks like the classpath order is wrong when running the application.

Example:
I have a class "MyClass" which also exist in "Dependency.jar".

When running the application I expect that my own "MyClass" will override MyClass in Dependency.jar but instead, MyClass from Dependency.jar is used.

This was tested in 0.4.0

@tjonsson tjonsson closed this as completed Feb 9, 2017
@tjonsson tjonsson reopened this Feb 14, 2017
@aalmiray
Copy link
Contributor

Running the application using the Gradle run command follows the conventions set forth by Gradle regarding dependency resolution and classpath order.

It's generally not a good practice to expect certain JARs to be loaded first than orders, as classpath order can't be explicitly guaranteed. Overriding a class definition with another in a different JAR is often times a brittle solution.

May I suggest a different approach to provide an alternative behavior? You may try using ServiceLoader or another pluggable mechanism to select the correct implementation. You may even use the dependency injection container for this matter.

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