Skip to content

Commit ad1f8d1

Browse files
committed
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.
1 parent c04ad9e commit ad1f8d1

File tree

29 files changed

+159
-118
lines changed

29 files changed

+159
-118
lines changed

core/pom.xml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.google.truth</groupId>
77
<artifactId>truth-parent</artifactId>
8-
<version>HEAD-SNAPSHOT</version>
8+
<version>999.0.0-SNAPSHOT</version>
99
</parent>
1010
<artifactId>truth</artifactId>
1111
<name>Truth Core</name>
@@ -98,23 +98,6 @@
9898
</path>
9999
</annotationProcessorPaths>
100100
</configuration>
101-
<executions>
102-
<execution>
103-
<id>compile-java9</id>
104-
<goals>
105-
<goal>compile</goal>
106-
</goals>
107-
<configuration>
108-
<release>9</release>
109-
<compileSourceRoots>
110-
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
111-
</compileSourceRoots>
112-
<multiReleaseOutput>true</multiReleaseOutput>
113-
<useIncrementalCompilation>false</useIncrementalCompilation>
114-
<moduleVersion>1.0</moduleVersion>
115-
</configuration>
116-
</execution>
117-
</executions>
118101
</plugin>
119102
<plugin>
120103
<artifactId>maven-source-plugin</artifactId>

core/src/main/java9/module-info.java renamed to core/src/main/java/module-info.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
module com.google.truth {
1818
requires com.google.common;
1919
requires junit;
20+
requires java.compiler;
2021

2122
requires static org.jspecify;
2223
requires static com.google.errorprone.annotations;
2324
requires static org.objectweb.asm;
2425
requires static auto.value.annotations;
26+
requires static com.google.j2objc.annotations;
2527

2628
exports com.google.common.truth;
2729
}

extensions/java8/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.google.truth.extensions</groupId>
99
<artifactId>truth-extensions-parent</artifactId>
10-
<version>HEAD-SNAPSHOT</version>
10+
<version>999.0.0-SNAPSHOT</version>
1111
</parent>
1212
<artifactId>truth-java8-extension</artifactId>
1313
<name>Obsolete Truth Extension for Java8</name>

extensions/liteproto/pom.xml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.google.truth.extensions</groupId>
99
<artifactId>truth-extensions-parent</artifactId>
10-
<version>HEAD-SNAPSHOT</version>
10+
<version>999.0.0-SNAPSHOT</version>
1111
</parent>
1212
<artifactId>truth-liteproto-extension</artifactId>
1313
<name>Truth Extension for Lite Protocol Buffers</name>
@@ -96,21 +96,6 @@
9696
</path>
9797
</annotationProcessorPaths>
9898
</configuration>
99-
<executions>
100-
<execution>
101-
<id>compile-java9</id>
102-
<goals>
103-
<goal>compile</goal>
104-
</goals>
105-
<configuration>
106-
<release>9</release>
107-
<compileSourceRoots>
108-
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
109-
</compileSourceRoots>
110-
<multiReleaseOutput>true</multiReleaseOutput>
111-
</configuration>
112-
</execution>
113-
</executions>
11499
</plugin>
115100
<plugin>
116101
<artifactId>maven-jar-plugin</artifactId>
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.common.truth.extensions.proto;
17+
package com.google.common.truth.extensions.liteproto;
1818

1919
import static com.google.common.base.Strings.lenientFormat;
2020
import static com.google.common.truth.Fact.fact;
2121
import static com.google.common.truth.Fact.simpleFact;
22-
import static com.google.common.truth.extensions.proto.Platform.getTrimmedToString;
22+
import static com.google.common.truth.extensions.liteproto.Platform.getTrimmedToString;
2323

