Vertispan / j2clmavenplugin

Maven plugin to launch new J2CL compilation
https://vertispan.github.io/j2clmavenplugin/
Apache License 2.0
53 stars 26 forks source link

it-tests depend on Java version? #129

Closed xamde closed 11 months ago

xamde commented 2 years ago

After some investigation I suspect the JDK & version in use might affect if IT tests run.

I tried create a local build of the project. mvn clean install. You wouldn't believe what happened next.

[DEBUG] Writing tracking file C:\somedir\.m2\repository\com\vertispan\javascript\closure-compiler-main\0.3-SNAPSHOT\resolver-status.properties
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-main:0.3-SNAPSHOT/maven-metadata.xml in maven-central (https://repo.maven.apache.org/maven2/)
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-main:0.3-SNAPSHOT/maven-metadata.xml in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots)
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-main:0.3-SNAPSHOT/maven-metadata.xml in sonatype-google-snapshots (https://oss.sonatype.org/content/repositories/google-snapshots/)
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-main:0.3-SNAPSHOT/maven-metadata.xml in central (https://repo1.maven.org/maven2)
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-main:0.3-SNAPSHOT/maven-metadata.xml in github-slf4j2cl (https://maven.pkg.github.com/xamde/slf4j2cl)
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-main:0.3-SNAPSHOT/maven-metadata.xml in sonatype-snapshots-repo (https://oss.sonatype.org/content/repositories/snapshots)
[DEBUG] Could not find metadata com.vertispan.javascript:closure-compiler-parent:0.3-SNAPSHOT/maven-metadata.xml in local (C:\somedir\.m2\repository)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.972 s
[INFO] Finished at: 2022-03-02T07:45:36+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Malformed \uxxxx encoding.
java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
    at java.util.Properties.loadConvert (Properties.java:662)
    at java.util.Properties.load0 (Properties.java:455)
    at java.util.Properties.load (Properties.java:408)
    at org.eclipse.aether.internal.impl.TrackingFileManager.read (TrackingFileManager.java:56)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.read (DefaultUpdateCheckManager.java:511)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkMetadata (DefaultUpdateCheckManager.java:250)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolve (DefaultMetadataResolver.java:302)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolveMetadata (DefaultMetadataResolver.java:181)
    at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion (DefaultVersionResolver.java:213)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:282)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
    at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel (DefaultModelResolver.java:172)
    at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel (DefaultModelResolver.java:222)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally (DefaultModelBuilder.java:1077)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent (DefaultModelBuilder.java:853)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:344)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:252)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:297)

Looking into C:\somedir\.m2\repository\com\vertispan\javascript\closure-compiler-main\0.3-SNAPSHOT\resolver-status.properties reveals

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Mar 02 07:45:36 CET 2022
maven-metadata-sonatype-snapshots-plugins.xml.lastUpdated=1643210259565
maven-metadata-sonatype-google-snapshots.xml.lastUpdated=1646203536205
maven-metadata-sonatype-snapshots-repo.xml.lastUpdated=1646203536221
maven-metadata-vertispan-releases.xml.lastUpdated=1646203536218
maven-metadata-sonatype-nexus-snapshots.xml.lastUpdated=1646203536200
maven-metadata-vertispan-snapshots.xml.error=
maven-metadata-maven-central.xml.lastUpdated=1646203536200
maven-metadata-sonatype-snapshots-repo.xml.error=
maven-metadata-github-slf4j2cl.xml.lastUpdated=1646203536214
maven-metadata-central.xml.error=
maven-metadata-vertispan-j2cl.xml.lastUpdated=163869177\u0000\u0000\u0000\u0000\u0000\u0000
maven-metadata-vertispan-snapshots.xml.lastUpdated=1645339659712
maven-\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
maven-metadata-sonatype-google-snapshots.xml.error=
maven-metadata-sonatype-snapshots-plugins.xml.error=
maven-metadata-google-snapshots.xml.error=
maven-metadata-google-snapshots.xml.lastUpdated=1645339659295
maven-metadata-sonatype-nexus-snapshots.xml.error=
maven-metadata-vertispan-releases-plugin.xml.lastUpdated=1643210259564
maven-metadata-github-slf4j2cl.xml.error=
maven-metadata-central.xml.lastUpdated=1646203536209
maven-metadata-maven-central.xml.error=

Where does such a crap comes from?

[INFO] Downloaded from vertispan-releases: https://repo.vertispan.com/j2cl/com/vertispan/javascript/closure-compiler-main/0.3-SNAPSHOT/maven-metadata.xml (618 B at 2.6 kB/s)

Manually downloading with a browser gives us

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>com.vertispan.javascript</groupId>
  <artifactId>closure-compiler-main</artifactId>
  <version>0.3-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20210825.175944</timestamp>
      <buildNumber>5</buildNumber>
    </snapshot>
    <lastUpdated>20210903142937</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>pom</extension>
        <value>0.3-20210825.175944-5</value>
        <updated>20210825175944</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

Is my hard disk dying? Lenovos full disk scan says everything looks OK.

