I want to enable older plug ins not available in m2e v 1.0
I have added this to the POM but it does not work if there are multiple items.
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>[0.0.0,)</version>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>[0.0.0,)</version>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
I have also tried the following variation.
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<lifecycleMappings>
<lifecycleMapping>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>[0.0.0,)</version>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMapping>
<lifecycleMapping>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>[0.0.0,)</version>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMapping>
</lifecycleMappings>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
The error message I get is:
Cannot parse lifecycle mapping metadata for maven project MavenProject: com.sakriom:drools-context:0.0.1-SNAPSHOT # D:\Documents and Settings.....\Workspaces\Eclipse 3.6 - Scala\DroolsContext\pom.xml
Cause: Unrecognised tag: 'version' (position: START_TAG seen ...\r\n ... #10:22)
How is this error message decoded?
"Cause: Unrecognised tag: 'version'" -- It's complaining about the <version>[0.0.0,)</version> tag because it doesn't belong inside of a <pluginExecutionFilter>. You should use <versionRange>[0.0.0,)</versionRange> instead.
"Cause: Unrecognised tag: 'version'" -- It's complaining about the <version>[0.0.0,)</version> tag because it doesn't belong inside of a <pluginExecutionFilter>. You should use <versionRange>[0.0.0,)</versionRange> instead.
The element version is not allowed at line 8.
If you need more help, add the relevant part of the pom-xml to your question.
[EDIT] Based on the POM you supplied, the problem is that you're using a property in the version element of the project. Maven only supports properties in all other version elements but not this one.
But the error message seems a bit odd. Try the latest Maven release (3.0.3). If that still gives the same error, please create a small demo POM which shows the problem (just delete as much as possible) and open a bug in the Maven issue tracker.
Related
I have a Vendor.xsd, where the namespace definition is referencing a vendor specific namespace http://vendor.com/xjc-plugins. A snippet is given below:
...
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:common="http://annox.dev.java.net"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:vendor="http://vendor.com/xjc-plugins"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="vendor common"
jaxb:version="2.0">
...
xs:complexType name="VendorType">
<xs:annotation>
<xs:appinfo>
<vendor:package>vendor.package</vendor:package>
</xs:appinfo>
</xs:annotation>
...
When I try to generate jaxbs by using either xjc from command line or maven-jaxb22-plugin the following exception occurs:
Unsupported binding namespace "http://vendor.com/xjc-plugins". Perhaps you meant "http://annox.dev.java.net"?
The maven plugin I am using is given here:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb22-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>Vendor.xsd</include>
</schemaIncludes>
<generatePackage>com.vendor.model</generatePackage>
<extension>true</extension>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>1.0.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>1.11.1</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-tools</artifactId>
<version>1.11.1</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>
Any ideas welcome ?
You do not seem to include your XJC plugin in plugins section of the maven-jaxb2-plugin configuration. Binding namespace must be acknowledged by some plugin. You only include jaxb2-basics but not the plugin which would acknowledge http://vendor.com/xjc-plugins.
I'm using JDK 1.6 (due to dependencies) and to generate classes from xsd, I have added maven-jaxb2 plugin as shown below in pom.xml.
But the eclipse (Kepler) complains as below.
Error parsing the command line [[-Xsimplify, -episode,
D:\test\workspace\sample\target\generated-sources\xjc\META-INF\sun-jaxb.episode]]
(org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.8.1:generate:jaxb-test:generate-sources)
pom.xml
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.9.0</version>
<executions>
<execution>
<id>jaxb-test</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>sample.xsd</include>
</schemaIncludes>
<xjbSources>
<xjbSource>bindings.xjb</xjbSource>
</xjbSources>
</configuration>
</execution>
</executions>
<configuration>
<extension>true</extension>
<args>
<arg>-Xsimplify</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
Try to upgrade to maven-jaxb2-plugin 0.13.1, and jaxb2-basics 0.11.0.
The versions you have now are very old already.
I have a maven code
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources-from-parent</id>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>./target/aut-ws</outputDirectory>
<resources>
<resource>
<directory>/prj//workspace-Fm-aut-Testing/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
This is working fine, but it is not copying .* linux files which are hidden. In normal linux we would use a parameter -a. How to use this here?
Thanks
Jeevan
To disable this behaviour set addDefaultExcludes to false.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<addDefaultExcludes>false</addDefaultExcludes>
</configuration>
</plugin>
By default files like .gitignore, .cvsignore etc. are excluded which
means they will not being copied. If you need them for a particular
reason you can do that by settings this to false.
Documentation: https://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html#addDefaultExcludes
In my case ".file" was in target/[unpacked folder] but was missing in final .jar.
I achieved this adding maven-antrun-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<configuration>
<target>
<echo message="repackaging" />
<jar destfile="${project.build.directory}/${project.build.finalName}.jar" basedir="${project.build.directory}/${project.artifactId}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I have a project using Maven and the frontend-maven-plugin (com.github.eirslett).
As I run mvn install all the executions from the plugin run, and they create a node_modules, bower_components, and node folders in the src/main/webapp root, where the actual frontend code is.
The thing is, I wanted to mvn install only execute and create those in war the package generated in the build directory, not in the versioned application code, just like it does with Java libraries.
Is there a way to achieve that?
This is the relevant part of my pom.xml:
<build>
<directory>build</directory>
<outputDirectory>build/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>WEB-INF/weblogic.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
...
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.20</version>
<configuration>
<workingDirectory>src/main/webapp</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v0.10.34</nodeVersion>
<npmVersion>2.1.11</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
It's possible to use <installDirectory> configuration parameter to choose where to install NodeJS.
frontend-maven-plugin will install node_modules in the place where it founds package.json. That's why you need to provide copy of your web resources with package.json to some target/<sub-path>.
Then frontend-maven-plugin may be configured by this way:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.24</version>
<configuration>
<nodeVersion>v0.11.14</nodeVersion>
<npmVersion>2.13.4</npmVersion>
<installDirectory>target/<sub-path></installDirectory>
<workingDirectory>target/<sub-path></workingDirectory>
</configuration>
...
The plugin (frontend-maven-plugin) mostly supports this. The "workingDirectory" parameter tells plugin where to do the work (i.e. npm install). That requires though that the build files (i.e. package.json, gruntFile.js) be in that workingDirectory. To accomodate this I added a antrun execution to copy those files over (with filtering) before the rest of the build. My grunt file then references the files from source when appropriate and any output goes in my target-grunt folder.
Here is my config:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.20</version>
<configuration>
<workingDirectory>target-grunt</workingDirectory>
</configuration>
<executions>
...
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>prepare-grunt</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- copy, filter, rename -->
<filter token="moduleName" value="${moduleName}" />
<filter token="project.version" value="${project.version}" />
<filter token="project.artifactId" value="${project.artifactId}" />
<copy file="${basedir}/target-grunt/imported-js/main/js/com/verisk/underwriting/config/grunt/npm-package-module/0.0.1/npm-package-module-0.0.1.js" tofile="${basedir}/target-grunt/package.json" filtering="true" failonerror="true" verbose="true" />
<copy file="${basedir}/Gruntfile.js" tofile="${basedir}/target-grunt/Gruntfile.js" failonerror="true" verbose="true" />
</target>
</configuration>
</execution>
</executions>
</plugin>
A possible way in order to do not dirty the frontend resources dir, contained as example in src/main/frontendResources, coming from GIT (or another source repo) with the node_modules, bower_components, ..., directories and files generated during npm, bower and grunt execution is:
using maven-resources-plugin, copy the sources directory src/main/frontendResources
in /target/webappStagingDir subfolder during
initialization phase
set the workingDirectory and
installDirectory in frontend-maven-plugin to /target/webappStagingDir
set the bower output directory as
subfolder of /target/webappStagingDir. In example put
{"directory":
"bower_components"}
in .bowerrc file
after bower build, using
maven-resources-plugin, copy the output built sources contained in
bower_components folder to /target/${artifactId}-${version} during
prepare-package phase (before war building)
Here is the pom slice:
...
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>${basedir}/target/frontendResourcesStagingDir</workingDirectory>
<installDirectory>${basedir}/target/frontendResourcesStagingDir</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<phase>generate-resources</phase>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v8.12.0</nodeVersion>
<npmVersion>6.4.1</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<phase>generate-resources</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>bower install</id>
<phase>generate-resources</phase>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<phase>generate-resources</phase>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<!--
Copy of the /frontendResources directory, coming from GIT, in /target directory
executed before the compiling and build of frontend resources
That dir will be the working directory of npm, bower, grunt
in order to avoid the creation of the direcotries node, node_modules, bower_components, ...
(they may be committed in repository)
-->
<execution>
<id>copy-frontendResources-toStagingDir-beforeBuild</id>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/frontendResourcesStagingDir</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/frontendResources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<!--
Copy of the /frontendResourcesStagingDir/grunt_output directory in /target/ directory
executed after build of frontend resources and before the war pachage creation
it contains the output of grunt install execution
-->
<execution>
<id>copy-frontendResources-afterBuild</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/${artifactId}-${version}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/frontendResourcesStagingDir/grunt_output</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
...
This solution is useful also for mixed projects with frontend in Node.js and backend in Java that has a single .war file as output deliverable
I would like to use wro4j maven plugin in a project. I works using mvn command line, but not in Eclipse/m2e.
I tried both lifecycle-mapping customization, and wroj4j-m2e integration plugin.
Here is the error with lifecycle-mapping customization :
Execution default of goal ro.isdc.wro4j:wro4j-maven-plugin:1.6.0:run failed: Plugin ro.isdc.wro4j:wro4j-maven-plugin:1.6.0 or one of its dependencies could not be resolved: Failed to collect dependencies for ro.isdc.wro4j:wro4j-maven-plugin:jar:1.6.0 () (ro.isdc.wro4j:wro4j-maven-plugin:1.6.0:run:default:process-resources)
The log of m2eclipse (in .plugins\org.eclipse.m2e.logback.configuration) is empty about this error, even with debug output selected in Eclipse maven preferences.
m2e version : 1.2.0.20120903-1050
eclipse version : Juno Service Release 1
Here is the pom.xml (extract)
<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>test</groupId>
<artifactId>test-maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<wro4j.version>1.6.0</wro4j.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>${wro4j.version}</version>
<executions>
<execution>
<configuration>
<destinationFolder>${project.build.directory}/</destinationFolder>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
<wroFile>${basedir}/src/main/config/wro.xml</wroFile>
<extraConfigFile>${basedir}/src/main/config/wro.properties</extraConfigFile>
<targetGroups>gss</targetGroups>
<cssDestinationFolder>${project.build.directory}/${project.build.finalName}/styles/</cssDestinationFolder>
<jsDestinationFolder>${project.build.directory}/${project.build.finalName}/scripts/</jsDestinationFolder>
<contextFolder>${basedir}/src/main/</contextFolder>
<ignoreMissingResources>false</ignoreMissingResources>
<wroFile>${basedir}/src/main/config/wro.xml</wroFile>
</configuration>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- configure #!# m2eclipse -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<versionRange>[1.0,]</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>