问题
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"
回答1:
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™.
来源:https://stackoverflow.com/questions/21287480/is-it-possible-to-set-the-user-agent-property-from-the-command-line-using-the-gw