From c04ad9ed6c4958f4dfef0c112ddf1017367a0d95 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Sun, 21 Sep 2025 09:51:59 -0400 Subject: [PATCH 01/21] Add Java Platform Module System (JPMS) support - Add module-info.java descriptors for core and extension modules - Configure multi-release JAR compilation for Java 9+ compatibility - Maintain Java 8 backward compatibility through multi-release structure - Support for Guava, JUnit, JSpecify, Error Prone, and ASM dependencies - Extension modules: truth-proto-extension, truth-liteproto-extension, truth-re2j-extension --- core/pom.xml | 24 ++++++++++++++++ core/src/main/java9/module-info.java | 27 ++++++++++++++++++ extensions/liteproto/pom.xml | 25 +++++++++++++++++ .../liteproto/src/main/java9/module-info.java | 26 +++++++++++++++++ extensions/proto/pom.xml | 25 +++++++++++++++++ .../proto/src/main/java9/module-info.java | 27 ++++++++++++++++++ extensions/re2j/pom.xml | 28 +++++++++++++++++++ .../re2j/src/main/java9/module-info.java | 22 +++++++++++++++ 8 files changed, 204 insertions(+) create mode 100644 core/src/main/java9/module-info.java create mode 100644 extensions/liteproto/src/main/java9/module-info.java create mode 100644 extensions/proto/src/main/java9/module-info.java create mode 100644 extensions/re2j/src/main/java9/module-info.java diff --git a/core/pom.xml b/core/pom.xml index 32fe3ef88..27b0c20aa 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -98,6 +98,23 @@ + + + compile-java9 + + compile + + + 9 + + ${project.basedir}/src/main/java9 + + true + false + 1.0 + + + maven-source-plugin @@ -110,6 +127,13 @@ maven-jar-plugin + + + + true + + + attach-gwt-sources diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java new file mode 100644 index 000000000..7d78c5046 --- /dev/null +++ b/core/src/main/java9/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module com.google.truth { + requires com.google.common; + requires junit; + + requires static org.jspecify; + requires static com.google.errorprone.annotations; + requires static org.objectweb.asm; + requires static auto.value.annotations; + + exports com.google.common.truth; +} \ No newline at end of file diff --git a/extensions/liteproto/pom.xml b/extensions/liteproto/pom.xml index a70faa5d8..58b0da1f8 100644 --- a/extensions/liteproto/pom.xml +++ b/extensions/liteproto/pom.xml @@ -96,6 +96,31 @@ + + + compile-java9 + + compile + + + 9 + + ${project.basedir}/src/main/java9 + + true + + + + + + maven-jar-plugin + + + + true + + + diff --git a/extensions/liteproto/src/main/java9/module-info.java b/extensions/liteproto/src/main/java9/module-info.java new file mode 100644 index 000000000..2d0c30da4 --- /dev/null +++ b/extensions/liteproto/src/main/java9/module-info.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module com.google.truth.extensions.liteproto { + requires com.google.truth; + requires com.google.common; + + requires static org.jspecify; + requires static com.google.errorprone.annotations; + requires static com.google.protobuf.lite; + + exports com.google.common.truth.extensions.proto; +} \ No newline at end of file diff --git a/extensions/proto/pom.xml b/extensions/proto/pom.xml index d52855799..09596e372 100644 --- a/extensions/proto/pom.xml +++ b/extensions/proto/pom.xml @@ -98,6 +98,31 @@ + + + compile-java9 + + compile + + + 9 + + ${project.basedir}/src/main/java9 + + true + + + + + + maven-jar-plugin + + + + true + + + diff --git a/extensions/proto/src/main/java9/module-info.java b/extensions/proto/src/main/java9/module-info.java new file mode 100644 index 000000000..756296e13 --- /dev/null +++ b/extensions/proto/src/main/java9/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module com.google.truth.extensions.proto { + requires com.google.truth; + requires com.google.truth.extensions.liteproto; + requires com.google.common; + requires com.google.protobuf; + + requires static org.jspecify; + requires static com.google.errorprone.annotations; + + exports com.google.common.truth.extensions.proto; +} \ No newline at end of file diff --git a/extensions/re2j/pom.xml b/extensions/re2j/pom.xml index 6ca4180ce..b9b2884b0 100644 --- a/extensions/re2j/pom.xml +++ b/extensions/re2j/pom.xml @@ -38,6 +38,34 @@ maven-javadoc-plugin + + maven-compiler-plugin + + + compile-java9 + + compile + + + 9 + + ${project.basedir}/src/main/java9 + + true + + + + + + maven-jar-plugin + + + + true + + + + diff --git a/extensions/re2j/src/main/java9/module-info.java b/extensions/re2j/src/main/java9/module-info.java new file mode 100644 index 000000000..2c1a6e7fc --- /dev/null +++ b/extensions/re2j/src/main/java9/module-info.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module com.google.truth.extensions.re2j { + requires com.google.truth; + requires com.google.re2j; + + exports com.google.common.truth.extensions.re2j; +} \ No newline at end of file From ad1f8d14d2872050121040516434a3336a73ba63 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Mon, 22 Sep 2025 15:43:58 -0400 Subject: [PATCH 02/21] Fix JPMS split package violations and enable documentation generation Resolves module system conflicts by moving liteproto extension from shared com.google.common.truth.extensions.proto package to unique com.google.common.truth.extensions.liteproto namespace. This eliminates split package violations that prevented proper module boundaries. Enables aggregated Javadoc generation using legacyMode=true to work around protobuf dependency conflicts between liteproto (protobuf-lite:3.0.1) and proto (protobuf-java:4.32.1) extensions that caused module-path failures. --- core/pom.xml | 19 +----- .../src/main/{java9 => java}/module-info.java | 2 + extensions/java8/pom.xml | 2 +- extensions/liteproto/pom.xml | 17 +---- .../LiteProtoSubject.java | 15 +++- .../{proto => liteproto}/LiteProtoTruth.java | 2 +- .../{proto => liteproto}/Platform.java | 2 +- .../internal/LiteProtoSubjectAccess.java | 68 +++++++++++++++++++ .../truth/extensions/proto/package-info.java | 27 -------- .../src/main/{java9 => java}/module-info.java | 8 ++- .../test}/LiteProtoSubjectTest.java | 14 ++-- extensions/pom.xml | 3 +- extensions/proto/pom.xml | 17 +---- .../truth/extensions/proto/ProtoSubject.java | 4 +- .../extensions/proto/ProtoSubjectBuilder.java | 4 +- .../truth/extensions/proto/ProtoTruth.java | 1 + .../src/main/{java9 => java}/module-info.java | 2 + .../proto/{ => test}/FieldScopesTest.java | 4 +- .../IterableOfProtosSubjectTest.java | 4 +- .../MapWithProtoValuesSubjectTest.java | 4 +- .../proto/{ => test}/MultiExpectFailure.java | 2 +- .../MultimapWithProtoValuesSubjectTest.java | 4 +- .../{ => test}/OverloadResolutionTest.java | 2 +- .../proto/{ => test}/ProtoSubjectTest.java | 2 +- .../{ => test}/ProtoSubjectTestBase.java | 8 ++- extensions/re2j/pom.xml | 17 +---- .../src/main/{java9 => java}/module-info.java | 4 +- .../re2j/{ => test}/Re2jSubjectsTest.java | 2 +- pom.xml | 17 ++++- 29 files changed, 159 insertions(+), 118 deletions(-) rename core/src/main/{java9 => java}/module-info.java (91%) rename extensions/liteproto/src/main/java/com/google/common/truth/extensions/{proto => liteproto}/LiteProtoSubject.java (94%) rename extensions/liteproto/src/main/java/com/google/common/truth/extensions/{proto => liteproto}/LiteProtoTruth.java (97%) rename extensions/liteproto/src/main/java/com/google/common/truth/extensions/{proto => liteproto}/Platform.java (97%) create mode 100644 extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java delete mode 100644 extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java rename extensions/liteproto/src/main/{java9 => java}/module-info.java (71%) rename extensions/liteproto/src/test/java/com/google/common/truth/extensions/{proto => liteproto/test}/LiteProtoSubjectTest.java (93%) rename extensions/proto/src/main/{java9 => java}/module-info.java (92%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/FieldScopesTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/IterableOfProtosSubjectTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/MapWithProtoValuesSubjectTest.java (97%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/MultiExpectFailure.java (97%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/MultimapWithProtoValuesSubjectTest.java (98%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/OverloadResolutionTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/ProtoSubjectTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{ => test}/ProtoSubjectTestBase.java (95%) rename extensions/re2j/src/main/{java9 => java}/module-info.java (93%) rename extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/{ => test}/Re2jSubjectsTest.java (97%) diff --git a/core/pom.xml b/core/pom.xml index 27b0c20aa..1bdd43c0d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ com.google.truth truth-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth Truth Core @@ -98,23 +98,6 @@ - - - compile-java9 - - compile - - - 9 - - ${project.basedir}/src/main/java9 - - true - false - 1.0 - - - maven-source-plugin diff --git a/core/src/main/java9/module-info.java b/core/src/main/java/module-info.java similarity index 91% rename from core/src/main/java9/module-info.java rename to core/src/main/java/module-info.java index 7d78c5046..98e7fe254 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java/module-info.java @@ -17,11 +17,13 @@ module com.google.truth { requires com.google.common; requires junit; + requires java.compiler; requires static org.jspecify; requires static com.google.errorprone.annotations; requires static org.objectweb.asm; requires static auto.value.annotations; + requires static com.google.j2objc.annotations; exports com.google.common.truth; } \ No newline at end of file diff --git a/extensions/java8/pom.xml b/extensions/java8/pom.xml index b6f38c544..bcbb2ba42 100644 --- a/extensions/java8/pom.xml +++ b/extensions/java8/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-java8-extension Obsolete Truth Extension for Java8 diff --git a/extensions/liteproto/pom.xml b/extensions/liteproto/pom.xml index 58b0da1f8..09a51b6b9 100644 --- a/extensions/liteproto/pom.xml +++ b/extensions/liteproto/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-liteproto-extension Truth Extension for Lite Protocol Buffers @@ -96,21 +96,6 @@ - - - compile-java9 - - compile - - - 9 - - ${project.basedir}/src/main/java9 - - true - - - maven-jar-plugin diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoSubject.java similarity index 94% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoSubject.java index 0f476ad26..c10ecf795 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoSubject.java @@ -14,18 +14,19 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.liteproto; import static com.google.common.base.Strings.lenientFormat; import static com.google.common.truth.Fact.fact; import static com.google.common.truth.Fact.simpleFact; -import static com.google.common.truth.extensions.proto.Platform.getTrimmedToString; +import static com.google.common.truth.extensions.liteproto.Platform.getTrimmedToString; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import com.google.common.truth.FailureMetadata; import com.google.common.truth.IntegerSubject; import com.google.common.truth.Subject; +import com.google.common.truth.extensions.liteproto.internal.LiteProtoSubjectAccess; import com.google.errorprone.annotations.CheckReturnValue; import com.google.j2objc.annotations.J2ObjCIncompatible; import com.google.protobuf.MessageLite; @@ -44,6 +45,16 @@ @NullMarked public class LiteProtoSubject extends Subject { + // Static initializer to register SharedSecrets accessor + static { + LiteProtoSubjectAccess.setAccessor(new LiteProtoSubjectAccess.Accessor() { + @Override + public String getCustomStringRepresentation(LiteProtoSubject subject) { + return subject.actualCustomStringRepresentationForProtoPackageMembersToCall(); + } + }); + } + /** * Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert * things about Lite Protobuf properties. diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoTruth.java similarity index 97% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoTruth.java index 2166e713b..fe2c57c6f 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoTruth.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.liteproto; import static com.google.common.truth.Truth.assertAbout; diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java similarity index 97% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java index c6880f9b2..af81e91e1 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.liteproto; import static com.google.common.base.Strings.lenientFormat; diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java new file mode 100644 index 000000000..8e13cf1f0 --- /dev/null +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.truth.extensions.liteproto.internal; + +import com.google.common.truth.extensions.liteproto.LiteProtoSubject; + +/** + * Provides access to package-private methods in LiteProtoSubject for use by + * other Truth extensions. + * + *

This is an internal API and should not be used by client code. + * This class may be removed or changed at any time without notice. + */ +public final class LiteProtoSubjectAccess { + + /** + * Accessor interface for LiteProtoSubject internal methods. + * Set by LiteProtoSubject during class initialization. + */ + public interface Accessor { + String getCustomStringRepresentation(LiteProtoSubject subject); + } + + private static Accessor accessor; + + /** + * Sets the accessor. This is called by LiteProtoSubject during class initialization. + * + * @param accessor the accessor implementation + * @throws IllegalStateException if the accessor is already set + */ + public static void setAccessor(Accessor accessor) { + if (LiteProtoSubjectAccess.accessor != null) { + throw new IllegalStateException("Accessor already set"); + } + LiteProtoSubjectAccess.accessor = accessor; + } + + /** + * Gets the custom string representation for the given LiteProtoSubject. + * + * @param subject the LiteProtoSubject instance + * @return the custom string representation + * @throws IllegalStateException if no accessor has been set + */ + public static String getCustomStringRepresentation(LiteProtoSubject subject) { + if (accessor == null) { + throw new IllegalStateException("No accessor set"); + } + return accessor.getCustomStringRepresentation(subject); + } + + private LiteProtoSubjectAccess() {} +} \ No newline at end of file diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java deleted file mode 100644 index a76e2e234..000000000 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2016 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Custom subjects for testing Protocol - * Buffer instances. - * - *

This package is a part of the open-source Truth - * project. - */ -@CheckReturnValue -package com.google.common.truth.extensions.proto; - -import com.google.errorprone.annotations.CheckReturnValue; diff --git a/extensions/liteproto/src/main/java9/module-info.java b/extensions/liteproto/src/main/java/module-info.java similarity index 71% rename from extensions/liteproto/src/main/java9/module-info.java rename to extensions/liteproto/src/main/java/module-info.java index 2d0c30da4..fa2f65297 100644 --- a/extensions/liteproto/src/main/java9/module-info.java +++ b/extensions/liteproto/src/main/java/module-info.java @@ -17,10 +17,14 @@ module com.google.truth.extensions.liteproto { requires com.google.truth; requires com.google.common; + requires java.compiler; requires static org.jspecify; requires static com.google.errorprone.annotations; - requires static com.google.protobuf.lite; + requires static protobuf.lite; + requires static auto.value.annotations; + requires static com.google.j2objc.annotations; - exports com.google.common.truth.extensions.proto; + exports com.google.common.truth.extensions.liteproto; + exports com.google.common.truth.extensions.liteproto.internal to com.google.truth.extensions.proto; } \ No newline at end of file diff --git a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/liteproto/test/LiteProtoSubjectTest.java similarity index 93% rename from extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java rename to extensions/liteproto/src/test/java/com/google/common/truth/extensions/liteproto/test/LiteProtoSubjectTest.java index 205867d67..1f7dc1a8a 100644 --- a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java +++ b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/liteproto/test/LiteProtoSubjectTest.java @@ -13,19 +13,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.liteproto.test; import static com.google.common.truth.ExpectFailure.assertThat; import static com.google.common.truth.ExpectFailure.expectFailureAbout; -import static com.google.common.truth.extensions.proto.LiteProtoTruth.assertThat; -import static com.google.common.truth.extensions.proto.LiteProtoTruth.liteProtos; +import static com.google.common.truth.extensions.liteproto.LiteProtoTruth.assertThat; +import static com.google.common.truth.extensions.liteproto.LiteProtoTruth.liteProtos; import com.google.auto.value.AutoValue; +import com.google.common.truth.extensions.liteproto.test.proto.OtherTestMessageLite2; +import com.google.common.truth.extensions.liteproto.test.proto.OtherTestMessageLite3; +import com.google.common.truth.extensions.liteproto.test.proto.TestMessageLite2; +import com.google.common.truth.extensions.liteproto.test.proto.TestMessageLite2WithRequiredFields; +import com.google.common.truth.extensions.liteproto.test.proto.TestMessageLite3; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.truth.Expect; import com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback; import com.google.common.truth.Subject; +import com.google.common.truth.extensions.liteproto.LiteProtoSubject; import com.google.protobuf.MessageLite; import java.util.Arrays; import java.util.Collection; @@ -134,7 +140,7 @@ public LiteProtoSubjectTest(@SuppressWarnings("unused") String name, Config conf } private LiteProtoSubject expectThat(@Nullable MessageLite m) { - return expect.about(LiteProtoTruth.liteProtos()).that(m); + return expect.about(liteProtos()).that(m); } private Subject expectThat(@Nullable Object o) { diff --git a/extensions/pom.xml b/extensions/pom.xml index a3af92922..45519c462 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -7,7 +7,7 @@ com.google.truth truth-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT com.google.truth.extensions truth-extensions-parent @@ -23,4 +23,5 @@ liteproto proto + diff --git a/extensions/proto/pom.xml b/extensions/proto/pom.xml index 09596e372..b582c5bc8 100644 --- a/extensions/proto/pom.xml +++ b/extensions/proto/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-proto-extension Truth Extension for Protocol Buffers @@ -98,21 +98,6 @@ - - - compile-java9 - - compile - - - 9 - - ${project.basedir}/src/main/java9 - - true - - - maven-jar-plugin diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java index 5d2218373..8649f84d6 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java @@ -23,6 +23,8 @@ import static com.google.common.truth.extensions.proto.FieldScopeUtil.asList; import com.google.common.truth.FailureMetadata; +import com.google.common.truth.extensions.liteproto.LiteProtoSubject; +import com.google.common.truth.extensions.liteproto.internal.LiteProtoSubjectAccess; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; @@ -677,7 +679,7 @@ public void hasAllRequiredFields() { failWithoutActual( simpleFact("expected to have all required fields set"), fact("but was missing", actual.findInitializationErrors()), - fact("proto was", actualCustomStringRepresentationForProtoPackageMembersToCall())); + fact("proto was", LiteProtoSubjectAccess.getCustomStringRepresentation(this))); } } diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java index e7015c189..27bf91743 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java @@ -19,6 +19,8 @@ import com.google.common.collect.Multimap; import com.google.common.truth.CustomSubjectBuilder; import com.google.common.truth.FailureMetadata; +import com.google.common.truth.extensions.liteproto.LiteProtoSubject; +import com.google.common.truth.extensions.liteproto.LiteProtoTruth; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; @@ -51,7 +53,7 @@ private ProtoSubjectBuilder(FailureMetadata failureMetadata) { } public LiteProtoSubject that(@Nullable MessageLite messageLite) { - return new LiteProtoSubject(metadata(), messageLite); + return LiteProtoTruth.liteProtos().createSubject(metadata(), messageLite); } public ProtoSubject that(@Nullable Message message) { diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java index 7daa0d1dc..fb9ade802 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java @@ -24,6 +24,7 @@ import com.google.common.truth.MapSubject; import com.google.common.truth.MultimapSubject; import com.google.common.truth.StandardSubjectBuilder; +import com.google.common.truth.extensions.liteproto.LiteProtoSubject; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; diff --git a/extensions/proto/src/main/java9/module-info.java b/extensions/proto/src/main/java/module-info.java similarity index 92% rename from extensions/proto/src/main/java9/module-info.java rename to extensions/proto/src/main/java/module-info.java index 756296e13..2526a3621 100644 --- a/extensions/proto/src/main/java9/module-info.java +++ b/extensions/proto/src/main/java/module-info.java @@ -19,9 +19,11 @@ requires com.google.truth.extensions.liteproto; requires com.google.common; requires com.google.protobuf; + requires java.compiler; requires static org.jspecify; requires static com.google.errorprone.annotations; + requires static auto.value.annotations; exports com.google.common.truth.extensions.proto; } \ No newline at end of file diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/FieldScopesTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/FieldScopesTest.java index 077d647f2..8df762678 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/FieldScopesTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; @@ -23,6 +23,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; +import com.google.common.truth.extensions.proto.FieldScope; +import com.google.common.truth.extensions.proto.FieldScopes; import com.google.protobuf.ByteString; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.InvalidProtocolBufferException; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/IterableOfProtosSubjectTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/IterableOfProtosSubjectTest.java index 9d2b52edb..475c27d59 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/IterableOfProtosSubjectTest.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import static java.util.Comparator.comparing; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; +import com.google.common.truth.extensions.proto.FieldScopes; +import com.google.common.truth.extensions.proto.IterableOfProtosSubject; import com.google.protobuf.Message; import java.util.Collection; import java.util.Comparator; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MapWithProtoValuesSubjectTest.java similarity index 97% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MapWithProtoValuesSubjectTest.java index 1bdf2f34d..807d7840c 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MapWithProtoValuesSubjectTest.java @@ -14,10 +14,12 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import com.google.common.collect.ImmutableMap; import com.google.common.truth.MapSubject; +import com.google.common.truth.extensions.proto.MapWithProtoValuesFluentAssertion; +import com.google.common.truth.extensions.proto.MapWithProtoValuesSubject; import com.google.protobuf.Message; import java.util.Collection; import org.junit.Test; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultiExpectFailure.java similarity index 97% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultiExpectFailure.java index d1ae1dd5c..a8ad20f87 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultiExpectFailure.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import com.google.common.base.Preconditions; import com.google.common.truth.ExpectFailure; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultimapWithProtoValuesSubjectTest.java similarity index 98% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultimapWithProtoValuesSubjectTest.java index f7570fdc6..0e74692c8 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultimapWithProtoValuesSubjectTest.java @@ -14,11 +14,13 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.truth.MultimapSubject; +import com.google.common.truth.extensions.proto.MultimapWithProtoValuesFluentAssertion; +import com.google.common.truth.extensions.proto.MultimapWithProtoValuesSubject; import com.google.protobuf.Message; import java.util.Collection; import org.junit.Test; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/OverloadResolutionTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/OverloadResolutionTest.java index adc4ee5ae..518d2994d 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/OverloadResolutionTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.Truth.assertThat; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTest.java index b9f8ffcbe..a502f68e1 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertThat; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTestBase.java similarity index 95% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTestBase.java index e686a4f4a..023119308 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTestBase.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto; +package com.google.common.truth.extensions.proto.test; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.truth.Truth.assertThat; @@ -32,6 +32,12 @@ import com.google.common.truth.ExpectFailure; import com.google.common.truth.Subject; import com.google.common.truth.TruthFailureSubject; +import com.google.common.truth.extensions.proto.IterableOfProtosSubject; +import com.google.common.truth.extensions.proto.MapWithProtoValuesSubject; +import com.google.common.truth.extensions.proto.MultimapWithProtoValuesSubject; +import com.google.common.truth.extensions.proto.ProtoSubject; +import com.google.common.truth.extensions.proto.ProtoSubjectBuilder; +import com.google.common.truth.extensions.proto.ProtoTruth; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.InvalidProtocolBufferException; diff --git a/extensions/re2j/pom.xml b/extensions/re2j/pom.xml index b9b2884b0..0a9b83970 100644 --- a/extensions/re2j/pom.xml +++ b/extensions/re2j/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-re2j-extension Truth Extension for RE2J @@ -40,21 +40,6 @@ maven-compiler-plugin - - - compile-java9 - - compile - - - 9 - - ${project.basedir}/src/main/java9 - - true - - - maven-jar-plugin diff --git a/extensions/re2j/src/main/java9/module-info.java b/extensions/re2j/src/main/java/module-info.java similarity index 93% rename from extensions/re2j/src/main/java9/module-info.java rename to extensions/re2j/src/main/java/module-info.java index 2c1a6e7fc..1fd418254 100644 --- a/extensions/re2j/src/main/java9/module-info.java +++ b/extensions/re2j/src/main/java/module-info.java @@ -16,7 +16,9 @@ module com.google.truth.extensions.re2j { requires com.google.truth; - requires com.google.re2j; + requires re2j; + + requires static org.jspecify; exports com.google.common.truth.extensions.re2j; } \ No newline at end of file diff --git a/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java b/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/test/Re2jSubjectsTest.java similarity index 97% rename from extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java rename to extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/test/Re2jSubjectsTest.java index 8c5949d2e..176a67b38 100644 --- a/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java +++ b/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/test/Re2jSubjectsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.re2j; +package com.google.common.truth.extensions.re2j.test; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.extensions.re2j.Re2jSubjects.re2jString; diff --git a/pom.xml b/pom.xml index 6eaf74b2e..2ae364d23 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.google.truth truth-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT pom Truth (Parent) @@ -249,6 +249,7 @@ -Xdoclint:-html ${conditionalJavadoc9PlusOptions} + true Truth ${project.version} Truth ${project.version} true @@ -313,6 +314,20 @@ 1.8 true + + + default-compile + + 9 + + + + default-testCompile + + 9 + + + maven-source-plugin From 2659b4fa1a035605e3196c2d47c34abbe1a5115a Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Mon, 22 Sep 2025 15:47:16 -0400 Subject: [PATCH 03/21] Update copyright year to 2025 for newly created file --- core/src/main/java/module-info.java | 2 +- .../extensions/liteproto/internal/LiteProtoSubjectAccess.java | 2 +- extensions/liteproto/src/main/java/module-info.java | 2 +- extensions/proto/src/main/java/module-info.java | 2 +- extensions/re2j/src/main/java/module-info.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index 98e7fe254..841238e26 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Google, Inc. + * Copyright (c) 2025 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java index 8e13cf1f0..047d6d0d6 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Google, Inc. + * Copyright (c) 2025 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/extensions/liteproto/src/main/java/module-info.java b/extensions/liteproto/src/main/java/module-info.java index fa2f65297..9bb27b891 100644 --- a/extensions/liteproto/src/main/java/module-info.java +++ b/extensions/liteproto/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Google, Inc. + * Copyright (c) 2025 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/extensions/proto/src/main/java/module-info.java b/extensions/proto/src/main/java/module-info.java index 2526a3621..7581473ef 100644 --- a/extensions/proto/src/main/java/module-info.java +++ b/extensions/proto/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Google, Inc. + * Copyright (c) 2025 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/extensions/re2j/src/main/java/module-info.java b/extensions/re2j/src/main/java/module-info.java index 1fd418254..e386a8329 100644 --- a/extensions/re2j/src/main/java/module-info.java +++ b/extensions/re2j/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Google, Inc. + * Copyright (c) 2025 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From b78c9a044c8cb8f343053daafbcd341453ee26ce Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Mon, 22 Sep 2025 18:03:18 -0400 Subject: [PATCH 04/21] Make module-info compilation CI-safe - Separate CI build (JDK 11) from test phases (JDK 8/11/17) - Centralize module-info compilation config in parent POM - Use two-stage compilation: module-info with release=9, base code with Java 8 - Maintain JDK 8 runtime compatibility via multi-release JAR structure --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++---------- extensions/pom.xml | 1 - pom.xml | 10 ++++++-- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b1eed4c6..cdf5f5c9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,8 @@ on: - master jobs: - test: - name: "JDK ${{ matrix.java }}" - strategy: - matrix: - java: [ 8, 11 ] + build: + name: 'Build with JDK 11' runs-on: ubuntu-latest steps: # Cancel any previous runs for the same branch that are still running. @@ -23,25 +20,54 @@ jobs: access_token: ${{ github.token }} - name: 'Check out repository' uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - - name: 'Set up JDK ${{ matrix.java }}' + - name: 'Set up JDK 11 for compilation' uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 with: - java-version: ${{ matrix.java }} + java-version: 11 distribution: 'zulu' cache: 'maven' - name: 'Install' shell: bash run: mvn -B -P!standard-with-extra-repos install -U -DskipTests=true - - name: 'Test' - shell: bash - run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true - name: 'Javadoc Test Run' shell: bash run: mvn -B -P!standard-with-extra-repos javadoc:aggregate -U + - name: 'Upload build artifacts' + uses: actions/upload-artifact@v3 + with: + name: truth-jars + path: | + **/target/*.jar + !**/target/*-sources.jar + !**/target/*-javadoc.jar + + test: + name: "Test with JDK ${{ matrix.java }}" + needs: build + strategy: + matrix: + java: [ 8, 11, 17 ] + runs-on: ubuntu-latest + steps: + - name: 'Check out repository' + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - name: 'Set up JDK ${{ matrix.java }} for testing' + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 + with: + java-version: ${{ matrix.java }} + distribution: 'zulu' + cache: 'maven' + - name: 'Download build artifacts' + uses: actions/download-artifact@v3 + with: + name: truth-jars + - name: 'Test' + shell: bash + run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true publish_snapshot: name: 'Publish snapshot' - needs: test + needs: [build, test] if: github.event_name == 'push' && github.repository == 'google/truth' runs-on: ubuntu-latest steps: @@ -66,7 +92,7 @@ jobs: permissions: contents: write name: 'Generate latest docs' - needs: test + needs: [build, test] if: github.event_name == 'push' && github.repository == 'google/truth' runs-on: ubuntu-latest steps: diff --git a/extensions/pom.xml b/extensions/pom.xml index 45519c462..f5549cf66 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -23,5 +23,4 @@ liteproto proto - diff --git a/pom.xml b/pom.xml index 2ae364d23..60a08b217 100644 --- a/pom.xml +++ b/pom.xml @@ -322,9 +322,15 @@ - default-testCompile + base-compile + + compile + - 9 + + module-info.java + **/super/**/*.java + From 8aead27a37c4886a39fc60349e6206ba908fdbd3 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Mon, 22 Sep 2025 18:26:14 -0400 Subject: [PATCH 05/21] Restore package documentation for proto extensions - Add package-info.java for com.google.common.truth.extensions.proto - Add package-info.java for com.google.common.truth.extensions.liteproto - Clarify differences between full protobuf and protobuf-lite extensions - Maintain proper Javadoc coverage for exported packages These were inadvertently removed during JPMS package separation. --- .../extensions/liteproto/package-info.java | 31 ++++++++++++++++++ .../truth/extensions/proto/package-info.java | 32 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java create mode 100644 extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java new file mode 100644 index 000000000..95805545b --- /dev/null +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Custom subjects for testing Protocol + * Buffer Lite instances. + * + *

This package provides Truth extensions specifically for protobuf-lite, which is a + * lighter-weight version of Protocol Buffers with reduced functionality but smaller + * binary size and better performance for resource-constrained environments. + * + *

This package is a part of the open-source Truth + * project. + */ +@CheckReturnValue +package com.google.common.truth.extensions.liteproto; + +import com.google.errorprone.annotations.CheckReturnValue; \ No newline at end of file diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java new file mode 100644 index 000000000..7bc53dc84 --- /dev/null +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Custom subjects for testing Protocol + * Buffer instances using the full protobuf library. + * + *

This package provides Truth extensions for full Protocol Buffers (protobuf-java), which + * includes advanced features like reflection, text format, and comprehensive message manipulation. + * For lighter-weight protobuf-lite support, see + * {@link com.google.common.truth.extensions.liteproto}. + * + *

This package is a part of the open-source Truth + * project. + */ +@CheckReturnValue +package com.google.common.truth.extensions.proto; + +import com.google.errorprone.annotations.CheckReturnValue; \ No newline at end of file From 5760bfd2fb520b59e05bf3096fe7b6c5fbb152d0 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Wed, 24 Sep 2025 17:36:24 -0400 Subject: [PATCH 06/21] Update core/src/main/java/module-info.java Make the JUnit 4 dependency optional Co-authored-by: Chris Povirk --- core/src/main/java/module-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index 841238e26..2e738a453 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -16,7 +16,7 @@ module com.google.truth { requires com.google.common; - requires junit; + requires static junit; requires java.compiler; requires static org.jspecify; From 6585167c15ba833d187038f8a85d9654e3bb9ca3 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 11:53:28 -0400 Subject: [PATCH 07/21] Fix module-info setup and GWT compatibility issues --- core/pom.xml | 7 -- .../src/main/{java => java9}/module-info.java | 0 .../CorrespondenceExceptionStoreTest.java | 5 +- .../common/truth/extension/Employee.java | 44 --------- .../truth/extension/EmployeeSubject.java | 97 ------------------- .../truth/extension/EmployeeSubjectTest.java | 64 ------------ .../truth/extension/FakeHrDatabase.java | 58 ----------- .../truth/extension/FakeHrDatabaseTest.java | 77 --------------- .../common/truth/extension/HrDatabase.java | 35 ------- extensions/liteproto/pom.xml | 12 +-- .../internal/LiteProtoSubjectAccess.java | 68 ------------- .../extensions/liteproto/package-info.java | 31 ------ .../LiteProtoSubject.java | 48 +++------ .../{liteproto => proto}/LiteProtoTruth.java | 4 +- .../{liteproto => proto}/Platform.java | 2 +- .../truth/extensions/proto/package-info.java | 9 +- .../liteproto/src/main/java/module-info.java | 30 ------ .../test => proto}/LiteProtoSubjectTest.java | 15 +-- extensions/proto/pom.xml | 12 +-- .../truth/extensions/proto/DiffResult.java | 10 +- .../extensions/proto/FieldScopeLogic.java | 14 +-- .../proto/FluentEqualityConfig.java | 2 - .../truth/extensions/proto/ProtoSubject.java | 4 +- .../extensions/proto/ProtoSubjectBuilder.java | 4 +- .../truth/extensions/proto/ProtoTruth.java | 1 - .../proto/src/main/java/module-info.java | 29 ------ .../proto/{test => }/FieldScopesTest.java | 4 +- .../IterableOfProtosSubjectTest.java | 4 +- .../MapWithProtoValuesSubjectTest.java | 4 +- .../proto/{test => }/MultiExpectFailure.java | 2 +- .../MultimapWithProtoValuesSubjectTest.java | 4 +- .../{test => }/OverloadResolutionTest.java | 2 +- .../proto/{test => }/ProtoSubjectTest.java | 2 +- .../{test => }/ProtoSubjectTestBase.java | 8 +- extensions/re2j/pom.xml | 15 +-- .../re2j/src/main/java/module-info.java | 24 ----- .../re2j/{test => }/Re2jSubjectsTest.java | 2 +- pom.xml | 14 +-- 38 files changed, 61 insertions(+), 706 deletions(-) rename core/src/main/{java => java9}/module-info.java (100%) delete mode 100644 core/src/test/java/com/google/common/truth/extension/Employee.java delete mode 100644 core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java delete mode 100644 core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java delete mode 100644 core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java delete mode 100644 core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java delete mode 100644 core/src/test/java/com/google/common/truth/extension/HrDatabase.java delete mode 100644 extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java delete mode 100644 extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java rename extensions/liteproto/src/main/java/com/google/common/truth/extensions/{liteproto => proto}/LiteProtoSubject.java (81%) rename extensions/liteproto/src/main/java/com/google/common/truth/extensions/{liteproto => proto}/LiteProtoTruth.java (97%) rename extensions/liteproto/src/main/java/com/google/common/truth/extensions/{liteproto => proto}/Platform.java (97%) rename extensions/{proto => liteproto}/src/main/java/com/google/common/truth/extensions/proto/package-info.java (67%) delete mode 100644 extensions/liteproto/src/main/java/module-info.java rename extensions/liteproto/src/test/java/com/google/common/truth/extensions/{liteproto/test => proto}/LiteProtoSubjectTest.java (93%) delete mode 100644 extensions/proto/src/main/java/module-info.java rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/FieldScopesTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/IterableOfProtosSubjectTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/MapWithProtoValuesSubjectTest.java (97%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/MultiExpectFailure.java (97%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/MultimapWithProtoValuesSubjectTest.java (98%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/OverloadResolutionTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/ProtoSubjectTest.java (99%) rename extensions/proto/src/test/java/com/google/common/truth/extensions/proto/{test => }/ProtoSubjectTestBase.java (95%) delete mode 100644 extensions/re2j/src/main/java/module-info.java rename extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/{test => }/Re2jSubjectsTest.java (97%) diff --git a/core/pom.xml b/core/pom.xml index 1bdd43c0d..d5469b68c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -110,13 +110,6 @@ maven-jar-plugin - - - - true - - - attach-gwt-sources diff --git a/core/src/main/java/module-info.java b/core/src/main/java9/module-info.java similarity index 100% rename from core/src/main/java/module-info.java rename to core/src/main/java9/module-info.java diff --git a/core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java b/core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java index 6b18bacb7..feb25fbaa 100644 --- a/core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java +++ b/core/src/test/java/com/google/common/truth/CorrespondenceExceptionStoreTest.java @@ -101,8 +101,9 @@ private static void assertExpectedFacts(Iterable facts, String expectedFir + "com.google.common.truth.TestCorrespondences\\$NullPointerExceptionFromWithin10Of" // some whitespace: + "\\s+" - // the start of a stack trace, with the correct class: - + "at com\\.google\\.common\\.truth\\.TestCorrespondences" + // the start of a stack trace, optionally with the module name and version, + // and the correct class: + + "at (?:[^/]+/)?com\\.google\\.common\\.truth\\.TestCorrespondences" // the rest of the stack trace, which we don't validate (and may contain newlines): + "(.|\\n)*" // the expected separator diff --git a/core/src/test/java/com/google/common/truth/extension/Employee.java b/core/src/test/java/com/google/common/truth/extension/Employee.java deleted file mode 100644 index 8cc2cf448..000000000 --- a/core/src/test/java/com/google/common/truth/extension/Employee.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.truth.extension; - -import com.google.auto.value.AutoValue; - -/** Represents an employee. */ -@AutoValue -public abstract class Employee { - public static Employee create( - String username, long id, String name, Location location, boolean isCeo) { - return new AutoValue_Employee(username, id, name, location, isCeo); - } - - abstract String username(); - - abstract long id(); - - abstract String name(); - - abstract Location location(); - - abstract boolean isCeo(); - - public enum Location { - MTV, - PIT, - CHI, - NYC - } -} diff --git a/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java b/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java deleted file mode 100644 index ba3acd76f..000000000 --- a/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.truth.extension; - -import static com.google.common.truth.Fact.simpleFact; -import static com.google.common.truth.Truth.assertAbout; - -import com.google.common.truth.ComparableSubject; -import com.google.common.truth.FailureMetadata; -import com.google.common.truth.LongSubject; -import com.google.common.truth.StringSubject; -import com.google.common.truth.Subject; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - -/** A Truth subject for {@link Employee}. */ -@NullMarked -public final class EmployeeSubject extends Subject { - - // User-defined entry point - public static EmployeeSubject assertThat(@Nullable Employee employee) { - return assertAbout(employees()).that(employee); - } - - // Static method for getting the subject factory (for use with assertAbout()) - public static Factory employees() { - return EmployeeSubject::new; - } - - private final @Nullable Employee actual; - - private EmployeeSubject(FailureMetadata failureMetadata, @Nullable Employee subject) { - super(failureMetadata, subject); - this.actual = subject; - } - - // User-defined test assertion SPI below this point - - public void hasName(String name) { - name().isEqualTo(name); - } - - public void hasUsername(String username) { - username().isEqualTo(username); - } - - public void hasId(long id) { - id().isEqualTo(id); - } - - public void hasLocation(Employee.Location location) { - location().isEqualTo(location); - } - - public void isCeo() { - if (!actual.isCeo()) { - failWithActual(simpleFact("expected to be CEO")); - } - } - - public void isNotCeo() { - if (actual.isCeo()) { - failWithActual(simpleFact("expected not to be CEO")); - } - } - - // Chained subjects methods below this point - - public StringSubject name() { - return check("name()").that(actual.name()); - } - - public StringSubject username() { - return check("username()").that(actual.username()); - } - - public LongSubject id() { - return check("id()").that(actual.id()); - } - - public ComparableSubject location() { - return check("location()").that(actual.location()); - } -} diff --git a/core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java b/core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java deleted file mode 100644 index a2cc6b2e9..000000000 --- a/core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.truth.extension; - -import static com.google.common.truth.ExpectFailure.assertThat; -import static com.google.common.truth.ExpectFailure.expectFailureAbout; -import static com.google.common.truth.extension.EmployeeSubject.assertThat; -import static com.google.common.truth.extension.EmployeeSubject.employees; - -import com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback; -import com.google.common.truth.extension.Employee.Location; -import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public final class EmployeeSubjectTest { - - // Note: not real employee IDs :-) - - private static final Employee KURT = - Employee.create("kak", 37802, "Kurt Alfred Kluever", Location.NYC, /* isCeo= */ false); - - @Test - public void id() { - assertThat(KURT).hasId(37802); - expectFailure(whenTesting -> whenTesting.that(KURT).hasId(12345)); - } - - @Test - public void name() { - assertThat(KURT).hasName("Kurt Alfred Kluever"); - expectFailure(whenTesting -> whenTesting.that(KURT).hasName("Sundar Pichai")); - } - - @Test - public void username() { - assertThat(KURT).hasUsername("kak"); - // Here's an example of asserting on the failure message. - // Note that it uses the assertThat method from ExpectFailure. - AssertionError e = expectFailure(whenTesting -> whenTesting.that(KURT).hasUsername("sundar")); - assertThat(e).factValue("value of").isEqualTo("employee.username()"); - } - - @CanIgnoreReturnValue - private static AssertionError expectFailure( - SimpleSubjectBuilderCallback callback) { - return expectFailureAbout(employees(), callback); - } -} diff --git a/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java b/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java deleted file mode 100644 index 78236b495..000000000 --- a/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.truth.extension; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.collect.ImmutableSet; -import com.google.common.truth.extension.Employee.Location; -import java.util.HashMap; -import java.util.Map; - -/** In-memory implementation of {@link HrDatabase}, suitable for testing. */ -public final class FakeHrDatabase implements HrDatabase { - private final Map employees = new HashMap<>(); - - public void put(Employee employee) { - employees.put(employee.id(), employee); - } - - @Override - public Employee get(long id) { - return employees.get(id); - } - - @Override - public void relocate(long id, Location location) { - checkNotNull(location); - Employee old = get(id); - checkState(old != null, "No employee found with ID %s", id); - employees.put(id, Employee.create(old.username(), old.id(), old.name(), location, old.isCeo())); - } - - @Override - public ImmutableSet getByLocation(Location location) { - checkNotNull(location); - ImmutableSet.Builder result = ImmutableSet.builder(); - for (Employee employee : employees.values()) { - if (employee.location() == location) { - result.add(employee); - } - } - return result.build(); - } -} diff --git a/core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java b/core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java deleted file mode 100644 index 095d899e0..000000000 --- a/core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.truth.extension; - -import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.extension.EmployeeSubject.assertThat; - -import com.google.common.truth.extension.Employee.Location; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public final class FakeHrDatabaseTest { - - // Note: not real employee IDs :-) - - private static final Employee KURT = - Employee.create("kak", 37802, "Kurt Alfred Kluever", Location.NYC, /* isCeo= */ false); - - private static final Employee SUNDAR = - Employee.create("sundar", 5243, "Sundar Pichai", Location.MTV, /* isCeo= */ true); - - // Notice that we static import two different assertThat methods. - - // These assertions use the EmployeeSubject.assertThat(Employee) overload and the - // EmployeeSubject-specific methods. - - @Test - public void relocatePresent() { - FakeHrDatabase db = new FakeHrDatabase(); - db.put(KURT); - db.relocate(KURT.id(), Location.MTV); - Employee movedKurt = db.get(KURT.id()); - assertThat(movedKurt).hasLocation(Location.MTV); - assertThat(movedKurt).hasUsername("kak"); - } - - // These assertions use the EmployeeSubject.assertThat(Employee) overload but the assertion - // methods inherited from Subject. - - @Test - public void getPresent() { - FakeHrDatabase db = new FakeHrDatabase(); - db.put(KURT); - assertThat(db.get(KURT.id())).isEqualTo(KURT); - } - - @Test - public void getAbsent() { - FakeHrDatabase db = new FakeHrDatabase(); - db.put(KURT); - assertThat(db.get(SUNDAR.id())).isNull(); - } - - // These assertions use Truth.assertThat() overloads - - @Test - public void getByLocation() { - FakeHrDatabase db = new FakeHrDatabase(); - db.put(KURT); - assertThat(db.getByLocation(Location.NYC)).containsExactly(KURT); - } -} diff --git a/core/src/test/java/com/google/common/truth/extension/HrDatabase.java b/core/src/test/java/com/google/common/truth/extension/HrDatabase.java deleted file mode 100644 index 50a6a1dc7..000000000 --- a/core/src/test/java/com/google/common/truth/extension/HrDatabase.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2017 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.truth.extension; - -import com.google.common.collect.ImmutableSet; -import com.google.common.truth.extension.Employee.Location; - -/** - * Service for accessing human resources data. - * - *

This class (and all the classes in this package) are just a demonstration of how to write and - * use a custom Truth subject. The only implementation of {@code HrDatabase} is {@link - * FakeHrDatabase}, and the only place we use it is in its own test, whose real purpose is to - * demonstrate how to use a custom Truth subject. - */ -public interface HrDatabase { - Employee get(long id); - - void relocate(long id, Location location); - - ImmutableSet getByLocation(Location location); -} diff --git a/extensions/liteproto/pom.xml b/extensions/liteproto/pom.xml index 09a51b6b9..a70faa5d8 100644 --- a/extensions/liteproto/pom.xml +++ b/extensions/liteproto/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - 999.0.0-SNAPSHOT + HEAD-SNAPSHOT truth-liteproto-extension Truth Extension for Lite Protocol Buffers @@ -97,16 +97,6 @@ - - maven-jar-plugin - - - - true - - - - diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java deleted file mode 100644 index 047d6d0d6..000000000 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2025 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.common.truth.extensions.liteproto.internal; - -import com.google.common.truth.extensions.liteproto.LiteProtoSubject; - -/** - * Provides access to package-private methods in LiteProtoSubject for use by - * other Truth extensions. - * - *

This is an internal API and should not be used by client code. - * This class may be removed or changed at any time without notice. - */ -public final class LiteProtoSubjectAccess { - - /** - * Accessor interface for LiteProtoSubject internal methods. - * Set by LiteProtoSubject during class initialization. - */ - public interface Accessor { - String getCustomStringRepresentation(LiteProtoSubject subject); - } - - private static Accessor accessor; - - /** - * Sets the accessor. This is called by LiteProtoSubject during class initialization. - * - * @param accessor the accessor implementation - * @throws IllegalStateException if the accessor is already set - */ - public static void setAccessor(Accessor accessor) { - if (LiteProtoSubjectAccess.accessor != null) { - throw new IllegalStateException("Accessor already set"); - } - LiteProtoSubjectAccess.accessor = accessor; - } - - /** - * Gets the custom string representation for the given LiteProtoSubject. - * - * @param subject the LiteProtoSubject instance - * @return the custom string representation - * @throws IllegalStateException if no accessor has been set - */ - public static String getCustomStringRepresentation(LiteProtoSubject subject) { - if (accessor == null) { - throw new IllegalStateException("No accessor set"); - } - return accessor.getCustomStringRepresentation(subject); - } - - private LiteProtoSubjectAccess() {} -} \ No newline at end of file diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java deleted file mode 100644 index 95805545b..000000000 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/package-info.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2016 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Custom subjects for testing Protocol - * Buffer Lite instances. - * - *

This package provides Truth extensions specifically for protobuf-lite, which is a - * lighter-weight version of Protocol Buffers with reduced functionality but smaller - * binary size and better performance for resource-constrained environments. - * - *

This package is a part of the open-source Truth - * project. - */ -@CheckReturnValue -package com.google.common.truth.extensions.liteproto; - -import com.google.errorprone.annotations.CheckReturnValue; \ No newline at end of file diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoSubject.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java similarity index 81% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoSubject.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java index c10ecf795..17544c705 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoSubject.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java @@ -14,19 +14,18 @@ * limitations under the License. */ -package com.google.common.truth.extensions.liteproto; +package com.google.common.truth.extensions.proto; import static com.google.common.base.Strings.lenientFormat; import static com.google.common.truth.Fact.fact; import static com.google.common.truth.Fact.simpleFact; -import static com.google.common.truth.extensions.liteproto.Platform.getTrimmedToString; +import static com.google.common.truth.extensions.proto.Platform.getTrimmedToString; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import com.google.common.truth.FailureMetadata; import com.google.common.truth.IntegerSubject; import com.google.common.truth.Subject; -import com.google.common.truth.extensions.liteproto.internal.LiteProtoSubjectAccess; import com.google.errorprone.annotations.CheckReturnValue; import com.google.j2objc.annotations.J2ObjCIncompatible; import com.google.protobuf.MessageLite; @@ -45,16 +44,6 @@ @NullMarked public class LiteProtoSubject extends Subject { - // Static initializer to register SharedSecrets accessor - static { - LiteProtoSubjectAccess.setAccessor(new LiteProtoSubjectAccess.Accessor() { - @Override - public String getCustomStringRepresentation(LiteProtoSubject subject) { - return subject.actualCustomStringRepresentationForProtoPackageMembersToCall(); - } - }); - } - /** * Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert * things about Lite Protobuf properties. @@ -135,31 +124,23 @@ public void isEqualTo(@Nullable Object expected) { } /** - * @deprecated A Builder can never compare equal to a MessageLite instance. Use {@code build()}, - * or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or, - * if you are passing {@code null}, use {@link #isNull()}. + * DO NOT CALL THIS METHOD!. A {@link MessageLite.Builder} will never compare equal to a + * MessageLite instance. Use {@code build()}, or {@code buildPartial()} on the argument to get a + * MessageLite for comparison instead. Or, if you are passing {@code null}, use {@link #isNull()}. */ /* - * TODO(cpovirk): Consider @DoNotCall -- or probably some other static analysis, given the problem - * discussed in the rest of this comment. - * - * The problem: isEqualTo(null) resolves to this overload (since this overload is more specific - * than isEqualTo(Object)), so @DoNotCall would break all assertions of that form. + * NOTE: we don't actually mark this as deprecated (or @DoNotCall) because isEqualTo(null) + * resolves to this overload (since this overload is more specific than isEqualTo(Object)). * * To address that, we could try also adding something like ` void isEqualTo(NullT)` and hoping that isEqualTo(null) would resolve to * that instead. That would also have the benefit of making isEqualTo(null) not produce a * deprecation warning (though of course people "should" use isNull(): b/17294077). But yuck. * - * Given the null issue, maybe we should never have added this overload in the first place, - * instead adding static analysis specific to MessageLite-MessageLite.Builder comparisons. (Sadly, - * we can't remove it now without breaking binary compatibility.) - * - * Still, we could add static analysis to produce a compile error for isEqualTo(Builder) this even - * today, even without using @DoNotCall. And then we could consider removing @Deprecated to stop - * spamming the people who call isEqualTo(null). + * Given the null issue, maybe we should never have added this overload in the first place! + * In cl/839267698, we added static analysis to MessageLite-MessageLite.Builder comparisons. + * However, we cannot remove this method without breaking binary compatibility. */ - @Deprecated public void isEqualTo(MessageLite.@Nullable Builder builder) { isEqualTo((Object) builder); } @@ -186,12 +167,11 @@ public void isNotEqualTo(@Nullable Object expected) { } /** - * @deprecated A Builder will never compare equal to a MessageLite instance. Use {@code build()}, - * or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or, - * if you are passing {@code null}, use {@link #isNotNull()}. + * DO NOT CALL THIS METHOD!. A {@link MessageLite.Builder} will never compare equal to a + * {@link MessageLite} instance. Use {@code build()}, or {@code buildPartial()} on the argument to + * get a {@link MessageLite} for comparison instead. Or, if you are passing {@code null}, use + * {@link #isNotNull()}. */ - // TODO(cpovirk): Consider @DoNotCall or other static analysis. (See isEqualTo(Builder).) - @Deprecated public void isNotEqualTo(MessageLite.@Nullable Builder builder) { isNotEqualTo((Object) builder); } diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoTruth.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java similarity index 97% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoTruth.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java index fe2c57c6f..2673534ab 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/LiteProtoTruth.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.google.common.truth.extensions.liteproto; +package com.google.common.truth.extensions.proto; import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.Subject; import com.google.errorprone.annotations.CheckReturnValue; import com.google.protobuf.MessageLite; -import org.jspecify.annotations.Nullable; import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A set of static methods to begin a Truth assertion chain for the lite version of protocol diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java similarity index 97% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java index af81e91e1..c6880f9b2 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.common.truth.extensions.liteproto; +package com.google.common.truth.extensions.proto; import static com.google.common.base.Strings.lenientFormat; diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java similarity index 67% rename from extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java rename to extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java index 7bc53dc84..a76e2e234 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java @@ -16,12 +16,7 @@ /** * Custom subjects for testing Protocol - * Buffer instances using the full protobuf library. - * - *

This package provides Truth extensions for full Protocol Buffers (protobuf-java), which - * includes advanced features like reflection, text format, and comprehensive message manipulation. - * For lighter-weight protobuf-lite support, see - * {@link com.google.common.truth.extensions.liteproto}. + * Buffer instances. * *

This package is a part of the open-source Truth * project. @@ -29,4 +24,4 @@ @CheckReturnValue package com.google.common.truth.extensions.proto; -import com.google.errorprone.annotations.CheckReturnValue; \ No newline at end of file +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/extensions/liteproto/src/main/java/module-info.java b/extensions/liteproto/src/main/java/module-info.java deleted file mode 100644 index 9bb27b891..000000000 --- a/extensions/liteproto/src/main/java/module-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2025 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -module com.google.truth.extensions.liteproto { - requires com.google.truth; - requires com.google.common; - requires java.compiler; - - requires static org.jspecify; - requires static com.google.errorprone.annotations; - requires static protobuf.lite; - requires static auto.value.annotations; - requires static com.google.j2objc.annotations; - - exports com.google.common.truth.extensions.liteproto; - exports com.google.common.truth.extensions.liteproto.internal to com.google.truth.extensions.proto; -} \ No newline at end of file diff --git a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/liteproto/test/LiteProtoSubjectTest.java b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java similarity index 93% rename from extensions/liteproto/src/test/java/com/google/common/truth/extensions/liteproto/test/LiteProtoSubjectTest.java rename to extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java index 1f7dc1a8a..787d320f8 100644 --- a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/liteproto/test/LiteProtoSubjectTest.java +++ b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java @@ -13,25 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.liteproto.test; +package com.google.common.truth.extensions.proto; import static com.google.common.truth.ExpectFailure.assertThat; import static com.google.common.truth.ExpectFailure.expectFailureAbout; -import static com.google.common.truth.extensions.liteproto.LiteProtoTruth.assertThat; -import static com.google.common.truth.extensions.liteproto.LiteProtoTruth.liteProtos; +import static com.google.common.truth.extensions.proto.LiteProtoTruth.assertThat; +import static com.google.common.truth.extensions.proto.LiteProtoTruth.liteProtos; import com.google.auto.value.AutoValue; -import com.google.common.truth.extensions.liteproto.test.proto.OtherTestMessageLite2; -import com.google.common.truth.extensions.liteproto.test.proto.OtherTestMessageLite3; -import com.google.common.truth.extensions.liteproto.test.proto.TestMessageLite2; -import com.google.common.truth.extensions.liteproto.test.proto.TestMessageLite2WithRequiredFields; -import com.google.common.truth.extensions.liteproto.test.proto.TestMessageLite3; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.truth.Expect; import com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback; import com.google.common.truth.Subject; -import com.google.common.truth.extensions.liteproto.LiteProtoSubject; import com.google.protobuf.MessageLite; import java.util.Arrays; import java.util.Collection; @@ -140,7 +134,7 @@ public LiteProtoSubjectTest(@SuppressWarnings("unused") String name, Config conf } private LiteProtoSubject expectThat(@Nullable MessageLite m) { - return expect.about(liteProtos()).that(m); + return expect.about(LiteProtoTruth.liteProtos()).that(m); } private Subject expectThat(@Nullable Object o) { @@ -167,6 +161,7 @@ public void subjectMethods() { } @Test + @SuppressWarnings("DoNotCall") public void isEqualTo_success() { expectThat(null).isEqualTo(null); expectThat(null).isNull(); diff --git a/extensions/proto/pom.xml b/extensions/proto/pom.xml index b582c5bc8..d52855799 100644 --- a/extensions/proto/pom.xml +++ b/extensions/proto/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - 999.0.0-SNAPSHOT + HEAD-SNAPSHOT truth-proto-extension Truth Extension for Protocol Buffers @@ -99,16 +99,6 @@ - - maven-jar-plugin - - - - true - - - - diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java index 990d350d1..b2c91f358 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java @@ -260,7 +260,7 @@ private static String indexed(String fieldPrefix, Optional fieldIndex) @Override final void printContents(boolean includeMatches, String fieldPrefix, StringBuilder sb) { printContentsForRepeatedField( - /* includeSelfAlways = */ false, includeMatches, fieldPrefix, sb); + /* includeSelfAlways= */ false, includeMatches, fieldPrefix, sb); } // When printing results for a repeated field, we want to print matches even if @@ -432,7 +432,7 @@ final void printContents(boolean includeMatches, String fieldPrefix, StringBuild fieldPrefix = newFieldPrefix(fieldPrefix, fieldDescriptor().getName()); for (PairResult pairResult : pairResults()) { pairResult.printContentsForRepeatedField( - /* includeSelfAlways = */ !isMatched(), includeMatches, fieldPrefix, sb); + /* includeSelfAlways= */ !isMatched(), includeMatches, fieldPrefix, sb); } } @@ -627,11 +627,11 @@ final String printToString(boolean reportMismatchesOnly) { if (!isMatched()) { sb.append("Differences were found:\n"); - printContents(/* includeMatches = */ false, /* fieldPrefix = */ "", sb); + printContents(/* includeMatches= */ false, /* fieldPrefix= */ "", sb); if (!reportMismatchesOnly && isAnyChildMatched()) { sb.append("\nFull diff report:\n"); - printContents(/* includeMatches = */ true, /* fieldPrefix = */ "", sb); + printContents(/* includeMatches= */ true, /* fieldPrefix= */ "", sb); } } else { sb.append("No differences were found."); @@ -641,7 +641,7 @@ final String printToString(boolean reportMismatchesOnly) { } else { sb.append("\nFull diff report:\n"); } - printContents(/* includeMatches = */ true, /* fieldPrefix = */ "", sb); + printContents(/* includeMatches= */ true, /* fieldPrefix= */ "", sb); } } diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogic.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogic.java index 312c04e6d..00d031471 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogic.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogic.java @@ -120,7 +120,7 @@ FieldScopeLogic ignoringFields(Iterable fieldNumbers) { } return and( this, - new NegationFieldScopeLogic(new FieldNumbersLogic(fieldNumbers, /* isRecursive = */ true))); + new NegationFieldScopeLogic(new FieldNumbersLogic(fieldNumbers, /* isRecursive= */ true))); } FieldScopeLogic ignoringFieldDescriptors(Iterable fieldDescriptors) { @@ -130,35 +130,35 @@ FieldScopeLogic ignoringFieldDescriptors(Iterable fieldDescript return and( this, new NegationFieldScopeLogic( - new FieldDescriptorsLogic(fieldDescriptors, /* isRecursive = */ true))); + new FieldDescriptorsLogic(fieldDescriptors, /* isRecursive= */ true))); } FieldScopeLogic allowingFields(Iterable fieldNumbers) { if (isEmpty(fieldNumbers)) { return this; } - return or(this, new FieldNumbersLogic(fieldNumbers, /* isRecursive = */ true)); + return or(this, new FieldNumbersLogic(fieldNumbers, /* isRecursive= */ true)); } FieldScopeLogic allowingFieldsNonRecursive(Iterable fieldNumbers) { if (isEmpty(fieldNumbers)) { return this; } - return or(this, new FieldNumbersLogic(fieldNumbers, /* isRecursive = */ false)); + return or(this, new FieldNumbersLogic(fieldNumbers, /* isRecursive= */ false)); } FieldScopeLogic allowingFieldDescriptors(Iterable fieldDescriptors) { if (isEmpty(fieldDescriptors)) { return this; } - return or(this, new FieldDescriptorsLogic(fieldDescriptors, /* isRecursive = */ true)); + return or(this, new FieldDescriptorsLogic(fieldDescriptors, /* isRecursive= */ true)); } FieldScopeLogic allowingFieldDescriptorsNonRecursive(Iterable fieldDescriptors) { if (isEmpty(fieldDescriptors)) { return this; } - return or(this, new FieldDescriptorsLogic(fieldDescriptors, /* isRecursive = */ false)); + return or(this, new FieldDescriptorsLogic(fieldDescriptors, /* isRecursive= */ false)); } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -331,7 +331,7 @@ final FieldScopeResult policyFor(Descriptor rootDescriptor, SubScopeId subScopeI } if (matchesFieldDescriptor(rootDescriptor, fieldDescriptor)) { - return FieldScopeResult.of(/* included = */ true, isRecursive); + return FieldScopeResult.of(/* included= */ true, isRecursive); } // We return 'EXCLUDED_NONRECURSIVELY' for both field descriptor scopes and field number diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java index 9659b1e09..5b6d55639 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java @@ -90,7 +90,6 @@ public ProtoTruthMessageDifferencer load(Descriptor descriptor) { abstract FieldScopeLogicMap> floatCorrespondenceMap(); - abstract boolean compareExpectedFieldsOnly(); // Whether 'withExpectedMessages()' has been invoked. This is a book-keeping boolean to ensure @@ -411,7 +410,6 @@ abstract Builder setDoubleCorrespondenceMap( abstract Builder setFloatCorrespondenceMap( FieldScopeLogicMap> floatCorrespondenceMap); - abstract Builder setCompareExpectedFieldsOnly(boolean compare); abstract Builder setHasExpectedMessages(boolean hasExpectedMessages); diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java index 8649f84d6..5d2218373 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java @@ -23,8 +23,6 @@ import static com.google.common.truth.extensions.proto.FieldScopeUtil.asList; import com.google.common.truth.FailureMetadata; -import com.google.common.truth.extensions.liteproto.LiteProtoSubject; -import com.google.common.truth.extensions.liteproto.internal.LiteProtoSubjectAccess; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; @@ -679,7 +677,7 @@ public void hasAllRequiredFields() { failWithoutActual( simpleFact("expected to have all required fields set"), fact("but was missing", actual.findInitializationErrors()), - fact("proto was", LiteProtoSubjectAccess.getCustomStringRepresentation(this))); + fact("proto was", actualCustomStringRepresentationForProtoPackageMembersToCall())); } } diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java index 27bf91743..e7015c189 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java @@ -19,8 +19,6 @@ import com.google.common.collect.Multimap; import com.google.common.truth.CustomSubjectBuilder; import com.google.common.truth.FailureMetadata; -import com.google.common.truth.extensions.liteproto.LiteProtoSubject; -import com.google.common.truth.extensions.liteproto.LiteProtoTruth; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; @@ -53,7 +51,7 @@ private ProtoSubjectBuilder(FailureMetadata failureMetadata) { } public LiteProtoSubject that(@Nullable MessageLite messageLite) { - return LiteProtoTruth.liteProtos().createSubject(metadata(), messageLite); + return new LiteProtoSubject(metadata(), messageLite); } public ProtoSubject that(@Nullable Message message) { diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java index fb9ade802..7daa0d1dc 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java @@ -24,7 +24,6 @@ import com.google.common.truth.MapSubject; import com.google.common.truth.MultimapSubject; import com.google.common.truth.StandardSubjectBuilder; -import com.google.common.truth.extensions.liteproto.LiteProtoSubject; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; diff --git a/extensions/proto/src/main/java/module-info.java b/extensions/proto/src/main/java/module-info.java deleted file mode 100644 index 7581473ef..000000000 --- a/extensions/proto/src/main/java/module-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2025 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -module com.google.truth.extensions.proto { - requires com.google.truth; - requires com.google.truth.extensions.liteproto; - requires com.google.common; - requires com.google.protobuf; - requires java.compiler; - - requires static org.jspecify; - requires static com.google.errorprone.annotations; - requires static auto.value.annotations; - - exports com.google.common.truth.extensions.proto; -} \ No newline at end of file diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/FieldScopesTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/FieldScopesTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java index 8df762678..077d647f2 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/FieldScopesTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; @@ -23,8 +23,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.common.truth.extensions.proto.FieldScope; -import com.google.common.truth.extensions.proto.FieldScopes; import com.google.protobuf.ByteString; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.InvalidProtocolBufferException; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/IterableOfProtosSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/IterableOfProtosSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java index 475c27d59..9d2b52edb 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/IterableOfProtosSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java @@ -14,14 +14,12 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import static java.util.Comparator.comparing; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; -import com.google.common.truth.extensions.proto.FieldScopes; -import com.google.common.truth.extensions.proto.IterableOfProtosSubject; import com.google.protobuf.Message; import java.util.Collection; import java.util.Comparator; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MapWithProtoValuesSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java similarity index 97% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MapWithProtoValuesSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java index 807d7840c..1bdf2f34d 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MapWithProtoValuesSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java @@ -14,12 +14,10 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import com.google.common.collect.ImmutableMap; import com.google.common.truth.MapSubject; -import com.google.common.truth.extensions.proto.MapWithProtoValuesFluentAssertion; -import com.google.common.truth.extensions.proto.MapWithProtoValuesSubject; import com.google.protobuf.Message; import java.util.Collection; import org.junit.Test; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultiExpectFailure.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java similarity index 97% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultiExpectFailure.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java index a8ad20f87..d1ae1dd5c 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultiExpectFailure.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import com.google.common.base.Preconditions; import com.google.common.truth.ExpectFailure; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultimapWithProtoValuesSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java similarity index 98% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultimapWithProtoValuesSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java index 0e74692c8..f7570fdc6 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/MultimapWithProtoValuesSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.truth.MultimapSubject; -import com.google.common.truth.extensions.proto.MultimapWithProtoValuesFluentAssertion; -import com.google.common.truth.extensions.proto.MultimapWithProtoValuesSubject; import com.google.protobuf.Message; import java.util.Collection; import org.junit.Test; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/OverloadResolutionTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/OverloadResolutionTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java index 518d2994d..adc4ee5ae 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/OverloadResolutionTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.Truth.assertThat; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java similarity index 99% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTest.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java index a502f68e1..b9f8ffcbe 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertThat; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTestBase.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java similarity index 95% rename from extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTestBase.java rename to extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java index 023119308..e686a4f4a 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/test/ProtoSubjectTestBase.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.proto.test; +package com.google.common.truth.extensions.proto; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.truth.Truth.assertThat; @@ -32,12 +32,6 @@ import com.google.common.truth.ExpectFailure; import com.google.common.truth.Subject; import com.google.common.truth.TruthFailureSubject; -import com.google.common.truth.extensions.proto.IterableOfProtosSubject; -import com.google.common.truth.extensions.proto.MapWithProtoValuesSubject; -import com.google.common.truth.extensions.proto.MultimapWithProtoValuesSubject; -import com.google.common.truth.extensions.proto.ProtoSubject; -import com.google.common.truth.extensions.proto.ProtoSubjectBuilder; -import com.google.common.truth.extensions.proto.ProtoTruth; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.InvalidProtocolBufferException; diff --git a/extensions/re2j/pom.xml b/extensions/re2j/pom.xml index 0a9b83970..6ca4180ce 100644 --- a/extensions/re2j/pom.xml +++ b/extensions/re2j/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - 999.0.0-SNAPSHOT + HEAD-SNAPSHOT truth-re2j-extension Truth Extension for RE2J @@ -38,19 +38,6 @@ maven-javadoc-plugin - - maven-compiler-plugin - - - maven-jar-plugin - - - - true - - - - diff --git a/extensions/re2j/src/main/java/module-info.java b/extensions/re2j/src/main/java/module-info.java deleted file mode 100644 index e386a8329..000000000 --- a/extensions/re2j/src/main/java/module-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -module com.google.truth.extensions.re2j { - requires com.google.truth; - requires re2j; - - requires static org.jspecify; - - exports com.google.common.truth.extensions.re2j; -} \ No newline at end of file diff --git a/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/test/Re2jSubjectsTest.java b/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java similarity index 97% rename from extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/test/Re2jSubjectsTest.java rename to extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java index 176a67b38..8c5949d2e 100644 --- a/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/test/Re2jSubjectsTest.java +++ b/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.common.truth.extensions.re2j.test; +package com.google.common.truth.extensions.re2j; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.extensions.re2j.Re2jSubjects.re2jString; diff --git a/pom.xml b/pom.xml index 60a08b217..5f372854d 100644 --- a/pom.xml +++ b/pom.xml @@ -318,19 +318,21 @@ default-compile - 9 + + **/super/**/*.java + - base-compile + compile-java9 compile - - module-info.java - **/super/**/*.java - + 9 + + ${project.basedir}/src/main/java9 + From 28162cb61d56770b1db6d403f1b48e65df9f7c23 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 12:14:12 -0400 Subject: [PATCH 08/21] Remove unnecessary java.compiler requirement from module-info.java --- core/src/main/java9/module-info.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java index 2e738a453..c82449707 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java9/module-info.java @@ -17,7 +17,6 @@ module com.google.truth { requires com.google.common; requires static junit; - requires java.compiler; requires static org.jspecify; requires static com.google.errorprone.annotations; @@ -26,4 +25,4 @@ requires static com.google.j2objc.annotations; exports com.google.common.truth; -} \ No newline at end of file +} From 461d2666cd1f85aaa6865e2fbdf89b56db2e5237 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:17:39 -0400 Subject: [PATCH 09/21] test under 25 instead of 11, use 999.0.0-SNAPSHOT throughout instead of mixing with HEAD-SNAPSHOT, sort and format module-info --- .github/workflows/ci.yml | 2 +- core/src/main/java9/module-info.java | 16 ++++++++-------- extensions/liteproto/pom.xml | 2 +- extensions/proto/pom.xml | 2 +- extensions/re2j/pom.xml | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f09f1fd9..c2b2e6280 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: needs: build strategy: matrix: - java: [ 8, 11, 17 ] + java: [ 8, 17, 25 ] runs-on: ubuntu-latest steps: - name: 'Check out repository' diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java index c82449707..511ee5889 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java9/module-info.java @@ -15,14 +15,14 @@ */ module com.google.truth { - requires com.google.common; - requires static junit; + requires com.google.common; - requires static org.jspecify; - requires static com.google.errorprone.annotations; - requires static org.objectweb.asm; - requires static auto.value.annotations; - requires static com.google.j2objc.annotations; + requires static auto.value.annotations; + requires static com.google.errorprone.annotations; + requires static com.google.j2objc.annotations; + requires static junit; + requires static org.jspecify; + requires static org.objectweb.asm; - exports com.google.common.truth; + exports com.google.common.truth; } diff --git a/extensions/liteproto/pom.xml b/extensions/liteproto/pom.xml index a70faa5d8..21dea4bc2 100644 --- a/extensions/liteproto/pom.xml +++ b/extensions/liteproto/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-liteproto-extension Truth Extension for Lite Protocol Buffers diff --git a/extensions/proto/pom.xml b/extensions/proto/pom.xml index d52855799..649ef78c3 100644 --- a/extensions/proto/pom.xml +++ b/extensions/proto/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-proto-extension Truth Extension for Protocol Buffers diff --git a/extensions/re2j/pom.xml b/extensions/re2j/pom.xml index 6ca4180ce..ae497198c 100644 --- a/extensions/re2j/pom.xml +++ b/extensions/re2j/pom.xml @@ -7,7 +7,7 @@ com.google.truth.extensions truth-extensions-parent - HEAD-SNAPSHOT + 999.0.0-SNAPSHOT truth-re2j-extension Truth Extension for RE2J From 41214591a75aaaba9692086c2c68485c80fc24cf Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:21:48 -0400 Subject: [PATCH 10/21] Restore Employee sample extension and fix modular test visibility --- core/pom.xml | 3 + .../common/truth/extension/Employee.java | 44 +++++++++ .../truth/extension/EmployeeSubject.java | 97 +++++++++++++++++++ .../truth/extension/EmployeeSubjectTest.java | 64 ++++++++++++ .../truth/extension/FakeHrDatabase.java | 58 +++++++++++ .../truth/extension/FakeHrDatabaseTest.java | 77 +++++++++++++++ .../common/truth/extension/HrDatabase.java | 35 +++++++ pom.xml | 10 ++ 8 files changed, 388 insertions(+) create mode 100644 core/src/test/java/com/google/common/truth/extension/Employee.java create mode 100644 core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java create mode 100644 core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java create mode 100644 core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java create mode 100644 core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java create mode 100644 core/src/test/java/com/google/common/truth/extension/HrDatabase.java diff --git a/core/pom.xml b/core/pom.xml index bff895634..9b2da615f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -128,6 +128,9 @@ maven-surefire-plugin + + ${test.add.exports} + default-test diff --git a/core/src/test/java/com/google/common/truth/extension/Employee.java b/core/src/test/java/com/google/common/truth/extension/Employee.java new file mode 100644 index 000000000..8cc2cf448 --- /dev/null +++ b/core/src/test/java/com/google/common/truth/extension/Employee.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.common.truth.extension; + +import com.google.auto.value.AutoValue; + +/** Represents an employee. */ +@AutoValue +public abstract class Employee { + public static Employee create( + String username, long id, String name, Location location, boolean isCeo) { + return new AutoValue_Employee(username, id, name, location, isCeo); + } + + abstract String username(); + + abstract long id(); + + abstract String name(); + + abstract Location location(); + + abstract boolean isCeo(); + + public enum Location { + MTV, + PIT, + CHI, + NYC + } +} diff --git a/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java b/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java new file mode 100644 index 000000000..ba3acd76f --- /dev/null +++ b/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2015 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.common.truth.extension; + +import static com.google.common.truth.Fact.simpleFact; +import static com.google.common.truth.Truth.assertAbout; + +import com.google.common.truth.ComparableSubject; +import com.google.common.truth.FailureMetadata; +import com.google.common.truth.LongSubject; +import com.google.common.truth.StringSubject; +import com.google.common.truth.Subject; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** A Truth subject for {@link Employee}. */ +@NullMarked +public final class EmployeeSubject extends Subject { + + // User-defined entry point + public static EmployeeSubject assertThat(@Nullable Employee employee) { + return assertAbout(employees()).that(employee); + } + + // Static method for getting the subject factory (for use with assertAbout()) + public static Factory employees() { + return EmployeeSubject::new; + } + + private final @Nullable Employee actual; + + private EmployeeSubject(FailureMetadata failureMetadata, @Nullable Employee subject) { + super(failureMetadata, subject); + this.actual = subject; + } + + // User-defined test assertion SPI below this point + + public void hasName(String name) { + name().isEqualTo(name); + } + + public void hasUsername(String username) { + username().isEqualTo(username); + } + + public void hasId(long id) { + id().isEqualTo(id); + } + + public void hasLocation(Employee.Location location) { + location().isEqualTo(location); + } + + public void isCeo() { + if (!actual.isCeo()) { + failWithActual(simpleFact("expected to be CEO")); + } + } + + public void isNotCeo() { + if (actual.isCeo()) { + failWithActual(simpleFact("expected not to be CEO")); + } + } + + // Chained subjects methods below this point + + public StringSubject name() { + return check("name()").that(actual.name()); + } + + public StringSubject username() { + return check("username()").that(actual.username()); + } + + public LongSubject id() { + return check("id()").that(actual.id()); + } + + public ComparableSubject location() { + return check("location()").that(actual.location()); + } +} diff --git a/core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java b/core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java new file mode 100644 index 000000000..a2cc6b2e9 --- /dev/null +++ b/core/src/test/java/com/google/common/truth/extension/EmployeeSubjectTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.common.truth.extension; + +import static com.google.common.truth.ExpectFailure.assertThat; +import static com.google.common.truth.ExpectFailure.expectFailureAbout; +import static com.google.common.truth.extension.EmployeeSubject.assertThat; +import static com.google.common.truth.extension.EmployeeSubject.employees; + +import com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback; +import com.google.common.truth.extension.Employee.Location; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class EmployeeSubjectTest { + + // Note: not real employee IDs :-) + + private static final Employee KURT = + Employee.create("kak", 37802, "Kurt Alfred Kluever", Location.NYC, /* isCeo= */ false); + + @Test + public void id() { + assertThat(KURT).hasId(37802); + expectFailure(whenTesting -> whenTesting.that(KURT).hasId(12345)); + } + + @Test + public void name() { + assertThat(KURT).hasName("Kurt Alfred Kluever"); + expectFailure(whenTesting -> whenTesting.that(KURT).hasName("Sundar Pichai")); + } + + @Test + public void username() { + assertThat(KURT).hasUsername("kak"); + // Here's an example of asserting on the failure message. + // Note that it uses the assertThat method from ExpectFailure. + AssertionError e = expectFailure(whenTesting -> whenTesting.that(KURT).hasUsername("sundar")); + assertThat(e).factValue("value of").isEqualTo("employee.username()"); + } + + @CanIgnoreReturnValue + private static AssertionError expectFailure( + SimpleSubjectBuilderCallback callback) { + return expectFailureAbout(employees(), callback); + } +} diff --git a/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java b/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java new file mode 100644 index 000000000..78236b495 --- /dev/null +++ b/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.common.truth.extension; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import com.google.common.collect.ImmutableSet; +import com.google.common.truth.extension.Employee.Location; +import java.util.HashMap; +import java.util.Map; + +/** In-memory implementation of {@link HrDatabase}, suitable for testing. */ +public final class FakeHrDatabase implements HrDatabase { + private final Map employees = new HashMap<>(); + + public void put(Employee employee) { + employees.put(employee.id(), employee); + } + + @Override + public Employee get(long id) { + return employees.get(id); + } + + @Override + public void relocate(long id, Location location) { + checkNotNull(location); + Employee old = get(id); + checkState(old != null, "No employee found with ID %s", id); + employees.put(id, Employee.create(old.username(), old.id(), old.name(), location, old.isCeo())); + } + + @Override + public ImmutableSet getByLocation(Location location) { + checkNotNull(location); + ImmutableSet.Builder result = ImmutableSet.builder(); + for (Employee employee : employees.values()) { + if (employee.location() == location) { + result.add(employee); + } + } + return result.build(); + } +} diff --git a/core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java b/core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java new file mode 100644 index 000000000..095d899e0 --- /dev/null +++ b/core/src/test/java/com/google/common/truth/extension/FakeHrDatabaseTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.common.truth.extension; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.extension.EmployeeSubject.assertThat; + +import com.google.common.truth.extension.Employee.Location; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class FakeHrDatabaseTest { + + // Note: not real employee IDs :-) + + private static final Employee KURT = + Employee.create("kak", 37802, "Kurt Alfred Kluever", Location.NYC, /* isCeo= */ false); + + private static final Employee SUNDAR = + Employee.create("sundar", 5243, "Sundar Pichai", Location.MTV, /* isCeo= */ true); + + // Notice that we static import two different assertThat methods. + + // These assertions use the EmployeeSubject.assertThat(Employee) overload and the + // EmployeeSubject-specific methods. + + @Test + public void relocatePresent() { + FakeHrDatabase db = new FakeHrDatabase(); + db.put(KURT); + db.relocate(KURT.id(), Location.MTV); + Employee movedKurt = db.get(KURT.id()); + assertThat(movedKurt).hasLocation(Location.MTV); + assertThat(movedKurt).hasUsername("kak"); + } + + // These assertions use the EmployeeSubject.assertThat(Employee) overload but the assertion + // methods inherited from Subject. + + @Test + public void getPresent() { + FakeHrDatabase db = new FakeHrDatabase(); + db.put(KURT); + assertThat(db.get(KURT.id())).isEqualTo(KURT); + } + + @Test + public void getAbsent() { + FakeHrDatabase db = new FakeHrDatabase(); + db.put(KURT); + assertThat(db.get(SUNDAR.id())).isNull(); + } + + // These assertions use Truth.assertThat() overloads + + @Test + public void getByLocation() { + FakeHrDatabase db = new FakeHrDatabase(); + db.put(KURT); + assertThat(db.getByLocation(Location.NYC)).containsExactly(KURT); + } +} diff --git a/core/src/test/java/com/google/common/truth/extension/HrDatabase.java b/core/src/test/java/com/google/common/truth/extension/HrDatabase.java new file mode 100644 index 000000000..50a6a1dc7 --- /dev/null +++ b/core/src/test/java/com/google/common/truth/extension/HrDatabase.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.common.truth.extension; + +import com.google.common.collect.ImmutableSet; +import com.google.common.truth.extension.Employee.Location; + +/** + * Service for accessing human resources data. + * + *

This class (and all the classes in this package) are just a demonstration of how to write and + * use a custom Truth subject. The only implementation of {@code HrDatabase} is {@link + * FakeHrDatabase}, and the only place we use it is in its own test, whose real purpose is to + * demonstrate how to use a custom Truth subject. + */ +public interface HrDatabase { + Employee get(long id); + + void relocate(long id, Location location); + + ImmutableSet getByLocation(Location location); +} diff --git a/pom.xml b/pom.xml index 01db194fb..a88bf2d86 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,7 @@ + @@ -390,6 +391,15 @@ + + java9-plus + + [9,) + + + --add-exports com.google.truth/com.google.common.truth.extension=junit,ALL-UNNAMED + + sonatype-oss-release From 575a6ac694a2609a3932011977b9e99fe601499a Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:37:55 -0400 Subject: [PATCH 11/21] document add-exports --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index a88bf2d86..672046974 100644 --- a/pom.xml +++ b/pom.xml @@ -397,6 +397,10 @@ [9,) + --add-exports com.google.truth/com.google.common.truth.extension=junit,ALL-UNNAMED From 3c8e54546a6b70521a4b1cbe11ba8575b35e9e58 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:45:24 -0400 Subject: [PATCH 12/21] remove autovalue annotations from module --- core/src/main/java9/module-info.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java index 511ee5889..c1cf32394 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java9/module-info.java @@ -17,7 +17,12 @@ module com.google.truth { requires com.google.common; - requires static auto.value.annotations; + /* + * AutoValue's annotations aren't ready for the module system: + * https://github.com/google/auto/issues/597. Let's hope that our usages are internal enough that + * we don't need to worry about listing them here. + */ + requires static com.google.errorprone.annotations; requires static com.google.j2objc.annotations; requires static junit; From 4136d0f65f4366bbf6b3873353d3b45f97640142 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:54:18 -0400 Subject: [PATCH 13/21] Move modular build configuration and GWT exclusions to core/pom.xml --- core/pom.xml | 28 ++++++++++++++++++++++++++++ pom.xml | 36 ------------------------------------ 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 9b2da615f..3fa03741f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -9,6 +9,9 @@ truth Truth Core + + + com.google.guava @@ -98,6 +101,22 @@ + + + compile-java9 + compile + + compile + + + 9 + + ${project.basedir}/src/main/java9 + + false + + + maven-source-plugin @@ -266,6 +285,15 @@ + + java9-plus + + [9,) + + + --add-exports com.google.truth/com.google.common.truth.extension=junit,ALL-UNNAMED + + java8 diff --git a/pom.xml b/pom.xml index 672046974..b2bad88c0 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,6 @@ - @@ -315,28 +314,6 @@ 1.8 true - - - default-compile - - - **/super/**/*.java - - - - - compile-java9 - - compile - - - 9 - - ${project.basedir}/src/main/java9 - - - - maven-source-plugin @@ -391,19 +368,6 @@ - - java9-plus - - [9,) - - - - --add-exports com.google.truth/com.google.common.truth.extension=junit,ALL-UNNAMED - - sonatype-oss-release From 80455f7646390081dcc7e5c4bcc76d62f72dc9f9 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:57:13 -0400 Subject: [PATCH 14/21] restore comment about why add-exports --- core/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/pom.xml b/core/pom.xml index 3fa03741f..8112a7e96 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -291,6 +291,10 @@ [9,) + --add-exports com.google.truth/com.google.common.truth.extension=junit,ALL-UNNAMED From c9496fc79d6d03d1c35e9bd37ec02ddee5d0b6b0 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 16:59:40 -0400 Subject: [PATCH 15/21] add transitive for junit, where it is probably important for users of Expect, and annotations, where it might not be but it seems possibly more correct and I would like to know of problems: https://github.com/jspecify/jspecify/issues/495#issuecomment-2744405987 --- core/src/main/java9/module-info.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java index c1cf32394..449b328b9 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java9/module-info.java @@ -23,11 +23,11 @@ * we don't need to worry about listing them here. */ - requires static com.google.errorprone.annotations; - requires static com.google.j2objc.annotations; - requires static junit; - requires static org.jspecify; - requires static org.objectweb.asm; + requires static transitive com.google.errorprone.annotations; + requires static transitive com.google.j2objc.annotations; + requires static transitive junit; + requires static transitive org.jspecify; + requires static transitive org.objectweb.asm; exports com.google.common.truth; } From caacd604f17bfd2c2fa19dcc4c7bf5bd57887a6f Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 17:02:31 -0400 Subject: [PATCH 16/21] transitive for guava, too --- core/src/main/java9/module-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java index 449b328b9..a78387ad7 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java9/module-info.java @@ -15,7 +15,7 @@ */ module com.google.truth { - requires com.google.common; + requires transitive com.google.common; /* * AutoValue's annotations aren't ready for the module system: From 4319994e181c03b98aac7614d75b5cb20d59666c Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 17:03:03 -0400 Subject: [PATCH 17/21] use java 26 for builds --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2b2e6280..f1547cc88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: jobs: build: - name: 'Build with JDK 11' + name: 'Build with JDK 26' runs-on: ubuntu-latest steps: # Cancel any previous runs for the same branch that are still running. @@ -20,10 +20,10 @@ jobs: access_token: ${{ github.token }} - name: 'Check out repository' uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - - name: 'Set up JDK 11 for compilation' + - name: 'Set up JDK 26 for compilation' uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 with: - java-version: 11 + java-version: 26 distribution: 'temurin' cache: 'maven' - name: 'Install' @@ -73,10 +73,10 @@ jobs: steps: - name: 'Check out repository' uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - - name: 'Set up JDK 11' + - name: 'Set up JDK 26' uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 with: - java-version: 11 + java-version: 26 distribution: 'temurin' cache: 'maven' server-id: central @@ -98,10 +98,10 @@ jobs: steps: - name: 'Check out repository' uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - - name: 'Set up JDK 11' + - name: 'Set up JDK 26' uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 with: - java-version: 11 + java-version: 26 distribution: 'temurin' cache: 'maven' - name: 'Generate latest docs' From eb000069418df250004cdfecaffb8e9d7ca221c3 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 17:39:55 -0400 Subject: [PATCH 18/21] pin artifacts --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1547cc88..df18064ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: shell: bash run: mvn -B -P!standard-with-extra-repos javadoc:aggregate -U - name: 'Upload build artifacts' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: truth-jars path: | @@ -58,7 +58,7 @@ jobs: distribution: 'temurin' cache: 'maven' - name: 'Download build artifacts' - uses: actions/download-artifact@v3 + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with: name: truth-jars - name: 'Test' From 1b70d3a783e50ad6de3702f135a0e70c692d25ad Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 17:49:04 -0400 Subject: [PATCH 19/21] Fix CI failure by moving modular compilation to a JDK 9+ profile --- core/pom.xml | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 8112a7e96..91000d4d6 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -101,22 +101,6 @@ - - - compile-java9 - compile - - compile - - - 9 - - ${project.basedir}/src/main/java9 - - false - - - maven-source-plugin @@ -297,6 +281,29 @@ --> --add-exports com.google.truth/com.google.common.truth.extension=junit,ALL-UNNAMED + + + + maven-compiler-plugin + + + compile-java9 + compile + + compile + + + 9 + + ${project.basedir}/src/main/java9 + + false + + + + + + java8 From fd02f03351ad570c9c9f3ad1cc1620a782427a1f Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 17:55:05 -0400 Subject: [PATCH 20/21] Skip main compilation in CI test job to preserve build artifacts --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df18064ec..c9e831cb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: name: truth-jars - name: 'Test' shell: bash - run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true + run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -Dmaven.main.skip=true publish_snapshot: name: 'Publish snapshot' From bd6d3a17a89c2dc0e69fe10abe70aa9242177334 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Fri, 15 May 2026 18:03:23 -0400 Subject: [PATCH 21/21] Unpack build artifacts in CI test job to satisfy test-compilation --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9e831cb9..398c55d74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,14 @@ jobs: uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with: name: truth-jars + - name: 'Unpack artifacts' + shell: bash + run: | + for f in $(find . -name "*.jar" ! -name "*-gwt.jar"); do + dest="${f%/target/*}/target/classes" + mkdir -p "$dest" + unzip -o "$f" -d "$dest" + done - name: 'Test' shell: bash run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -Dmaven.main.skip=true