java – 如何创建开发/调试和生产设置
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 如何创建开发/调试和生产设置,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3681字,纯文字阅读大概需要6分钟。
内容图文
![java – 如何创建开发/调试和生产设置](/upload/InfoBanner/zyjiaocheng/807/ff6bde436e8e4e848b9f413e5aef3203.jpg)
我最近无意中部署了我们的游戏typrX的调试版本
(在www.typrx.com输入比赛 – 尝试它很有趣).
它很快被纠正了,但我知道它可能会再次发生.挖完之后
在Google上,我找到了一些信息,如何创建2个不同的配置文件,一个
用于具有调试功能和用于的调试功能的开发模式
部署.这是我从Google IO演示文稿中找到的内容.是否
有谁有这个设置?有人可以解释如何运行吗?
MyAppCommon.gwt.xml
<module>
...
<define-property values="debug, release" name="app.config" />
<replace-with class="myapp.debug.DebugConsole">
<when-type-is class="myapp.Console" />
<when-property-is name="app.config" value="debug" />
</replace-with>
...
</module>
MyAppDebug.gwt.xml
<module>
...
<set-property name="app.config" value="debug" />
</module>
解决方法:
使用特定模块进行调试的想法已经浮出了一段时间,并且在this Google I/O presentation中也有提及(参见PDF中的幻灯片33或视频中的0h31m).
基本思想是你有一个标准的GWT模块,第二个调试模块继承这个标准模块,配置一些属性,并使用GWT的延迟绑定在调试时用特定的实例替换一些类.
然后,您只需配置Maven / ant构建即可编译相应的模块,具体取决于您处于开发模式还是处于发布模式.
在我的项目中,我没有创建“app.config”延迟绑定属性,但我可能稍后会这样做.我做的是以下内容:
创建了一个标准模块
COM /示例/ MainModule.gwt.xml:
<module rename-to="mainModule">
<inherits name="com.smartgwt.SmartGwt" />
<!-- (other configurations) -->
<!-- gwt-log configuration -->
<define-property name="log_level" values="OFF,DEBUG" />
<inherits name="com.allen_sauer.gwt.log.gwt-log-common" />
<!-- Locales we want to compile for -->
<extend-property name="locale" values="en" />
<extend-property name="locale" values="fr_FR" />
</module>
创建了一个“调试”模块,它继承了标准模块并为开发配置了一些额外的属性
COM /示例/ MainModuleDebug.gwt.xml:
<module rename-to="mainModule">
<inherits name="com.example.MainModule" />
<set-property name="user.agent" value="gecko1_8" />
<set-property name="locale" value="fr_FR"/>
<set-property name="log_level" value="DEBUG" />
</module>
注意:rename-to属性在这里非常重要,因为您希望在完全相同的名称下部署这两个模块.在开发期间编译时,您不希望必须更改所有html主机页面以指向调试模块.
配置Maven和gwt-maven-plugin来编译正确的模块
<project>
(...)
<properties>
(...)
<!--
Suffix appended to the names of the GWT modules we compile in our child projects.
Empty by default, this suffix is overriden by some profiles to specify an alternative module to compile.
-->
<gwt.module.suffix></gwt.module.suffix>
<!-- We force GWT-recompilation by default (except when using the "gwtDebug" profile - see below for more info) -->
<gwt.compiler.force>true</gwt.compiler.force>
</properties>
(...)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
(...)
<module>com.example.MainModule${gwt.module.suffix}</module>
</configuration>
</plugin>
(...)
<profiles>
<!-- This profile should be used during *DEVELOPMENT* -->
<profile>
<id>gwtDebug</id>
<properties>
<gwt.module.suffix>Debug</gwt.module.suffix>
<!-- Tells gwt-maven-plugin to recompile GWT modules only when necessary -->
<gwt.compiler.force>false</gwt.compiler.force>
</properties>
<activation>
<property>
<name>gwtDebug</name>
</property>
</activation>
</profile>
</profiles>
</project>
只需执行“maven clean install”即可编译生产模块.在开发中,使用“mvn clean install -DgwtDebug”来激活gwtDebug配置文件,后者又编译调试模块.
当然,您可以配置?/ .m2 / settings.xml以始终定义“gwtDebug”属性…
同样的想法也适用于Ant.但我并不精通它.
当您开始玩具有使用调试模块覆盖真实模块的想法时,您开始设想一些非常酷的可能性:
>您可以添加性能日志,这些日志将在生产时从代码中删除.
>您可以配置所有toString()方法,以便在调试模式下返回有用的内容,并在生产时返回空字符串(从而减少.js大小).
>您可以通过仅指定一个区域设置/一个浏览器/一个日志级别来减少排列数,以加快编译速度(但不要忘记不时测试其他区域设置/浏览器).
内容总结
以上是互联网集市为您收集整理的java – 如何创建开发/调试和生产设置全部内容,希望文章能够帮你解决java – 如何创建开发/调试和生产设置所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。