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/core/pom.xml b/core/pom.xml index 32fe3ef88..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 @@ -110,6 +110,13 @@ maven-jar-plugin + + + + true + + + attach-gwt-sources diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java new file mode 100644 index 000000000..2e738a453 --- /dev/null +++ b/core/src/main/java/module-info.java @@ -0,0 +1,29 @@ +/* + * 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 { + requires com.google.common; + requires static 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 a70faa5d8..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 @@ -97,6 +97,16 @@ + + maven-jar-plugin + + + + true + + + + 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..047d6d0d6 --- /dev/null +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/internal/LiteProtoSubjectAccess.java @@ -0,0 +1,68 @@ +/* + * 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 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/liteproto/src/main/java/module-info.java b/extensions/liteproto/src/main/java/module-info.java new file mode 100644 index 000000000..9bb27b891 --- /dev/null +++ b/extensions/liteproto/src/main/java/module-info.java @@ -0,0 +1,30 @@ +/* + * 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/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..f5549cf66 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 diff --git a/extensions/proto/pom.xml b/extensions/proto/pom.xml index d52855799..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 @@ -99,6 +99,16 @@ + + maven-jar-plugin + + + + true + + + + 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/liteproto/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 similarity index 67% rename from extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java rename to extensions/proto/src/main/java/com/google/common/truth/extensions/proto/package-info.java index a76e2e234..7bc53dc84 100644 --- a/extensions/liteproto/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 @@ -16,7 +16,12 @@ /** * Custom subjects for testing Protocol - * Buffer instances. + * 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. @@ -24,4 +29,4 @@ @CheckReturnValue package com.google.common.truth.extensions.proto; -import com.google.errorprone.annotations.CheckReturnValue; +import com.google.errorprone.annotations.CheckReturnValue; \ No newline at end of file diff --git a/extensions/proto/src/main/java/module-info.java b/extensions/proto/src/main/java/module-info.java new file mode 100644 index 000000000..7581473ef --- /dev/null +++ b/extensions/proto/src/main/java/module-info.java @@ -0,0 +1,29 @@ +/* + * 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/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 6ca4180ce..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 @@ -38,6 +38,19 @@ 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 new file mode 100644 index 000000000..e386a8329 --- /dev/null +++ b/extensions/re2j/src/main/java/module-info.java @@ -0,0 +1,24 @@ +/* + * 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/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..60a08b217 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,26 @@ 1.8 true + + + default-compile + + 9 + + + + base-compile + + compile + + + + module-info.java + **/super/**/*.java + + + + maven-source-plugin