Maybe that was a Maven race condition writing crap (e.g. running from IntelliJ and another one from the command line)?

I delete from my local Maven repo all of /com/vertispan and retry mvn clean install -e -X. We get this

[INFO] Reactor Summary for J2CL Build Tools 0.19-SNAPSHOT:
[INFO] 
[INFO] J2CL Build Tools ................................... SUCCESS [  0.798 s]
[INFO] Build caching tools ................................ SUCCESS [  2.748 s]
[INFO] j2cl-tasks ......................................... SUCCESS [  2.396 s]
[INFO] J2CL Maven Plugin .................................. FAILURE [09:34 min]
[INFO] J2CL Maven Archetypes .............................. SKIPPED
[INFO] Simple J2CL Project Archetype ...................... SKIPPED
[INFO] J2CL+Servlet Project ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

with details

INFO]           annotation-processor-in-reactor\pom.xml .......... FAILED (104.2 s)
[INFO]   The build exited with code 1. See C:\checkoutdir\j2cl-maven-plugin\target\it-tests\annotation-processor-in-reactor\build.log for details.
[INFO]           dependency-replacements\pom.xml .................. FAILED (26.4 s)
[INFO]   The build exited with code 1. See C:\checkoutdir\j2cl-maven-plugin\target\it-tests\dependency-replacements\build.log for details.
[INFO]           elemental2-project\pom.xml ....................... SUCCESS (62.7 s)
[INFO]           failing-htmlunit-test\pom.xml .................... SUCCESS (40.9 s)
[INFO]           hello-world-reactor\pom.xml ...................... FAILED (22.4 s)
[INFO]   The build exited with code 1. See C:\checkoutdir\j2cl-maven-plugin\target\it-tests\hello-world-reactor\build.log for details.
[INFO]           hello-world-single\pom.xml ....................... FAILED (24.3 s)
[INFO]   The build exited with code 1. See C:\checkoutdir\j2cl-maven-plugin\target\it-tests\hello-world-single\build.log for details.
[INFO]           hello-world-web-components\pom.xml ............... SUCCESS (1.9 s)
[INFO]           issue-41\pom.xml ................................. SUCCESS (69.5 s)
[INFO]           java-assertions\pom.xml .......................... SUCCESS (61.1 s)
[INFO]           simple-htmlunit-test\pom.xml ..................... SUCCESS (45.3 s)
[INFO]           static-resources\pom.xml ......................... SUCCESS (49.4 s)
[INFO]           top-level-source-file\pom.xml .................... FAILED (30.8 s)
[INFO]   The build exited with code 1. See C:\checkoutdir\j2cl-maven-plugin\target\it-tests\top-level-source-file\build.log for details.
[INFO]           transitive-dependencies\pom.xml .................. FAILED (27.7 s)
[INFO]   The build exited with code 1. See C:\checkoutdir\j2cl-maven-plugin\target\it-tests\transitive-dependencies\build.log for details.

Lets look into the individual logs then. We start with \j2cl-maven-plugin\target\it-tests\annotation-processor-in-reactor\build.log.

[INFO] Starting annotation-processor-in-reactor:processor:1.0/stripped_bytecode
[ERROR] annotation-processor-in-reactor:processor:1.0/stripped_bytecode: /C:/_data_/_p_/_git/GitHub/j2clmavenplugin/j2cl-maven-plugin/target/it-tests/annotation-processor-in-reactor/app/target/gwt3BuildCache/0.19-SNAPSHOT/annotation-processor-in-reactor-processor-1.0/10ebb01450798db43be2a016db277eeb-stripped_sources/results/com/example/MyProcessor.java:3 package com.google.auto.common does not exist

It seems annotation-processor-in-reactor\processor\pom.xml depends on

        <dependency>
            <groupId>com.google.auto</groupId>
            <artifactId>auto-common</artifactId>
            <version>1.0.1</version>
        </dependency>

which was happily downloaded into the it-repo (this version is not present in my local main maven repo). No idea why that dependency was not found. But the build keeps going on and finally fails with 1) Error injecting constructor, java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties. See next error for details on this one.

Let's check the next build.log and look for patterns. Here is \j2cl-maven-plugin\target\it-tests\dependency-replacements\build.log.

[WARNING] Error injecting: org.apache.maven.plugin.war.WarMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties
  at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source)
  while locating org.apache.maven.plugin.war.WarMojo

...

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project app: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.2:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.2' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Cannot access defaults field of Properties

According to Stackoverflow, this is related to a Java version mismatch with versions of maven war plugin version. I'm running this

openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

\j2cl-maven-plugin\target\it-tests\hello-world-reactor\build.log reports the same ProvisionException. \j2cl-maven-plugin\target\it-tests\hello-world-single\build.log is ProvisionException as well. \j2cl-maven-plugin\target\it-tests\top-level-source-file\build.log is ProvisionException as well. \j2cl-maven-plugin\target\it-tests\transitive-dependencies\build.log same story.

Summary

So we seem to have one issue, most likely a basic version mismatch with the Java version. Write once, run anywhere? ;-)

niloc132 commented 2 years ago

See #159.