Is It Possible to Set the user.agent Property from the Command Line Using the GWT-Maven-Plugin?

StackOverflow https://stackoverflow.com/questions/21287480

  •  01-10-2022
  •  | 
  •  

Question

I know that in my *.gwt.xml file I can specify the browsers I want the GWT compiler to compile my app for by adding this to it:

<set-property name="user.agent" value="opera,ie8, gecko1_8, safari, ie9"/>

Is it possible for me to set this property on the command line when I build my project through maven? I'd like to be able to do something like this when I'm developing locally on my machine:

mvn clean install -Duser.agent="opera,ie8"
Was it helpful?

Solution

EDIT: Starting with GWT 2.7, you can now pass a -setProperty user.agent=… on the command line; no need to tweak gwt.xml files any more. I'm not sure Mojo Plugin for GWT let you use that though, but the net.ltgt.gwt.maven Maven Plugin for GWT can.


You can use filtering of your resources, but then it might make it harder to work from within your IDE.

In your gwt.xml:

<set-property name="user.agent" value="${user.agent}" />

Then in your pom.xml:

<resources>
  <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
  </resource>
</resources>

and the default value for the property when you don't give it on the command-line:

<properties>
  <user.agent>opera,ie8,gecko1_8,safari,ie9</user.agent>
</properties>

Note however that this goes against The Maven Way™.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top