hosuaby / inject-resources

Simple and convenient way to read content of resource in Java.
http://inject-resources.hosuaby.io
Apache License 2.0
53 stars 5 forks source link

Why inject-resources-junit-jupiter does not depend on inject-resources-core? #7

Closed michaldo closed 3 years ago

michaldo commented 3 years ago

It it is natural that when I add dependendcy to inject-resources-junit-jupiter I also want inject-resources-core.

Nobody wants first lib without second one

hosuaby commented 3 years ago

Hello, @michaldo inject-resources-core is a dependency of inject-resources-junit-jupiter. inject-resources-junit-jupiter can't be used without first one.

michaldo commented 3 years ago

Page https://mvnrepository.com/artifact/io.hosuaby/inject-resources-junit-jupiter/0.2.0 shows that there in such dependency

hosuaby commented 3 years ago

inject-resources-core is a compileOnly dependency of inject-resources-junit-jupiter and inject-resources-junit-vintage. If you use InjectResources for tests, you need two explicit imports, like documentation says: https://hosuaby.github.io/inject-resources/0.2.0/asciidoc/#inject-resources-junit-jupiter

I made this choice because I think it gives user a more fine grained control over dependencies of project.

inject-resources-core is a standalone project, that can be used in production code. So user is perfectly able to add inject-resources-core as compile dependecy to use it in production code, and inject-resources-junit-jupiter as testCompile dependecy for tests.

InjectResources for Spring is quite diferent. Spring is production dependency, so not need to complicate things here. While used imports inject-resources-spring it imports automatically inject-resources-core.

michaldo commented 3 years ago

For me inject-resources is testing utility. I don't need it in production code but in test I often need compare something against expected file and inject-resources is very handy.

When I have to add two dependencies to use single feature I feel it is a defect.

From client perspective inject-resources-junit-jupiter is couple of annotations. These annotations are driven by inject-resources-core. Maybe best way is repackage (shade) classes into private package space, for example com.adelean.jupiter.inject.resources.core and drive annotations by code which separated from core used in production?

hosuaby commented 3 years ago

Hm. I will think about this proposition. I will weight pros and cons of this architectural change.

hosuaby commented 3 years ago

Fixed in 0.3.0