frontend-maven-plugin fails npm install - maven

I can use the command line to run npm install and npm run build on my project but when I try to use the frontend-maven-plugin it fails with the following error
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] app_name [pom]
[INFO] frontend [jar]
[INFO] backend [jar]
[INFO]
[INFO] ---------------------< com.flareback-domain:app_name >----------------------
[INFO] Building app_name 1.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # app_name ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # app_name ---
[INFO] Installing /Users/flareback/code/app_name/pom.xml to /Users/flareback/.m2/repository/com/flareback-domain/app_name/1.0-SNAPSHOT/app_name-1.0-SNAPSHOT.pom
[INFO]
[INFO] ----------------------< com.flareback-domain:frontend >----------------------
[INFO] Building frontend 1.0-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # frontend ---
[INFO] Deleting /Users/flareback/code/app_name/frontend/target
[INFO]
[INFO] --- frontend-maven-plugin:1.9.1:install-node-and-npm (install node and npm) # frontend ---
[INFO] Node v12.14.1 is already installed.
[INFO]
[INFO] --- frontend-maven-plugin:1.9.1:npm (npm install) # frontend ---
[INFO] Running 'npm install' in /Users/flareback/code/app_name/frontend
[INFO] internal/modules/cjs/loader.js:796
[INFO] throw err;
[INFO] ^
[INFO]
[INFO] Error: Cannot find module './internal/streams/buffer_list'
[INFO] Require stack:
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/readable.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/index.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/log.js
[INFO] - /Users/flareback/code/app_name/frontend/node/node_modules/npm/bin/npm-cli.js
[INFO] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
[INFO] at Function.Module._load (internal/modules/cjs/loader.js:686:27)
[INFO] at Module.require (internal/modules/cjs/loader.js:848:19)
[INFO] at require (internal/modules/cjs/helpers.js:74:18)
[INFO] at Object.<anonymous> (/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:72:18)
[INFO] at Module._compile (internal/modules/cjs/loader.js:955:30)
[INFO] at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
[INFO] at Module.load (internal/modules/cjs/loader.js:811:32)
[INFO] at Function.Module._load (internal/modules/cjs/loader.js:723:14)
[INFO] at Module.require (internal/modules/cjs/loader.js:848:19) {
[INFO] code: 'MODULE_NOT_FOUND',
[INFO] requireStack: [
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js',
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/readable-stream/readable.js',
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js',
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js',
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/index.js',
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/node_modules/npmlog/log.js',
[INFO] '/Users/flareback/code/app_name/frontend/node/node_modules/npm/bin/npm-cli.js'
[INFO] ]
[INFO] }
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for app_name 1.0-SNAPSHOT:
[INFO]
[INFO] app_name ........................................... SUCCESS [ 0.279 s]
[INFO] frontend ........................................... FAILURE [ 0.438 s]
[INFO] backend ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.902 s
[INFO] Finished at: 2020-02-04T10:34:21-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.9.1:npm (npm install) on project frontend: Failed to run task: 'npm install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :frontend
My frontend pom file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>frontend</artifactId>
<parent>
<artifactId>app_name</artifactId>
<groupId>com.flareback-domain</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<frontend-maven-plugin.version>1.9.1</frontend-maven-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v12.14.1</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

I changed my pom to use a different node version
<nodeVersion>v9.11.1</nodeVersion>
I then ran mvn clean install. That failed but it got past the install part and failed on the run build. Then I switched back to <nodeVersion>v12.14.1</nodeVersion> and re-ran the mvn clean install and it worked.

I added node and npm version same as my local machine version then this error disappered
<properties>
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
<node.version>v12.18.1</node.version>
<npm.version>6.14.5</npm.version>
</properties>

I have this error but my issue is that I added "v" before npm version.
If you get node version, node --version you'll get "v12.3.4" but if you get npm version, you 'll get "5.4.3".
In pom file,
<properties>
<node.version>v16.13.0</node.version>
<npm.version>8.1.0</npm.version> <java.version>11</java.version>
</properties>

I upgraded the Node LTS version and now it works.

It's node version issue. Also possible that your global node version mismatches.
I have implemented following code with node version 10.16.0
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<nodeVersion>v10.16.0</nodeVersion>
<npmVersion>6.10.2</npmVersion>
<workingDirectory>./angular</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run-script build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run-script build</arguments>
</configuration>
</execution>
</executions>
</plugin>
If this still not work, try clearing npm cache with force attribute
npm cache clean --force
Thanks for reading.

