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

JUnit and Jetbrains annotations leaked as transitive dependencies #71

Open
Avalancs opened this issue Nov 16, 2024 · 7 comments
Open

JUnit and Jetbrains annotations leaked as transitive dependencies #71

Avalancs opened this issue Nov 16, 2024 · 7 comments

Comments

@Avalancs
Copy link

Avalancs commented Nov 16, 2024

I have a project of mine where I use KeePassJava2 and was trying to slim down the number of jars that I need to include in my deployment when I noticed that using any KeePassJava2 dependency from version 2.2.2 will include junit:junit:4.13.2 and org.jetbrains:annotations:24.1.0.

Neither of them are libraries which are supposed to be included in the released pom.xml. If I exclude them in my project using Gradle the application runs fine, so they are not needed as transitive compile/runtime dependencies.

This will require some maven restructuring in the project as far as I see.

@jorabin
Copy link
Owner

jorabin commented Nov 18, 2024

Thank you for this. I'll have a look and see why it is happening.

Jo

@jorabin
Copy link
Owner

jorabin commented Nov 19, 2024

Two reasons for it happening: the first is that the Maven Run Listener is not in src/test and the other is that the tests defined in the test module are not either. I have always avoided using test-jar but that's probably the way to go here so they can be used by the modules that need to use them as tests, and make it clear that the test module is not needed at runtime at all.

The annotations are a compile dependency. I had not considered using scope provided as the jar is not needed at runtime, as you point out.

@jorabin
Copy link
Owner

jorabin commented Nov 19, 2024

Further thoughts on this: thanks for your pull request.

Changing MavenRunListener to a test class makes it invisible to compilation of other modules. Anyway, I have done a bit of a major hack around, which I think addresses the main points of what you are after, namely not having a run-time dependency on junit or annotations.

Additionally, I've made the changes to the test module, to make it a test-jar which means that test files are no longer part of the run-time either, which they would have been before.

A bit more to do to address #70 as well, then I will make this 2.2.3.

jorabin added a commit that referenced this issue Nov 19, 2024
@Avalancs
Copy link
Author

Changing MavenRunListener to a test class makes it invisible to compilation of other modules.

Aww :( I'm more familiar with Gradle than maven, seen the test-jar recommended many times but couldn't quite figure it out. Thank you for taking the time to fix this :)

jorabin added a commit that referenced this issue Nov 22, 2024
jorabin added a commit that referenced this issue Nov 22, 2024
* v3:
  Fixes for #70, Refactor for #71
@jorabin
Copy link
Owner

jorabin commented Nov 25, 2024

The way it ended up is that MavenRunListener is in a new module called util which is not needed at run time and that as mentioned the tests ended up in test-jar.

@Avalancs
Copy link
Author

Sounds good to me, thank you! 😃

@jorabin jorabin reopened this Nov 25, 2024
@jorabin
Copy link
Owner

jorabin commented Nov 25, 2024

Reopening as not yet released, will be 2.2.3

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

No branches or pull requests

2 participants