Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adding java 7 check #1847

Merged
merged 14 commits into from May 9, 2023
Merged

test: adding java 7 check #1847

merged 14 commits into from May 9, 2023

Conversation

suztomo
Copy link
Member

@suztomo suztomo commented May 8, 2023

We haven't run the Java 7 builds for a while even though the README.md says Java 7 target. Let's clarify the current situation by installing the check again.

It turned out that the google-http-client-jackson2 and google-http-client-appengine modules require Java 8 or higher due to their dependencies. We keep the compilation target for Java 7 so that the users can tweak some old version of the dependencies.

The surefire (unit test) plugin's "jvm" option is the core of this Java 7 check. Guava's warning about Java 7 tells that the test is indeed running on Java 7:

image

https://github.com/googleapis/google-http-java-client/actions/runs/4927699269/jobs/8805047743?pr=1847

Fixes #1713
Closes #1721

@suztomo suztomo requested a review from a team as a code owner May 8, 2023 19:51
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label May 8, 2023
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: s Pull request size is small. labels May 8, 2023
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: l Pull request size is large. labels May 8, 2023
@suztomo
Copy link
Member Author

suztomo commented May 8, 2023

It turned out that Maven wrapper does not work with Java 7.

Error: Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/wrapper/MavenWrapperMain : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:808)

@suztomo
Copy link
Member Author

suztomo commented May 8, 2023

3.6.3 failed: https://github.com/googleapis/google-http-java-client/actions/runs/4919311091/jobs/8786764114?pr=1847


Error: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/fasterxml/jackson/databind/ObjectMapper : Unsupported major.minor version 52.0

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels May 8, 2023
@suztomo
Copy link
Member Author

suztomo commented May 8, 2023

Memo: Maven 3.5.x does not have "-ntp" option.

@suztomo
Copy link
Member Author

suztomo commented May 8, 2023

3.5.4 still failed:

constituent[0]: file:/opt/hostedtoolcache/maven/3.5.4/x64/conf/logging/
constituent[1]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-plugin-api-3.5.4.jar
constituent[2]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/plexus-interpolation-1.24.jar
constituent[3]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-util-1.1.1.jar
constituent[4]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-impl-1.1.1.jar
constituent[5]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/plexus-utils-3.1.0.jar
constituent[6]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/jsr250-api-1.0.jar
constituent[7]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/commons-cli-1.4.jar
constituent[8]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/jcl-over-slf4j-1.7.25.jar
constituent[9]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-compat-3.5.4.jar
constituent[10]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-artifact-3.5.4.jar
constituent[11]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-settings-builder-3.5.4.jar
constituent[12]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-repository-metadata-3.5.4.jar
constituent[13]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/guice-4.2.0-no_aop.jar
constituent[14]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/wagon-http-3.1.0-shaded.jar
constituent[15]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-model-builder-3.5.4.jar
constituent[16]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/commons-io-2.5.jar
constituent[17]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/slf4j-api-1.7.25.jar
constituent[18]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/plexus-component-annotations-1.7.1.jar
constituent[19]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/plexus-cipher-1.7.jar
constituent[20]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-shared-utils-3.2.1.jar
constituent[21]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/guava-20.0.jar
constituent[22]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/wagon-file-3.1.0.jar
constituent[23]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/org.eclipse.sisu.plexus-0.3.3.jar
constituent[24]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-core-3.5.4.jar
constituent[25]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/javax.inject-1.jar
constituent[26]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-settings-3.5.4.jar
constituent[27]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/wagon-provider-api-3.1.0.jar
constituent[28]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-embedder-3.5.4.jar
constituent[29]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/org.eclipse.sisu.inject-0.3.3.jar
constituent[30]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-builder-support-3.5.4.jar
constituent[31]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-provider-3.5.4.jar
constituent[32]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-spi-1.1.1.jar
constituent[33]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/commons-lang3-3.5.jar
constituent[34]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-connector-basic-1.1.1.jar
constituent[35]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/aopalliance-1.0.jar
constituent[36]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-model-3.5.4.jar
constituent[37]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-api-1.1.1.jar
constituent[38]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/jansi-1.17.1.jar
constituent[39]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-resolver-transport-wagon-1.1.1.jar
constituent[40]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/plexus-sec-dispatcher-1.4.jar
constituent[41]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/maven-slf4j-provider-3.5.4.jar
constituent[42]: file:/opt/hostedtoolcache/maven/3.5.4/x64/lib/cdi-api-1.0.jar
---------------------------------------------------
Error: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/fasterxml/jackson/databind/ObjectMapper : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:808)

Where is it coming from? com/fasterxml/jackson/databind/ObjectMapper

@suztomo
Copy link
Member Author

