eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.21k stars 867 forks source link

build fails with frontend-maven-plugin 1.12.1 but not with 1.12.0 #1024

Open gstanchev opened 2 years ago

gstanchev commented 2 years ago

We use frontend-maven-plugin in a pretty straightforward matter. Recently we bumped the version of the plugin from 1.12.0 to 1.12.1 and the project started failing with the following error

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.1:install-node-and-npm (install node and npm) on project bosun-api-parent: Execution install node and npm of goal com.github.eirslett:frontend-maven-plugin:1.12.1:install-node-and-npm failed: A required class was missing while executing com.github.eirslett:frontend-maven-plugin:1.12.1:install-node-and-npm: org/apache/http/protocol/HttpContext
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>com.github.eirslett:frontend-maven-plugin:1.12.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/gstanchev/.m2/com/github/eirslett/frontend-maven-plugin/1.12.1/frontend-maven-plugin-1.12.1.jar
[ERROR] urls[1] = file:/C:/Users/gstanchev/.m2/com/github/eirslett/frontend-plugin-core/1.12.1/frontend-plugin-core-1.12.1.jar
[ERROR] urls[2] = file:/C:/Users/gstanchev/.m2/com/fasterxml/jackson/core/jackson-core/2.13.0/jackson-core-2.13.0.jar
[ERROR] urls[3] = file:/C:/Users/gstanchev/.m2/com/fasterxml/jackson/core/jackson-databind/2.13.0/jackson-databind-2.13.0.jar
[ERROR] urls[4] = file:/C:/Users/gstanchev/.m2/com/fasterxml/jackson/core/jackson-annotations/2.13.0/jackson-annotations-2.13.0.jar
[ERROR] urls[5] = file:/C:/Users/gstanchev/.m2/org/apache/commons/commons-compress/1.21/commons-compress-1.21.jar
[ERROR] urls[6] = file:/C:/Users/gstanchev/.m2/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar
[ERROR] urls[7] = file:/C:/Users/gstanchev/.m2/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar
[ERROR] urls[8] = file:/C:/Users/gstanchev/.m2/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar
[ERROR] urls[9] = file:/C:/Users/gstanchev/.m2/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[10] = file:/C:/Users/gstanchev/.m2/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar
[ERROR] urls[11] = file:/C:/Users/gstanchev/.m2/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[12] = file:/C:/Users/gstanchev/.m2/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
[ERROR] urls[13] = file:/C:/Users/gstanchev/.m2/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.3/org.eclipse.sisu.inject-0.3.3.jar
[ERROR] urls[14] = file:/C:/Users/gstanchev/.m2/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[15] = file:/C:/Users/gstanchev/.m2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
[ERROR] urls[16] = file:/C:/Users/gstanchev/.m2/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : org.apache.http.protocol.HttpContext

running with --debug produces the following exception (cut short for brevity):

Caused by: java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
    at com.github.eirslett.maven.plugins.frontend.lib.FrontendPluginFactory.getNodeInstaller (FrontendPluginFactory.java:25)
    at com.github.eirslett.maven.plugins.frontend.mojo.InstallNodeAndNpmMojo.execute (InstallNodeAndNpmMojo.java:96)
    at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute (AbstractFrontendMojo.java:94)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

I noticed that in 1.12.1, the version of httpclient was updated to the latest (4.5.13) from 4.5.2. The pom file of the plugin also doesn't include httpcore which contains the HttpContext interface which appears to be referenced. Is it possible the Apache Http Client/Core to have refactored/moved stuff where httpcore is now required also to be included thus now the execution of the plugin fails?

I also have the following extended output

[WARNING] The POM for org.apache.httpcomponents:httpclient:jar:4.5.13 is invalid, transitive dependencies (if any) will not be available: 3 problems were encountered while building the effective model for org.apache.httpcomponents:httpclient:4.5.13
[ERROR] Invalid packaging for parent POM org.apache.httpcomponents:httpclient:4.5.13, must be "pom" but is "jar" @ 
[ERROR] Invalid packaging for parent POM org.apache.httpcomponents:httpclient:4.5.13, must be "pom" but is "jar" @ 
[FATAL] The parents form a cycle: org.apache.httpcomponents:httpclient:4.5.13 -> org.apache.httpcomponents:httpclient:4.5.13 @ 

Anyways, any help/workaround is appreciated...

gstanchev commented 2 years ago

Additionally, if i pull "master" from this project and "mvn clean package", it fails to compile with

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[14,23] package org.apache.http does not exist
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[70,42] cannot access org.apache.http.HttpResponse
  class file for org.apache.http.HttpResponse not found
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[75,71] cannot find symbol
  symbol:   method getEntity()
  location: variable response of type org.apache.http.client.methods.CloseableHttpResponse
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[103,64] cannot access org.apache.http.message.AbstractHttpMessage
  class file for org.apache.http.message.AbstractHttpMessage not found
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[105,49] cannot access org.apache.http.HttpRequest
  class file for org.apache.http.HttpRequest not found
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[119,15] cannot find symbol
  symbol:   class HttpHost
  location: class com.github.eirslett.maven.plugins.frontend.lib.DefaultFileDownloader
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[119,44] cannot find symbol
  symbol:   class HttpHost
  location: class com.github.eirslett.maven.plugins.frontend.lib.DefaultFileDownloader
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[148,9] cannot find symbol
  symbol:   class HttpHost
  location: class com.github.eirslett.maven.plugins.frontend.lib.DefaultFileDownloader
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[148,31] cannot find symbol
  symbol:   class HttpHost
  location: class com.github.eirslett.maven.plugins.frontend.lib.DefaultFileDownloader
[ERROR] /D:/work/ITOM/playground/frontend-maven-plugin/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/FileDownloader.java:[155,59] cannot access org.apache.http.protocol.HttpCoreContext
  class file for org.apache.http.protocol.HttpCoreContext not found

But if i add

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.15</version>
        </dependency>

to "frontend-maven-plugin/frontend-plugin-core/pom.xml" it builds cleanly. I am not sure if the issue is on my end because obviously the project was built and released without httpcore...

gstanchev commented 2 years ago

Okay, so after building and installing 1.12.2-SNAPSHOT locally with added httpcore dependency, and pointing our project to use that, tests are no longer failing so I can confirm it fixes the issue for us