2424
import com.google.common.annotations.GwtIncompatible;
2525
import com.google.common.annotations.J2ktIncompatible;
2626
import com.google.common.truth.FailureMetadata;
2727
import com.google.common.truth.IntegerSubject;
2828
import com.google.common.truth.Subject;
29+
import com.google.common.truth.extensions.liteproto.internal.LiteProtoSubjectAccess;
2930
import com.google.errorprone.annotations.CheckReturnValue;
3031
import com.google.j2objc.annotations.J2ObjCIncompatible;
3132
import com.google.protobuf.MessageLite;
@@ -44,6 +45,16 @@
4445
@NullMarked
4546
public class LiteProtoSubject extends Subject {
4647

48+
// Static initializer to register SharedSecrets accessor
49+
static {
50+
LiteProtoSubjectAccess.setAccessor(new LiteProtoSubjectAccess.Accessor() {
51+
@Override
52+
public String getCustomStringRepresentation(LiteProtoSubject subject) {
53+
return subject.actualCustomStringRepresentationForProtoPackageMembersToCall();
54+
}
55+
});
56+
}
57+
4758
/**
4859
* Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert
4960
* things about Lite Protobuf properties.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.common.truth.extensions.proto;
17+
package com.google.common.truth.extensions.liteproto;
1818

1919
import static com.google.common.truth.Truth.assertAbout;
2020

extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/Platform.java renamed to extensions/liteproto/src/main/java/com/google/common/truth/extensions/liteproto/Platform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.common.truth.extensions.proto;
17+
package com.google.common.truth.extensions.liteproto;
1818

1919
import static com.google.common.base.Strings.lenientFormat;
2020

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2024 Google, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.common.truth.extensions.liteproto.internal;
18+
19+
import com.google.common.truth.extensions.liteproto.LiteProtoSubject;
20+
21+
/**
22+
* Provides access to package-private methods in LiteProtoSubject for use by
23+
* other Truth extensions.
24+
*
25+
* <p><b>This is an internal API and should not be used by client code.</b>
26+
* This class may be removed or changed at any time without notice.
27+
*/
28+
public final class LiteProtoSubjectAccess {
29+
30+
/**
31+
* Accessor interface for LiteProtoSubject internal methods.
32+
* Set by LiteProtoSubject during class initialization.
33+
*/
34+
public interface Accessor {
35+
String getCustomStringRepresentation(LiteProtoSubject subject);
36+
}
37+
38+
private static Accessor accessor;
39+
40+
/**
41+
* Sets the accessor. This is called by LiteProtoSubject during class initialization.
42+
*
43+
* @param accessor the accessor implementation
44+
* @throws IllegalStateException if the accessor is already set
45+
*/
46+
public static void setAccessor(Accessor accessor) {
47+
if (LiteProtoSubjectAccess.accessor != null) {
48+
throw new IllegalStateException("Accessor already set");
49+
}
50+
LiteProtoSubjectAccess.accessor = accessor;
51+
}
52+
53+
/**
54+
* Gets the custom string representation for the given LiteProtoSubject.
55+
*
56+
* @param subject the LiteProtoSubject instance
57+
* @return the custom string representation
58+
* @throws IllegalStateException if no accessor has been set
59+
*/
60+
public static String getCustomStringRepresentation(LiteProtoSubject subject) {
61+
if (accessor == null) {
62+
throw new IllegalStateException("No accessor set");
63+
}
64+
return accessor.getCustomStringRepresentation(subject);
65+
}
66+
67+
private LiteProtoSubjectAccess() {}
68+
}

extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/package-info.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

extensions/liteproto/src/main/java9/module-info.java renamed to extensions/liteproto/src/main/java/module-info.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
module com.google.truth.extensions.liteproto {
1818
requires com.google.truth;
1919
requires com.google.common;
20+
requires java.compiler;
2021

2122
requires static org.jspecify;
2223
requires static com.google.errorprone.annotations;
23-
requires static com.google.protobuf.lite;
24+
requires static protobuf.lite;
25+
requires static auto.value.annotations;
26+
requires static com.google.j2objc.annotations;
2427

25-
exports com.google.common.truth.extensions.proto;
28+
exports com.google.common.truth.extensions.liteproto;
29+
exports com.google.common.truth.extensions.liteproto.internal to com.google.truth.extensions.proto;
2630
}

0 commit comments

Comments
 (0)