locationtech / spatial4j

LocationTech Spatial4j: A Geospatial Library for Java
https://projects.eclipse.org/projects/locationtech.spatial4j
935 stars 168 forks source link

Split packages between spatial4j and spatial4j-*-tests #214

Open dweiss opened 2 years ago

dweiss commented 2 years ago

These artifacts have classes in the same package which causes major headaches if one wants to use them together with the module system. Would it be at all possible to separate packages between these two modules?

dsmiley commented 2 years ago

To put tests in a different package from the code they are testing? That sounds unusual but yeah, possible. It's useful to use "package" visibility to expose methods to a a test that you would otherwise not want to expose.

Disclaimer: I'm only vaguely familiar with "split package" notions in the module system. I'd like to think tests need not adhere to this rule.

dweiss commented 2 years ago

spatial-extras requires a module:

moduleApi 'org.locationtech.spatial4j:spatial4j'

and the tests of that project require this:

testImplementation 'org.locationtech.spatial4j:spatial4j::tests'

both can't live as separate public modules with the same packages - this situation is really difficult to work around in consumer projects without all sorts of command-line JVM hackery. If it's a public module meant for consumption, it should use a separate package.

dweiss commented 2 years ago

It's useful to use "package" visibility to expose methods to a a test that you would otherwise not want to expose.

Yeah, this trick simply no longer works with the module system. module patching is a substitute for this, but it's hell in my opinion.