是否可以使用GWT-Maven-Plugin从命令行设置user.agent属性? [英] Is It Possible to Set the user.agent Property from the Command Line Using the GWT-Maven-Plugin?

查看:169
本文介绍了是否可以使用GWT-Maven-Plugin从命令行设置user.agent属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,在我的* .gwt.xml文件中,可以通过添加以下代码来指定我希望GWT编译器为其编译应用的浏览器:

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"/>

通过maven构建项目时,是否可以在命令行上设置此属性?在计算机上进行本地开发时,我希望能够执行以下操作:

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"

推荐答案

编辑:从GWT 2.7开始,您现在可以在命令行中传递-setProperty user.agent=…;无需再调整gwt.xml文件.我不确定GWT的Mojo插件是否可以让您使用,但是net.ltgt.gwt.maven GWT的Maven插件可以.

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.

您可以使用过滤资源 ,但是这样可能会使在IDE中工作变得困难.

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

在您的gwt.xml中:

In your gwt.xml:

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

然后在您的pom.xml中:

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>

但是请注意,这与 The Maven Way™.

这篇关于是否可以使用GWT-Maven-Plugin从命令行设置user.agent属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