From c04ad9ed6c4958f4dfef0c112ddf1017367a0d95 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Sun, 21 Sep 2025 09:51:59 -0400 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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;