takari / polyglot-maven

Support alternative markup for Apache Maven POM files
Eclipse Public License 1.0
893 stars 101 forks source link

[clojure] Clojure runtime fails to initialize while parsing pom.clj #239

Open ghost opened 2 years ago

ghost commented 2 years ago

This is a very similar problem to #117 , but happens much earlier, while parsing pom.clj.

To reproduce: create a .mvn/extensions.xml and a minimal pom.clj:

(defmaven 'foo/bar "0.1.0"
  :model-version "4.0.0"

  :name "experiment")

With maven 3.8.4 (haven't tried other versions, JVM version doesn't seem to matter), run any goal, or no goal at all:

$ mvn
Picked up JAVA_TOOL_OPTIONS: -Xmx2g -XX:+PerfDisableSharedMem
[INFO] Scanning for projects...
---------------------------------------------------
constituent[0]: file:/opt/maven/conf/logging/
constituent[1]: file:/opt/maven/lib/plexus-interpolation-1.26.jar
constituent[2]: file:/opt/maven/lib/maven-settings-builder-3.8.4.jar
constituent[3]: file:/opt/maven/lib/plexus-cipher-2.0.jar
constituent[4]: file:/opt/maven/lib/maven-slf4j-provider-3.8.4.jar
constituent[5]: file:/opt/maven/lib/maven-repository-metadata-3.8.4.jar
constituent[6]: file:/opt/maven/lib/commons-cli-1.4.jar
constituent[7]: file:/opt/maven/lib/javax.inject-1.jar
constituent[8]: file:/opt/maven/lib/org.eclipse.sisu.plexus-0.3.5.jar
constituent[9]: file:/opt/maven/lib/guava-25.1-android.jar
constituent[10]: file:/opt/maven/lib/maven-artifact-3.8.4.jar
constituent[11]: file:/opt/maven/lib/wagon-file-3.4.3.jar
constituent[12]: file:/opt/maven/lib/maven-model-3.8.4.jar
constituent[13]: file:/opt/maven/lib/maven-model-builder-3.8.4.jar
constituent[14]: file:/opt/maven/lib/maven-core-3.8.4.jar
constituent[15]: file:/opt/maven/lib/plexus-utils-3.3.0.jar
constituent[16]: file:/opt/maven/lib/maven-resolver-impl-1.6.3.jar
constituent[17]: file:/opt/maven/lib/plexus-component-annotations-2.1.0.jar
constituent[18]: file:/opt/maven/lib/guice-4.2.2-no_aop.jar
constituent[19]: file:/opt/maven/lib/commons-io-2.6.jar
constituent[20]: file:/opt/maven/lib/maven-resolver-spi-1.6.3.jar
constituent[21]: file:/opt/maven/lib/jcl-over-slf4j-1.7.32.jar
constituent[22]: file:/opt/maven/lib/jansi-2.4.0.jar
constituent[23]: file:/opt/maven/lib/maven-resolver-transport-wagon-1.6.3.jar
constituent[24]: file:/opt/maven/lib/plexus-sec-dispatcher-2.0.jar
constituent[25]: file:/opt/maven/lib/slf4j-api-1.7.32.jar
constituent[26]: file:/opt/maven/lib/wagon-provider-api-3.4.3.jar
constituent[27]: file:/opt/maven/lib/maven-embedder-3.8.4.jar
constituent[28]: file:/opt/maven/lib/maven-builder-support-3.8.4.jar
constituent[29]: file:/opt/maven/lib/maven-resolver-connector-basic-1.6.3.jar
constituent[30]: file:/opt/maven/lib/maven-resolver-api-1.6.3.jar
constituent[31]: file:/opt/maven/lib/maven-resolver-provider-3.8.4.jar
constituent[32]: file:/opt/maven/lib/maven-resolver-util-1.6.3.jar
constituent[33]: file:/opt/maven/lib/org.eclipse.sisu.inject-0.3.5.jar
constituent[34]: file:/opt/maven/lib/commons-lang3-3.8.1.jar
constituent[35]: file:/opt/maven/lib/maven-compat-3.8.4.jar
constituent[36]: file:/opt/maven/lib/maven-shared-utils-3.3.4.jar
constituent[37]: file:/opt/maven/lib/javax.annotation-api-1.2.jar
constituent[38]: file:/opt/maven/lib/maven-settings-3.8.4.jar
constituent[39]: file:/opt/maven/lib/maven-plugin-api-3.8.4.jar
constituent[40]: file:/opt/maven/lib/wagon-http-3.4.3-shaded.jar
---------------------------------------------------
Exception in thread "main" java.lang.ExceptionInInitializerError
        at org.sonatype.maven.polyglot.clojure.ClojureModelReader.read(ClojureModelReader.java:42)
        at org.sonatype.maven.polyglot.io.ModelReaderSupport.read(ModelReaderSupport.java:38)
        at org.sonatype.maven.polyglot.io.ModelReaderSupport.read(ModelReaderSupport.java:31)
        at org.sonatype.maven.polyglot.TeslaModelProcessor.read(TeslaModelProcessor.java:119)
        at org.sonatype.maven.polyglot.TeslaModelProcessor.read(TeslaModelProcessor.java:101)
        at org.apache.maven.model.building.DefaultModelBuilder.readModel(DefaultModelBuilder.java:559)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:288)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:252)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:448)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:414)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:377)
        at org.sonatype.maven.polyglot.TeslaProjectBuilder.build(TeslaProjectBuilder.java:43)
        at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:414)
        at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:405)
        at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:82)
        at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:507)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.
        at clojure.lang.RT.load(RT.java:462)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.lang.RT.<clinit>(RT.java:338)
        ... 30 more

I'm not sure exactly what causes it, but was able to fix it, thanks to half-educated guesses and stackoverflow.