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

蓝咒 提交于 2019-12-13 14:07:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!