I was not aware that cross visibility quirkiness remained even on published artifacts, so I’ve found these to be some rules of thumb I wasn’t aware:
-
Transient dependencies are not accessible. (as opposed to what some
sources have said) I was told that if B implements A, I would have
access to A from C when C implements B… this was not the case
after testing. (Because of #1, I was structuring the artifacts
dividing them in submodules, classifying them based on degree of
outer dependance.) -
Artifact submodules can ONLY be accessed directly under
main/java
.
If a class’ path goes deeper than this, the class will have access
to none of the submodule’s contents:
On build.gradle
:
dependencies {
implementation('io.github.org:anartifact-submodule:1.0.0')
}
From src/main/java/some_package/DeepClass.java
package some_package;
import io.github.org.anartifact_submodule.SomeClass;
// import anartifact_submodule.SomeClass;
// import submodule.SomeClass;
public class DeepClass {
SomeClass sc = new SomeClass();
}
“cannot resolve
[ io | anartifact_submodule | submodule | SomeClass ]
symbol”
Now from main/java/SurfaceClass.java
:
class SurfaceClass {
SomeClass sc = new SomeClass();
}
No issue, no import needed.
How can I access a submodule’s content from inside a package?