使用 maven jetty:run 时 - 是否可以禁用编译步骤?
我正在使用 Eclipse 和 Maven,并使用 Maven jetty 插件运行我的应用程序。
我发现每次执行 jetty:run 时 Maven 都坚持重新编译我的文件,这有点令人恼火。它不是最优的,因为文件已经由 Eclipse 编译(并且我正在编写 Scala,它的编译器(相对)较慢)。
我正在使用配置文件,并在我的“开发”配置文件下运行 mvn jetty:run 。
我想做的是:
<块引用> <块引用>配置jetty插件,使其在开发配置文件下运行时跳过编译阶段。
我查看了 Maven 生命周期文档,但没有找到有关“skip.compile”标志或配置参数的任何信息。
我也尝试像这样配置 Maven,徒劳地假设它会在 maven-jetty-plugin 启动时停止重新编译。
我错了,它不起作用。但我想,也许Scala编译器就是问题所在。也许它忽略了编译的东西。
发展 maven-编译器-插件 默认测试编译 测试编译 默认编译 编译 1.6 1.6 错误的 org.mortbay.jetty jetty-maven-插件 7.2.2.v20101205 真的 发展
更新:
我将尝试专门禁用 scala 编译
I'm working with Eclipse and Maven and run my application using the Maven jetty plugin.
I find it mildly irritating that Maven insists on recompiling my files every time I execute jetty:run. It is sub-optimal, as the files have already been compiled by Eclipse (and I'm writing Scala which has a (relatively) slow compiler).
I'm using profiles, and run mvn jetty:run under my 'development' profile.
What I want to do is:
Configure the jetty plugin so that it skips the compilation phase whilst running under the development profile.
I've looked into maven lifecycle documentation but haven't found any information about a 'skip.compile' flag or configuration parameter.
I've also tried configuring Maven like so in the vain assumption that it would stop the recompile upon maven-jetty-plugin startup.
I was wrong, it did not work. But what I have thought is, perhaps the Scala compiler is the problem. Perhaps it ignores the compile stuff.
development
maven-compiler-plugin
default-testCompile
test-compile
default-compile
compile
1.6
1.6
false
org.mortbay.jetty
jetty-maven-plugin
7.2.2.v20101205
true
development
Update:
I'm going to try specifically disabling scala compilation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
终于解决了.. @RobertMunteanu
哇!好吧,我终于弄清楚我做错了什么,解决方案是创建一个开发和生产配置文件,并且对于开发配置文件,将 Scala 插件执行配置为不执行任何操作。
像这样:
Finally solved it.. @RobertMunteanu
Wow! Well I've finally figured out what I was doing wrong, the solution is to create a development and production profile, and, for the development profile configure the Scala plugin executions to do nothing.
Like so :
解决方案是设置一个环境变量:
以上对我有用。
在互联网的其他地方,它被描述为:
The solution is to set an environmental variable of:
The above worked for me.
Elsewhere on the Internet it is described as:
经过一番研究,问题不在于jetty插件,而在于maven-compiler-plugin。增量编译中存在错误。请参阅此 stackoverflow 问题和答案: Maven 编译器插件总是检测一组源为“陈旧”
以下配置对我来说效果很好;当代码发生更改时,它允许快速重新启动 jetty,只需最少的重新编译,并且如果您已经编译过,则不会重新编译:
After some research, the problem is not with the jetty plugin, but with maven-compiler-plugin. There's a bug in the incrementalCompilation. See this stackoverflow question and answer: Maven compiler plugin always detecting a set of sources as "stale"
The following configuration works well for me; it allows for a very quick restart of jetty when code has changed with minimal recompilation, and it does not recompile if you have already compiled:
如果你说这些类已经被 Eclipse 编译过,那么重新编译有两种可能的原因:
clean
或以某种方式删除已编译的类;因此,您需要防止删除已编译的类,或者将 Eclipse 和 Maven 配置为使用相同的输出文件夹。
If you say that the classes have already been compiled by Eclipse, there are two possible causes for recompiling:
clean
or deleting the compiled classes somehow;So you need to either prevent deletion of your compiled classes or configure Eclipse and Maven to use the same output folder.