truth icon indicating copy to clipboard operation
truth copied to clipboard

Truth8 java 8 extension part of the main library?

Open apflieger opened this issue 5 years ago • 5 comments

Hello,

I couldn't find any discussion about that so I wanted to give it a chance. java 8 is now 6 years old, I doubt there are many legacy project (<java 8) that introduce Truth in their code base whereas people starts new project on java 11 at least now.

What do you think?

apflieger avatar Aug 27 '20 14:08 apflieger

Thanks. We plan to at least merge the 2 artifacts into 1 "soon" (probably months from now if it's left up to me, but this may be the kind of thing that someone could put together a PR for). We will still keep Truth and Truth8 as separate classes for the moment, but maybe we can convince ourselves that it's safe enough to merge the classes, too. (That might well break something, for Java 7 or for Android. We'd have to see. We probably won't drop compatibility with old versions of Android yet, but if Android works but Java 7 does not, we could consider dropping Java 7.)

cpovirk avatar Aug 27 '20 16:08 cpovirk

Yeah I mean merging Truth and Truth8 because that's what is painful to use.

apflieger avatar Aug 27 '20 16:08 apflieger

Yeah. I forget if we've experimented to see what might break. Someday :(

cpovirk avatar Aug 27 '20 16:08 cpovirk

com.google.common.truth.Truth and com.google.common.truth.Truth8 classes reside in the same package but in different modules. After converting both maven artifacts to OSGI bundles I get java.lang.NoClassDefFoundError: com/google/common/truth/Subject by calling Truth8.assertThat(Optional<?>).hasValue(expected) in a downstream test bundle.
Both bundles provide Export-Package: com.google.common.truth in MANIFEST.MF. This looks like split package problem. Truth Subject from "main" bundle is not visible in the "extension" bundle.

At the first glance, there are two possible solutions:

  • Move Truth8 to a subpackage like com.google.common.truth.extensions.truth8 like ProtoTruth and Re2jSubjects
  • Merge Truth8 extension with Truth main module (preferred)

bjmi avatar Jan 25 '22 20:01 bjmi

All true, thanks. We intend to merge them, but it's been difficult to schedule time for Truth among our other priorities. It is frequently on my mind, but that doesn't actually help people who are hitting this issue :(

cpovirk avatar Jan 25 '22 20:01 cpovirk

With the release of Truth 1.4.2, this is essentially done: You no longer need the truth-java8-extension artifact, and you no longer need the Truth8 class.

We could still do some more internal cleanup (like to move the tests of the Truth8 functionality into the core directory). But from the perspective of users, this is finally done.

cpovirk avatar Feb 29 '24 21:02 cpovirk