如何在Eclipse项目中构建过程中过滤ressources? [英] How to filter ressources during build in Eclipse project?

查看:211
本文介绍了如何在Eclipse项目中构建过程中过滤ressources?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用几个配置文件的应用程序(让我们在这里考虑appli.properties)。
这些文件包含几个取决于环境的值。我们可以找到一些信息,例如:

I have an application that uses several configuration files (let just consider appli.properties here). These files contain several values that depend on the environment. We can find some information such as:

server.port=${envi.server.port}

另一方面,我有一组属性文件,每个环境一个(dev.properties,homolo.properties等) 。
它们包含配置文件中某些属性的值。我们可以在这里找到这种属性:

On other side, I have a set of properties files, one per environment (dev.properties, homolo.properties, etc.). They contain the values for some properties in configuration files. We can find here this kind of properties:

envi.server.port=4242

我的构建由Maven2处理。一切正常。

My build is handled by Maven2. Everything is working fine.

但是,现在我需要将我的项目导入到Eclipse中。
我主要关心的是配置文件过滤。事实上,如果我不修改我的Eclipse参数为我的项目(在一个 mvn eclipse:eclipse命令之后),那么所有我的配置文件将保持属性键(即 $ {envi.server.port} ),而不是它们的值。有了这样的配置文件,我的应用程序将不会在Eclipse内运行...

However, I now need to import my project into Eclipse. My main concern is about the configuration files filtering. Indeed, if I do not modify anything in my Eclipse parameter for my project (after a mvn eclipse:eclipse command), then all my configuration file will keep the property keys (i.e. ${envi.server.port}) instead of their values. And with such configuration files, my application will not run inside Eclipse...

所以我尝试了两个解决方案:

So I tried two solutions:

这两个解决方案的常见问题是,操作(基本上保存在Java类版本),然后需要时间。第二个解决方案比第一个解决方案更快(3秒)(超过10秒)。

The common problem of these two solutions is that the filtering is made at every operation (essentially saves on Java class edition), and then take time. The second solution is however quicker (3 seconds) than the first one (more than 10 seconds).

您认为我的方法是什么?

What do you think of my approach? How would you do that, in a better way?

推荐答案

如果资源不经常更改,可以设置Maven构建只在Clean构建之后运行,那么它不会干扰这么多,这不会做任何事情加快构建。

If the resources are not changed that often, you can set the Maven build to only run after a Clean build, then it won't interfere so much, this doesn't do anything to speed up the build however.

就使过滤更快,我不知道任何其他简单的机制,将有所帮助,因为你已经说过你需要Ant或Maven来运行过滤,他们都需要一些时间来建立,

As far as making the filtering quicker, I don't know of any other simple mechanism that will help, as you've said you need either Ant or Maven to run the filtering, and they both take some time to set up before building, resulting in the slow down.

如果这会导致很多问题,你可以写一个自定义增量Eclipse生成器,用于对deltas执行过滤。这应该是相当快,但显然更多的努力写。

If this is causing you a lot of problems, you can write a custom Incremental Eclipse builder that performs the filtering on the deltas. This should be considerably quicker, but obviously a lot more effort to write.

这篇关于如何在Eclipse项目中构建过程中过滤ressources?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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