How do you organize your package names? Do you do ...
# library-development
m
How do you organize your package names? Do you do 1 artifact == 1 packageName? Or is it OK to reuse packageNames between artifactIds?
h
With JPMS you are not allowed to split packages names across artifacts, so I would recommend 1 package name = 1 artifact
m
That's if I want Java consumers right?
What if have coroutines and extensions functions everywhere
And I don't mind too much about Java consumers
h
It’s not Java but JVM if you want to use JPMS.
👍 1
m
I see
Thanks!
e
1 artifact = N packages works with JPMS, just avoid N artifacts with 1 package
h
Yeah true
m
Is it ok to have "subpackages"? Like
foo
in artifact1 and
foo.bar
in artifact2
Those are considered separate?
👌 4
h
Yes, in the same artifact, but you can’t reuse a package name in another artifact (Gradle module)
👍 1
👎 1
v
Packages
foo
and
foo.bar
are totally separate packages without any relation. There is no such thing as a "sub-package", even if some people use that term sometimes. So yes, it is absolutely fine to have class
foo.Baz
in one artifact and
foo.bar.Baz
in another artifact.
a
what if I have
foo.Bar
in 1 artifact and
foo.Baz
in another artifact? will that work with JPMS?
h
Not with module-path.
a
so if all the artifacts are part of the same module? then no problem?
e
module = jar in JPMS, and jar = artifact in build systems
👍🏾 1
v
Well, it can work in different JARs. module=jar is only the default. You can for example use
--patch-module
to combine two jars to one module. But yeah,
foo.Bar
and
foo.Baz
are classes in the same package, so they must be in the same module or you get an error about split package