什么是“grails干净”?脚本其实呢? [英] What does the "grails clean" script actually do?

查看:90
本文介绍了什么是“grails干净”?脚本其实呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇 grails clean 命令。一旦我将错误的包导入到一个域类中,它就是 java.util.regex 。我用它来做一个正则表达式替换命令,但事实证明,一切都没有改变,所以我认为我的正则表达式是错误的。但是我将它留在那里以便将来改进。

我的localhost中的web应用正常运行,但其他程序员告诉我,他们在编译我的代码时遇到了编译错误码。我关闭Grails,然后再次启动它,但它仍然正常运行。只有在运行 grails clean 编译错误出现后才会出现。

首先忽略了我的变化。在文档中,他们说:


如果你的Grails应用程序有
被搞乱了,并且带有
神秘错误消息尝试:

grails clean


我对这个神秘的东西有点困惑。那么 grails clean 究竟干什么?什么样的资源不会被再次编译,除非 grails clean 被调用?

解决方案

clean脚本删除已编译的类和属性文件以及复制到类dir的其他非源资源,以及其他类似测试报告的资源。



你看到的问题是增量编译。它通常相当可靠,但可能会因Java而失败,不幸的是Groovy更可能是一种动态语言。很难在所有其他课程中的一个班级中发现变化的全部范围,有时会发生变化。如果幸运的话,显然有些事情是错误的,但有时需要一段时间才能知道为什么会发生一些非常奇怪的行为。

所以最好的做法是做一个完整的编译,无论是纯Java还是Groovy和Java的混合。因为这样很昂贵(特别是对于大型项目),尽可能多地使用渐进式编译就足够了,但偶尔会用 grails clean 来强制执行完整编译。


I'm curious about the grails clean command. Once I imported a wrong package into a domain class, It was java.util.regex. I used it to do a regex replace command, but it turns out that everything was unchanged so that I supposed my regex was wrong. But I left it there for future refinement.

The web-app in my localhost functioned normally but then other programmers told me that they got compiling errors when they tried to compile my code. I shutdown grails and then start it again, but it still ran properly. Only after runnning grails clean the compiling error appeared.

So it seems the application just ignored my changes in the first place. In the documentation, they say:

In case your Grails application has been screwed and comes up with mysterious error messages try:

grails clean

I'm a bit confused about this "mysterious" thing. So what does grails clean actually do? What kinds of resources will not get compiled again, unless grails clean is called?

解决方案

The clean script deletes compiled classes and property files and other non-source resources that were copied to the classes dir, and also other stuff like test reports.

The problem that you're seeing is with incremental compilation. It's fairly reliable in general but can fail with Java, and is unfortunately more likely with Groovy since it's a dynamic language. It's hard to detect the full scope of a change in one class on all other classes, and sometimes changes get missed. If you're lucky it's obvious that something's wrong but sometimes it can take a while wondering why some seriously strange behavior is happening.

So the best thing to do is always do a full compile, whether it's pure Java or a mix of Groovy and Java. Since this is expensive (especially with larger projects) it's sufficient to use incremental compilation as much as possible, but occasionally force a full compile with grails clean.

这篇关于什么是“grails干净”?脚本其实呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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