suztomo commented May 9, 2023

sdk install java 7.0.352-zulu still worked to my computer. #1721 (comment)

@suztomo
Copy link
Member Author

suztomo commented May 9, 2023

Using Maven 3.6.3, mvn -V -X tells:

[DEBUG]    org.sonatype.nexus:nexus-client-core:jar:2.15.1-02:compile (exclusions managed from default)
[DEBUG]       org.sonatype.nexus.plugins:nexus-restlet1x-model:jar:2.15.1-02:compile
[DEBUG]       org.slf4j:slf4j-api:jar:1.7.36:compile (version managed from default)
[DEBUG]       com.google.code.findbugs:jsr305:jar:2.0.1:compile
[DEBUG]       com.intellij:annotations:jar:9.0.4:compile (version managed from default)
[DEBUG]       commons-io:commons-io:jar:2.8.0:compile
[DEBUG]       com.thoughtworks.xstream:xstream:jar:1.4.19:compile (version managed from default)
[DEBUG]          io.github.x-stream:mxparser:jar:1.2.2:compile
[DEBUG]             xmlpull:xmlpull:jar:1.1.3.1:compile
[DEBUG]       joda-time:joda-time:jar:2.2:compile
[DEBUG]       commons-lang:commons-lang:jar:2.6:compile
[DEBUG]       commons-beanutils:commons-beanutils:jar:1.9.4:compile (version managed from default) (exclusions managed from default)
[DEBUG]          commons-collections:commons-collections:jar:3.2.2:compile
[DEBUG]       org.sonatype.sisu.siesta:siesta-client:jar:1.8:compile
[DEBUG]          org.sonatype.sisu.siesta:siesta-common:jar:1.8:compile
[DEBUG]             javax.ws.rs:jsr311-api:jar:1.1.1:compile
[DEBUG]             com.sun.jersey:jersey-core:jar:1.17.1:compile
[DEBUG]             javax.validation:validation-api:jar:1.1.0.Final:compile
[DEBUG]          com.sun.jersey:jersey-client:jar:1.17.1:compile
[DEBUG]          com.sun.jersey.contribs:jersey-apache-client4:jar:1.17.1:compile
[DEBUG]       org.sonatype.sisu.siesta:siesta-jackson:jar:1.8:compile
[DEBUG]          com.fasterxml.jackson.core:jackson-annotations:jar:2.13.2:compile (version managed from default)
[DEBUG]          com.fasterxml.jackson.core:jackson-core:jar:2.13.2:compile (version managed from default)
[DEBUG]          com.fasterxml.jackson.core:jackson-databind:jar:2.13.2.2:compile (version managed from default)
[DEBUG]          com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.13.2:compile (version managed from default)
[DEBUG]             com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.13.2:compile

@suztomo
Copy link
Member Author

suztomo commented May 9, 2023

After commenting out "nexus-staging-maven-plugin", now the error is on os-maven-plugin:

[ERROR] Internal error: com.google.inject.ProvisionException: Unable to provision, see the following errors:
[ERROR] 
[ERROR] 1) Error in custom provider, java.lang.TypeNotPresentException: Type kr.motd.maven.os.DetectExtension not present
[ERROR]   at ClassRealm[extension>kr.motd.maven:os-maven-plugin:1.7.1, parent: sun.misc.Launcher$AppClassLoader@60437dcb] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR]   while locating org.apache.maven.AbstractMavenLifecycleParticipant annotated with @com.google.inject.name.Named(value=detect-os)
[ERROR] 
[ERROR] 1 error: kr/motd/maven/os/DetectExtension : Unsupported major.minor version 52.0
[ERROR] -> [Help 1]

After that, now it's enforcer plugin:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.1.0:enforce (enforce-maven) on project google-http-client-parent: Execution enforce-maven of goal org.apache.maven.plugins:maven-enforcer-plugin:3.1.0:enforce failed: Unable to load the mojo 'enforce' in the plugin 'org.apache.maven.plugins:maven-enforcer-plugin:3.1.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/apache/maven/plugins/enforcer/EnforceMojo : Unsupported major.minor version 52.0

Note that -Denforcer.skip does not solve this.

https://gist.github.com/suztomo/af1d49b2e4cebb57246dbbf5438d30d8

maven-javadoc-plugin too.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.5.0:jar (attach-javadocs) on project google-http-client-parent: Execution attach-javadocs of goal org.apache.maven.plugins:maven-javadoc-plugin:3.5.0:jar failed: Unable to load the mojo 'jar' in the plugin 'org.apache.maven.plugins:maven-javadoc-plugin:3.5.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/apache/maven/plugins/javadoc/JavadocJar : Unsupported major.minor version 52.0

