I need to pass "-deploy src/main/webapp/WEB-INF/deploy/" argument to GWT Compiler in gwt-maven-plugin configuration.
My purpose is to integrate remote logger using gwt-log.
To achieve I need to pass above mentioned argument to GWT compiler.
Thanks!!
Bhavesh
See gwt-maven-plugin
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<configuration>
<deploy>src/main/webapp/WEB-INF/deploy/</deploy>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
[...]
</plugins>
</build>
[...]
</project>
As noted you'll need to upgrade.
It looks like this parameter is only available since 2.3.0-1 version of gwt-maven-plugin (see here).
Related
Maven properties in pom.xml of Java repos have to be aligned to some convention for CI processes to work correctly.
For example:
<app-name.prop-name-version>X.X.X.X</app-name-version.prop-name-version>
Is there a way to fail maven builds if maven property is not aligned to convention?
I thought about developing maven plugin from scratch, but is there another way?
Maven Enforcer Plugin exactly does what you need. That has a lot of built-in rules like Require Property
According the documentation this rule can enforce the declared property is set and optionally fits for a regex rule.
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>app-name.prop-name-version</property>
<message>"Project version must be specified."</message>
<regex>.*[...]$</regex>
<regexMessage>"Invalid format."</regexMessage>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
What approach can be taken to verify that a library is compatible on a specific version of Java?
Example: Library X was compiled on Java 1.7, therefor it might not work on Java 1.7 or lower.
Thank you.
The best is to check the byte code via an enforcer rule which can be applied to your build by using the maven-enforcer-plugin...
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-bytecode-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>1.7</maxJdkVersion>
</enforceBytecodeVersion>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.0-beta-4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
[...]
</project>
compile with the version you want:
javac -target ...
see that: How do i compile a .java with support for older versions of java?
and check jar dependencies: with Jdepend for example
Analyze JAR dependencies in a Java project
I have a maven plugin (jaxb2) and I need to supply a jvm arg to it. I don't think there is a tag to add jvm args in the pom for it.
I know I can pass in jvm args on the command line eg: mvn clean install -Djavax.xml.accessExternalSchema=all
Is it possible to set this jvm arg in the pom so that I don't have to type it into the command line every time?
(As aside - this jvm arg is required in order for it to work with JAVA-8. It works fine with JAVA-7)
This is relevant to the new XML security properties in JAXB 1.5, introduced in Java 8. This is why your builds now fail on Java 8 but work with Java 7.
If you're using my maven-jaxb2-plugin, please upgrade to the version 0.9.0 or later (current is 0.10.0). It has now a accessExternalSchema switch (default is all).
This sets precisely javax.xml.accessExternalSchema=all.
Please see the documentation.
I came across this issue while working with jaxb2-maven-plugin. I found a related jira issue for maven-jabx2-plugin - https://java.net/projects/maven-jaxb2-plugin/lists/issues/archive/2014-03/message/0
According to this issue Stephan202 suggested using properties-maven-plugin which worked like charm. Here is a sample code from his post -
<plugin>
<!-- We use this plugin to ensure that our usage of the
maven-jaxb2-plugin is JDK 8 compatible in absence of a fix
for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>set-additional-system-properties</id>
<goals>
<goal>set-system-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>file,http</value>
</property>
</properties>
</configuration>
</plugin>
Re; the post - "I needed a solution that doesn't use alpha versions as that is my companies rules. –"
Changing the version to 1.0 & the value to 'all' got it working for me:
<plugin>
<!-- We use this plugin to ensure that our usage of the
maven-jaxb2-plugin is JDK 8 compatible in absence of a fix
for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<!--
<version>1.0-alpha-2</version> -->
<version>1.0.0</version>
<executions>
<execution>
<id>set-additional-system-properties</id>
<goals>
<goal>set-system-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>all</value>
</property>
</properties>
</configuration>
</plugin>
It has worked for me :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<vmArgs>
<arg>-Djavax.xml.accessExternalSchema=all</arg>
</vmArgs>
<keep>true</keep>
<verbose>true</verbose>
<wsdlDirectory>${project.build.directory}/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>ServiceWsService.wsdl</wsdlFile>
</wsdlFiles>
<bindingFiles>
<bindingFile>custom-binding.xml</bindingFile>
<bindingFile>custom-binding2.xml</bindingFile>
</bindingFiles>
</configuration>
</execution>
</executions>
</plugin>
Take a look at the Maven Compiler Plugin. Specifically you should be able to use the <compilerArgument> element to pass settings to the compiler.
See http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html for examples.
If you are trying to change the behavior of the JVM that is running Maven itself, add options to MAVEN_OPTS in the environment before launching mvn.
For maven-jaxb2-plugin version 2.5.0 trying to generate from DTD and spitting
org.xml.sax.SAXParseException: External parsing is disabled. Cannot
parse URI: ...
it helped adding the following to plugin configuration
<configuration>
...
<externalEntityProcessing>true</externalEntityProcessing>
</configuration>
I do not have much experience with Maven profiles ....
I do not know if Maven can do this, but it definitely could be useful to me ...
Is possible to define a profile, which when called, automatically run the maven release plugin prepare goal?
I explained better ....
instead of:
mvn release: prepare
I would like to call
mvn install-pProfileThatPerformThePrepare
that automatically perform the prepare ...
Thank you....
You just have to bind an execution of the plugin to a phase (e.g. "install" in your example):
<profile>
<id>my-profile</id>
<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>prepare</goal>
</goals>
<configuration>
<updateWorkingCopyVersions>false</updateWorkingCopyVersions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
I'd like to use the Maven Enforcer plugin to check to see if I have duplicate classes on my path.
I've tried the example from here.
But when I run it like this:
mvn enforcer:enforce
I get this error:
Failed to execute goal
org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce
(default-cli) on project datapopulator: The parameters 'rules' for
goal org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce are
missing or invalid
Is there a way to use this correctly?
EDIT #1
If changing my config to this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<AlwaysPass />
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
Produces the same error.
The reason why your first version did not work is because there is a difference between a plug-in configuration inside the execution tag and a plug-in configuration outside the execution tag. The execution is only used when your plug-in is triggered by a special phase of the complete Maven build.
The Maven guide to configuration explains it better:
Configurations inside the tag differ from those that are outside in that they cannot be used from a direct command line invocation. Instead they are only applied when the lifecycle phase they are bound to are invoked. Alternatively, if you move a configuration section outside of the executions section, it will apply globally to all invocations of the plugin.
Try this, moving the configuration outside executions, so it isn't bound to the life cycle phase.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<AlwaysPass />
</rules>
<fail>true</fail>
</configuration>
</plugin>
Now when you do mvn enforcer:enforce, it picks the rules from your pom.xml.
See these answers
You can use the special default command line execution id, default-cli to invoke it (see Maven Docs), see my example below. This works at least with 3.1.1 and the article cited says it should work with 2.2.0+
mvn enforcer:enforce
However if you are using above Maven 3.1.1 (I can confirm it works in 3.3.3 with enforcer v 1.4.1) you can specify the execution id you wish using the new # syntax (see Maven JIRA and the answers above);
e.g. for the example below use
mvn enforcer:enforce#dependency-convergence
Here's a snippet from my pom;
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>dependency-convergence</id>
<phase>install</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<DependencyConvergence />
</rules>
<fail>true</fail>
</configuration>
</execution>
<execution>
<id>default-cli</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<DependencyConvergence/>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
...
I don't know why it won't work with the config being in an execution, but this worked for me:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<configuration>
<rules>
<banDuplicateClasses>
<findAllDuplicates>true</findAllDuplicates>
</banDuplicateClasses>
</rules>
<fail>false</fail>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>extra-enforcer-rules</artifactId>
<version>1.0-alpha-1</version>
</dependency>
</dependencies>
</plugin>