Had the same problem. Turn out I just had forgotten to add the 'v' in my node version.

change node version and npm version in the pom file to the node and npm versions that are installed in your local machine. Then run a mvn clean install. It will solve your issue.
This is how i did it.
(1) This is the node and npm versions that are in the project earlier
node - v10.15.2
npm - 6.4.1
(2)This is after i changed the versions
node - v14.19.1
npm - 6.14.16
(3)Then run mvn clean install.
Your problem sould be solved.

Related

maven -P option not working with mvn clean install

When I try to build the project using
mvn clean package -P dev, it activates the dev profile and performs the build. But when I try with mvn clean install -P dev, it builds all the profiles.
I have more than one profiles in my pom.xml.
<profiles>
<!-- The Configuration of the development profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>dev</build.profile.id>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<!-- The Configuration of the integration-test profile -->
<profile>
<id>integration-test</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<build.profile.id>integration-test</build.profile.id>
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
</profiles>
Also tried with mvn clean install --activate-profiles=dev, but with same results. Even -D option also did not work.
========================Update=====================================
Please find the complete POM here:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myservice</groupId>
<artifactId>myservicename</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<!-- Below property indicates the pattern of the test suite -->
<runSuite>**/*Test.class</runSuite>
</properties>
<profiles>
<!-- The Configuration of the development profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>dev</build.profile.id>
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<!-- The Configuration of the integration-test profile -->
<profile>
<id>integration-test</id>
<properties>
<build.profile.id>integration-test</build.profile.id>
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
</profile>
</profiles>
<dependencies>
<!-- All Dependencies -->
</dependencies>
<build>
<plugins>
<!-- Adds source and resource directories to build -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<!-- Add a new source directory to our build -->
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<!-- Configures the source directory of our integration tests -->
<sources>
<source>src/integration-test/java</source>
</sources>
</configuration>
</execution>
<!-- Add a new resource directory to our build -->
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<!-- Configures the resource directory of our integration tests -->
<resources>
<!-- Placeholders that are found from the files located in the configured
resource directories are replaced with the property values found from the
profile specific configuration file. -->
<resource>
<filtering>true</filtering>
<directory>src/integration-test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Below plugin ensures the execution of test cases during maven build -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>
<includes>
<include>${runSuite}</include>
</includes>
<excludes>
<exclude>com.myservice.testsuite.service.*</exclude>
</excludes>
</configuration>
</plugin>
<!-- Runs integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<!-- Invokes both the integration-test and the verify goals of the Failsafe Maven plugin -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Skips integration tests if the value of skip.integration.tests property is true -->
<skipTests>${skip.integration.tests}</skipTests>
<includes>
<include>**/*IntegrationTest.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</pluginManagement>
</build>
</project>
And also the console output for mvn clean install -P dev:
c:\path\to\gitrepo\service>mvn clean install -P dev
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TwelveFactorAnswers 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # myservicename ---
[INFO] Deleting c:\path\to\gitrepo\service\target
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.9:prepare-agent (jacoco-initialize) # myservicename ---
[INFO]
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # myservicename ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # myservicename ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to c:\path\to\gitrepo\service\target\classes
[INFO]
[INFO] --- build-helper-maven-plugin:1.10:add-test-source (add-integration-test-sources) # myservicename ---
[INFO] Test Source directory: c:\path\to\gitrepo\service\src\integration-test\java added.
[INFO]
[INFO] --- build-helper-maven-plugin:1.10:add-test-resource (add-integration-test-resources) # myservicename ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # myservicename ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory c:\path\to\gitrepo\service\src\test\resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # myservicename ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to c:\path\to\gitrepo\service\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # myservicename ---
[INFO] Surefire report directory: c:\path\to\gitrepo\service\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
||
||
|| All the JUnit Test runs - sample Junit Test Class - <ServiceName>Test.java
||
||
Results :
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.9:check (jacoco-check) # myservicename ---
[INFO] Loading execution data file c:\path\to\gitrepo\service\target\jacoco.exec
[INFO] Analyzed bundle 'myservicename' with 16 classes
[INFO] All coverage checks have been met.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) # myservicename ---
[INFO] Building jar: c:\path\to\gitrepo\service\target\myservicename-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) # myservicename ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.9:report (jacoco-site) # myservicename ---
[INFO] Loading execution data file c:\path\to\gitrepo\service\target\jacoco.exec
[INFO] Analyzed bundle 'TwelveFactorAnswers' with 16 classes
[INFO]
[INFO] --- maven-failsafe-plugin:2.18:integration-test (default) # myservicename ---
[INFO] Failsafe report directory: c:\path\to\gitrepo\service\target\failsafe-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
||
||
|| All the Integration Test runs - sample Integration Test Class - <ServiceName>IT.java
||
||
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-failsafe-plugin:2.18:integration-test (integration-tests) # myservicename ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-failsafe-plugin:2.18:verify (default) # myservicename ---
[INFO] Failsafe report directory: c:\path\to\gitrepo\service\target\failsafe-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:15 min
[INFO] Finished at: 2018-02-16T14:28:05+05:30
[INFO] Final Memory: 38M/269M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18:verify (default) on project myservicename: There are test failures.
[ERROR]
[ERROR] Please refer to c:\path\to\gitrepo\service\target\failsafe-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I think I may have have found the reason for the above behavior. Reference
Before explaining my findings, let me clarify few things:
All my Integration Test class are post-fixed with IT (Example: ServiceIT.java)
All the Integration Test related files (sources & resources) are kept in a folder called integartion-tests inside src folder (example: "src/integration-tests/java" & "src/integration-tests/resources")
Now what I've learnt is:
integration-test phase is included in install, verify & deploy goals.
By default, maven considers any class name ending with -IT and inside test or integration-test folder (eventually in test-classes folder) as Integration Test Class.
Now in my support:
If you look closely in the console output I've pasted, you'll find that the integration-test is being executed twice -
Once:
[INFO] --- maven-failsafe-plugin:2.18:integration-test (default) # myservicename ---
[INFO] Failsafe report directory: c:\path\to\gitrepo\service\target\failsafe-reports
Twice:
[INFO] --- maven-failsafe-plugin:2.18:integration-test (integration-tests) # myservicename ---
[INFO] Tests are skipped.
The first time is being executed as default phase (as a part of install goal). The second time it is being skipped, since the dev profile is being activated, in which the integration-test are skipped.
Why am I so sure?
I changed the Integration Test classes from ServiceIT.java to ServiceIntegrationTest.java and updated the plugin accordingly in pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<!-- Invokes both the integration-test and the verify goals of the Failsafe Maven plugin -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Skips integration tests if the value of skip.integration.tests property is true -->
<skipTests>${skip.integration.tests}</skipTests>
<includes>
<include>**/*IntegrationTest.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Now, for maven, there is no default class for Integration Test and the integration-tests profile is not activated. Hence, maven did not find any default integration test to run. And the console output came as:
[INFO] --- maven-failsafe-plugin:2.18:integration-test (default) # twelvefactorquestion ---
[INFO]
[INFO] --- maven-failsafe-plugin:2.18:integration-test (integration-tests) # twelvefactorquestion ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-failsafe-plugin:2.18:verify (default) # twelvefactorquestion ---
[INFO] Failsafe report directory: c:\Work\12Factor\git\twelveFactorQuestion\target\failsafe-reports
[INFO]
[INFO] --- maven-failsafe-plugin:2.18:verify (integration-tests) # twelvefactorquestion ---
[INFO] Tests are skipped.

yuicompressor-maven-plugin not working at mvn install or designated phase

Here is the maven pom.xml build session
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>${project.artifactId}</warName>
<warSourceExcludes>**/*.js,**/*.css</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<jswarn>false</jswarn>
<nosuffix>true</nosuffix>
<linebreakpos>-1</linebreakpos>
<excludes>
<exclude>**/*.min.js</exclude>
<exclude>**/*.min.css</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
and when run mvn install or mvn pre-package(which is the designated phase ) there is no yuicompressor-maven-plugin working log.
$mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gif-www 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # gif-www ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # gif-www ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # gif-www ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ximing/work/gifmiao/gif-www/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # gif-www ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # gif-www ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # gif-www ---
[INFO] Packaging webapp
[INFO] Assembling webapp [gif-www] in [/home/ximing/work/gifmiao/gif-www/target/gif-www-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ximing/work/gifmiao/gif-www/src/main/webapp]
[INFO] Webapp assembled in [170 msecs]
[INFO] Building war: /home/ximing/work/gifmiao/gif-www/target/gif-www.war
[INFO] WEB-INF/web.xml already added, skipping
but using mvn yuicompressor:compress can get the yuicompressor log shows that the plugin is working.
and I also don't know how to package the compressed css and js to the war file (with the same file name cause I don't want to tweak the include code in html template). Have been working on this about a whole day, someone give me a clue?
You are only defining, but not executing your plugin by putting the configuration between the tag.
See also https://stackoverflow.com/a/10483284/1110843

maven-resources-plugin + profiles

I am moving an existing project (legacy) to maven. It has the following structure:
ParentProject
- EARModule
- src
- target
- pom.xml (ear)
- WARModule
- src
- main
- java
- (java packages and classes)
- resources
- dev
- index.jsp
- prod
- index.jsp
- webapp
- views
- index.jsp (original)
- WEB-INF
- target
- pom.xml (war)
- pom.xml (parent)
I intend to have two different profiles: production and development. In production profile, /WARModule/src/main/resources/prod/index.jsp should be assembled into views/ war directory. In development profile, /WARModule/src/main/resources/dev/index.jsp should be copied into views/ war directory.
For that, I am trying to make use of the maven-resources-plugin, which I am configuring in war pom.xml.
<properties>
<prodResourcesDir>${basedir}/src/main/resources/prod</prodResourcesDir>
<devResourcesDir>${basedir}/src/main/resources/dev</devResourcesDir>
<viewsDir>${basedir}/target/WARModule/views</viewsDir>
</properties>
<profiles>
<profile>
<id>development</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy_development_index.jsp</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${viewsDir}</outputDirectory>
<resources>
<resource>
<directory>${devResourcesDir}</directory>
<filtering>true</filtering>
<includes>
<include>index.jsp</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy_production_index.jsp</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${viewsDir}</outputDirectory>
<resources>
<resource>
<directory>${prodResourcesDir}</directory>
<includes>
<include>index.jsp</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
As you can see above, I am creating two profiles (production and development) and configuring the resources plugin under each of them.
When I run mvn install -P any_of_the_profiles, index.jsp is not copied to the specified destination. Instead, I get the original version. Can anyone help me sort this out?
Below the log trace:
$ mvn -P production install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] ParentProject
[INFO] WebModule Maven Webapp
[INFO] EARModule
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ParentProject 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # ParentProject ---
[INFO] Installing D:\workspace\mvn_projects\ParentProject\pom.xml to C:\Users\a048148\.m2\repository\my\org\ParentProject\0.0.2-SNAPSHOT\ParentProject-0.0.2-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WebModule Maven Webapp 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # WebModule ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # WebModule ---
[INFO] Changes detected - recompiling the module!
[INFO] Compilation messages...
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # WebModule ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\workspace\mvn_projects\ParentProject\WebModule\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # WebModule ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # WebModule ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (copy_index.jsp) # WebModule ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # WebModule ---
[INFO] Packaging webapp
[INFO] Assembling webapp [WebModule] in [D:\workspace\mvn_projects\ParentProject\WebModule\target\WebModule]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\workspace\mvn_projects\ParentProject\WebModule\src\main\webapp]
[INFO] Webapp assembled in [3122 msecs]
[INFO] Building war: D:\workspace\mvn_projects\ParentProject\WebModule\target\WebModule.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # WebModule ---
[INFO] Installing D:\workspace\mvn_projects\ParentProject\WebModule\target\WebModule.war to C:\Users\a048148\.m2\repository\my\org\WebModule\0.0.2-SNAPSHOT\WebModule-0.0.2-SNAPSHOT.war
[INFO] Installing D:\workspace\mvn_projects\ParentProject\WebModule\pom.xml to C:\Users\a048148\.m2\repository\my\org\WebModule\0.0.2-SNAPSHOT\WebModule-0.0.2-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EARModule 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-ear-plugin:2.8:generate-application-xml (default-generate-application-xml) # EARModule ---
[INFO] Generating application.xml
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # EARModule ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-ear-plugin:2.8:ear (default-ear) # EARModule ---
[INFO] Copying artifact [war:com.bbh:WebModule:0.0.1-SNAPSHOT] to [WebModule-0.0.1-SNAPSHOT.war]
[INFO] Could not find manifest file: D:\workspace\mvn_projects\ParentProject\EARModule\target\ParentProject\META-INF\MANIFEST.MF - Generating one
[INFO] Building jar: D:\workspace\mvn_projects\ParentProject\EARModule\target\ParentProject.ear
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # EARModule ---
[INFO] Installing D:\workspace\mvn_projects\ParentProject\EARModule\target\ParentProject.ear to C:\Users\a048148\.m2\repository\my\org\EARModule\0.0.1-SNAPSHOT\EARModule-0.0.1-SNAPSHOT.ear
[INFO] Installing D:\workspace\mvn_projects\ParentProject\EARModule\pom.xml to C:\Users\a048148\.m2\repository\my\org\EARModule\0.0.1-SNAPSHOT\EARModule-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] ParentProject .......................................... SUCCESS [ 0.229 s]
[INFO] WebModule Maven Webapp ................................ SUCCESS [ 19.470 s]
[INFO] EARModule ............................................. SUCCESS [ 3.049 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.892 s
[INFO] Finished at: 2016-12-12T15:18:14+01:00
[INFO] Final Memory: 39M/247M
[INFO] ------------------------------------------------------------------------
I ended up figuring out that maven-resources-plugin works just fine for resources, not web resources (JSP).
So I switched my approach to the maven-war-plugin filtering feature and specifying the destination path. Thus, the profiles section in my web pom.xml ended up like this:
<profiles>
<profile>
<id>development</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<webResources>
<resource>
<directory>${devResourcesDir}</directory>
<filtering>true</filtering>
<targetPath>views</targetPath> <!-- target/WebModule/ subdirectory -->
<include>index.jsp</include>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<webResources>
<resource>
<directory>${prodResourcesDir}</directory>
<filtering>true</filtering>
<targetPath>views</targetPath> <!-- target/WebModule/ subdirectory -->
<include>index.jsp</include>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This tells maven-war-plugin to move index.jsp from the specified resources directory to the target/WebModule/views directory. It is all done by the war plugin just before packaging the war, so there is no need to specify the life cycle phase.

capture maven wagon:exist output

is there a way to capture the output of the maven wagon:exist goal?
if i configure:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-5</version>
<executions>
<execution>
<id>check</id>
<phase>validate</phase>
<goals>
<goal>exist</goal>
</goals>
<configuration>
<serverId>tst.check</serverId>
<url>https://tst.check/${url.part}</url>
</configuration>
</execution>
</executions>
</plugin>
then run the build with a existing url:
c:\dev\tst.package>mvn validate -Durl.part=valid
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tst.package 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- wagon-maven-plugin:1.0-beta-5:exist (check) # tst.package ---
[INFO] exists.
and if i run the build with an invalid url:
c:\dev\tst.package>mvn validate -Durl.part=invalid
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tst.package 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- wagon-maven-plugin:1.0-beta-5:exist (check) # tst.package ---
[INFO] does not exists.
i want to capture the output because i have to process different further steps if the url is valid or not. i am using the wagon plugin because the maven-antrun-plugin don't consider the configured user & password for this server in the settings.xml file.
The source code for the mojo does exactly what you've already shown: log a message if the resource exists or doesn't. I don't see a way to capture the output of the wagon:exist goal.

2 exec-maven-plugin defined in POM - not working

I have two Java main classes that I need executed during different parts of a build process. One needs to execute ALWAYS as part of my standard build process during the generate-sources phase. The other needs to execute as part of a profile, but that profile should be execute at the end of the process-classes phase, which should also include the generate-sources phase prior to that.
I was able to get the first plugin working correctly during the generate-sources phase of the standard build process:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.MySourceGenerator</mainClass>
</configuration>
</plugin>
However when I added a second instance of the same plugin to the profile, the plugin defined as part of the standard build is no longer invoked during my build process, resulting in compile errors. This is the configuration in the profile:
<profiles>
<profile>
<id>initSchema</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.SomeOtherClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This is what I run on the command line: mvn process-classes -PinitSchema. What is wrong with my configuration? I am expecting both plugins to execute during their respective phases.
To clarify: the first exec-maven-plugin generates sources and the second one initialized my DB schema.
EDIT:
Here is the output
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ABC Web Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) # web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/msg added.
[INFO]
[INFO] --- maven-processor-plugin:2.0.6:process (process) # web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt added
[INFO] javac option: -cp
...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: com.company.vocab.generator.VocabAnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] javac option: -s
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final
[INFO] diagnostic /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/AccountDto.java:5: error: cannot find symbol
import com.telos.xacta.util.Messages;
...
(more similar messages)
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default) # web-app ---
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
...
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # web-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 16 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # web-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 281 source files to /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] -------------------------------------------------------------
...
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/ProjectHeadDto.java:[4,28] cannot find symbol
symbol: class Messages
location: package com.company.util
...
(more similar errors)
...
[INFO] 29 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.817s
[INFO] Finished at: Thu Aug 01 20:49:07 EDT 2013
[INFO] Final Memory: 31M/282M
[INFO] ------------------------------------------------------------------------
Give both the execution blocks a different id, because now they both use the default id and so one will overwrite the other.

Resources