Maven resource plugin too.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.0:resources (default-resources) on project google-http-client: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.3.0:resources failed: Unable to load the mojo 'resources' in the plugin 'org.apache.maven.plugins:maven-resources-plugin:3.3.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/apache/maven/plugins/resources/ResourcesMojo : Unsupported major.minor version 52.0

@suztomo
Copy link
Member Author

suztomo commented May 9, 2023

Maven-surefire-plugin has "jvm" option https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm.

However, when I used it /google-http-java-client$ mvn test --batch-mode --show-version -Dclirr.skip=true -Denforcer.skip=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -T 1C -Djvm=/usr/local/google/home/suztomo/.sdkman/candidates/java/7.0.352-zulu/bin/java, it failed:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/surefire/booter/ForkedBooter : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:808)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

@suztomo
Copy link
Member Author

suztomo commented May 9, 2023

It finally ran https://gist.github.com/suztomo/270f6fb08ed7b8683d283a3f88f6d0e8:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Parent for the Google HTTP Client Library for Java 1.43.2-SNAPSHOT:
[INFO] 
[INFO] Parent for the Google HTTP Client Library for Java . SUCCESS [  0.618 s]
[INFO] Google HTTP Client Library for Java ................ SUCCESS [ 16.377 s]
[INFO] Android Platform Extensions to the Google HTTP Client Library for Java. SUCCESS [  0.956 s]
[INFO] Apache HTTP transport v2 for the Google HTTP Client Library for Java. SUCCESS [  2.744 s]
[INFO] Shared classes used for testing of artifacts in the Google HTTP Client Library for Java. SUCCESS [  1.592 s]
[INFO] Google App Engine extensions to the Google HTTP Client Library for Java. FAILURE [  2.181 s]
[INFO] GSON extensions to the Google HTTP Client Library for Java. SUCCESS [  1.440 s]
[INFO] Jackson 2 extensions to the Google HTTP Client Library for Java. FAILURE [  1.349 s]
[INFO] Protocol Buffer extensions to the Google HTTP Client Library for Java. SUCCESS [  2.881 s]
[INFO] XML extensions to the Google HTTP Client Library for Java. SUCCESS [  1.447 s]
[INFO] Assembly for the Google HTTP Client Library for Java SKIPPED
[INFO] Google APIs Client Library Findbugs custom plugin. . SUCCESS [  0.485 s]
[INFO] Simple example for the Dailymotion API. ............ SKIPPED
[INFO] Google HTTP Client Library for Java BOM ............ SUCCESS [  0.007 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21.488 s (Wall Clock)
[INFO] Finished at: 2023-05-09T11:03:39-04:00

The surefire plugin version is set to 2.22.2.

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • .github/sync-repo-settings.yaml

-Dclirr.skip=true -Denforcer.skip=true -Dmaven.javadoc.skip=true \
-Dgcloud.download.skip=true -T 1C \
-Dproject.surefire.version=2.22.2 \
-Djvm=${JAVA7_HOME}/bin/java
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -581,6 +581,7 @@
<project.httpcore.version>4.4.16</project.httpcore.version>
<project.opencensus.version>0.31.1</project.opencensus.version>
<project.root-directory>..</project.root-directory>
<project.surefire.version>3.0.0-M7</project.surefire.version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By moving the version value to the property, we can set it via -Dproject.surefire.version=2.22.2.

@suztomo
Copy link
Member Author

suztomo commented May 9, 2023

Guava's warning about Java 7 tells that the test is indeed running on Java 7:

image

https://github.com/googleapis/google-http-java-client/actions/runs/4927699269/jobs/8805047743?pr=1847

@suztomo suztomo requested a review from lqiu96 May 9, 2023 15:41
@suztomo suztomo changed the title test: adding java 7 build test: adding java 7 check May 9, 2023
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.8.8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is the last version of maven that supports Java 7, right? I don't think anyone is going to manually update this, but would it helpful to add a blurb as to why this set to 3.8.8 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this Maven does not need to work for Java 7. In fact this check does not run Maven via Java 7. (Maven calls Java 7 when running surefire unit tests)

Copy link

@lqiu96 lqiu96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@suztomo suztomo merged commit 98625f6 into googleapis:main May 9, 2023
15 checks passed
@suztomo suztomo deleted the java7_build branch May 9, 2023 16:04
suztomo added a commit to suztomo/google-api-java-client that referenced this pull request May 15, 2023
Using the same method as googleapis/google-http-java-client#1847
to use surefire's jvm system property
suztomo added a commit to suztomo/google-api-java-client that referenced this pull request May 15, 2023
Using the same method as googleapis/google-http-java-client#1847
to use surefire's jvm system property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java 7 test
2 participants