Search code examples
mavenmaven-frontend-plugin

Maven frontend plugin is running twice on mvn install


The frontend module pom is just configured with:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.12.1</version>
    <configuration>
        <workingDirectory>./</workingDirectory>
        <nodeVersion>v18.8.0</nodeVersion>
        <npmVersion>8.18.0</npmVersion>
    </configuration>
    <executions>
        <execution>
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
        </execution>
        <execution>
            <id>npm install</id>
            <goals>
                <goal>npm</goal>
            </goals>
        </execution>
        <execution>
            <id>npm run build</id>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>run build</arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

And in angular.json I just changed the target to get the maven clean plugin working without extra configuration:

"outputPath": "target/frontend",

Result when inside the module directory:

  • mvn package: executed once
  • mvn install: executed twice

Logs:

mvn install -DskipTests 
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< com.foo.datagen:frontend >-------------------
[INFO] Building frontend 0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:install-node-and-npm (install node and npm) @ frontend ---
[INFO] Node v18.8.0 is already installed.
[INFO] NPM 8.18.0 is already installed.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:npm (npm install) @ frontend ---
[INFO] Running 'npm install' in /.../frontend
[INFO] 
[INFO] added 1040 packages, and audited 1041 packages in 22s
[INFO] 
[INFO] 123 packages are looking for funding
[INFO]   run `npm fund` for details
[INFO] 
[INFO] 11 high severity vulnerabilities
[INFO] 
[INFO] To address issues that do not require attention, run:
[INFO]   npm audit fix
[INFO] 
[INFO] To address all issues (including breaking changes), run:
[INFO]   npm audit fix --force
[INFO] 
[INFO] Run `npm audit` for details.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:npm (npm run build) @ frontend ---
[INFO] Running 'npm run build' in /.../frontend
[INFO] 
[INFO] > [email protected] build
[INFO] > ng build
[INFO] 
[INFO] - Generating browser application bundles (phase: setup)...
[INFO] Processing legacy "View Engine" libraries:
[INFO] - @ctrl/ngx-codemirror [es2015/esm2015] (scttcper/ngx-codemirror)
[INFO] Encourage the library authors to publish an Ivy distribution.
[INFO] ✔ Browser application bundle generation complete.
[INFO] ✔ Browser application bundle generation complete.
[INFO] - Copying assets...
[INFO] ✔ Copying assets complete.
[INFO] - Generating index html...
[INFO] ✔ Index html generation complete.
[INFO] 
[INFO] Initial Chunk Files           | Names         |  Raw Size | Estimated Transfer Size
[INFO] main.c1261d1eeee700ca.js      | main          |   2.04 MB |               435.69 kB
[INFO] scripts.90b6764e1f8f981b.js   | scripts       | 481.01 kB |                45.68 kB
[INFO] styles.f9e27c2e36f079fb.css   | styles        | 291.76 kB |                33.56 kB
[INFO] polyfills.21fceb59526882bc.js | polyfills     |  33.13 kB |                10.74 kB
[INFO] runtime.896b07ca8815e68d.js   | runtime       |   1.19 kB |               684 bytes
[INFO] 
[INFO] | Initial Total |   2.83 MB |               526.34 kB
[INFO] 
[INFO] Build at: 2022-10-30T09:37:17.525Z - Hash: 069c25b6955c3763 - Time: 12770ms
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ frontend ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /.../frontend/src/main/resources
[INFO] skip non existing resourceDirectory /.../frontend/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ frontend ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ frontend ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /.../frontend/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ frontend ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ frontend ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ frontend ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /.../frontend/target/frontend-0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M7:integration-test (default) @ frontend ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M7:verify (default) @ frontend ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ frontend ---
[INFO] Installing /.../frontend/target/frontend-0.1-SNAPSHOT.jar to /.../frontend/0.1-SNAPSHOT/frontend-0.1-SNAPSHOT.jar
[INFO] Installing /.../frontend/pom.xml to /.../frontend/0.1-SNAPSHOT/frontend-0.1-SNAPSHOT.pom
[INFO] 
[INFO] >>> maven-surefire-report-plugin:3.0.0-M7:report (default) > [surefire]test @ frontend >>>
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:install-node-and-npm (install node and npm) @ frontend ---
[INFO] Node v18.8.0 is already installed.
[INFO] NPM 8.18.0 is already installed.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:npm (npm install) @ frontend ---
[INFO] Running 'npm install' in /.../frontend
[INFO] 
[INFO] removed 1 package, and audited 1041 packages in 2s
[INFO] 
[INFO] 123 packages are looking for funding
[INFO]   run `npm fund` for details
[INFO] 
[INFO] 11 high severity vulnerabilities
[INFO] 
[INFO] To address issues that do not require attention, run:
[INFO]   npm audit fix
[INFO] 
[INFO] To address all issues (including breaking changes), run:
[INFO]   npm audit fix --force
[INFO] 
[INFO] Run `npm audit` for details.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.1:npm (npm run build) @ frontend ---
[INFO] Running 'npm run build' in /.../frontend
[INFO] 
[INFO] > [email protected] build
[INFO] > ng build
[INFO] 
[INFO] - Generating browser application bundles (phase: setup)...
[INFO] ✔ Browser application bundle generation complete.
[INFO] ✔ Browser application bundle generation complete.
[INFO] - Copying assets...
[INFO] ✔ Copying assets complete.
[INFO] - Generating index html...
[INFO] ✔ Index html generation complete.
[INFO] 
[INFO] Initial Chunk Files           | Names         |  Raw Size | Estimated Transfer Size
[INFO] main.c1261d1eeee700ca.js      | main          |   2.04 MB |               435.69 kB
[INFO] scripts.90b6764e1f8f981b.js   | scripts       | 481.01 kB |                45.68 kB
[INFO] styles.f9e27c2e36f079fb.css   | styles        | 291.76 kB |                33.56 kB
[INFO] polyfills.21fceb59526882bc.js | polyfills     |  33.13 kB |                10.74 kB
[INFO] runtime.896b07ca8815e68d.js   | runtime       |   1.19 kB |               684 bytes
[INFO] 
[INFO] | Initial Total |   2.83 MB |               526.34 kB
[INFO] 
[INFO] Build at: 2022-10-30T09:37:33.002Z - Hash: 069c25b6955c3763 - Time: 10010ms
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ frontend ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /.../frontend/src/main/resources
[INFO] skip non existing resourceDirectory /.../frontend/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ frontend ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ frontend ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /.../frontend/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ frontend ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ frontend ---
[INFO] Tests are skipped.
[INFO] 
[INFO] <<< maven-surefire-report-plugin:3.0.0-M7:report (default) < [surefire]test @ frontend <<<
[INFO] 
[INFO] 
[INFO] --- maven-surefire-report-plugin:3.0.0-M7:report (default) @ frontend ---
[WARNING] Unable to locate Test Source XRef to link to - DISABLED
[INFO] 
[INFO] --- maven-surefire-report-plugin:3.0.0-M7:failsafe-report-only (default) @ frontend ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  54.770 s
[INFO] Finished at: 2022-10-30T10:37:33+01:00
[INFO] ------------------------------------------------------------------------

Why the the execution id npm run build is executed twice ?

Context: java 17 & angular 14


Solution

  • Root cause found: removing maven-surefire-report-plugin from parent pom (declared in pluginManagement) solves the problem.

    I have no explanation.