.properties files in regular src folder okay? [closed]

I work on a Java project with a suggested structure (separate src folders for java files and resource files).

After moving the message / text related properties files to that folder, the externalize strings mechanism in Eclipse does not work as before.

Usually when hovering over the key string in a getString(“”) call, the tooltip showed the content of the properties file with the default locale. That has been extremely helpful for me personally. It seems as if that feature only works if the properties file is in the same source folder as the Java code that manages the BUNDLE_NAME stuff.

Can I make a strong case for moving the properties file back to the src-folder, or should they be kept separate from the java source files? Anything else that I can try to get the feature to work again with the new structure?

4

No, its not ok to put property files into the source directory. Some build environments could get rather unhappy with such a structure. While yes, it may work, and the source directory may be in the class path for you in Eclipse, the best option is to have the resources in a separate directory.

Think of the build process. This is typically ‘build all the files from the source directory and put the resulting class files in another directory (target, or dist)’. When there are property files (and other resources) mixed in there, the build gets more complex having to select another set of files to get copied to the build directory.

A much easier approach is to have source in one spot and resources in another. This is actually the preferred directory structure that maven requires (with some directories left out):

src/main/java
src/main/resources
src/main/webapp
src/test/java
src/test/resources

This allows the tests (JUnit or TestNG) to be able to use a separate set of resources rather than the main resources and makes testing much easier.

Likewise, the webapp directory is handled specially when building a .war file.

Keeping the properties separate makes for an easier build process, a cleaner identification of the files that are needed to be part of the class path, and an easier test environment for overriding those files that are part of the main class path for testing.

7

Don’t let your tools (IDEs, frameworks, build tools, etc) dictate how you organise your code. Don’t put your properties files where eclipse wants them and don’t put them where your packaging tool would like them.

Organise your code such that it is obvious what your application does and so that code and resources are as close to the things they depend on as possible. If you want to change feature foo it you should be able to find it and all of its dependencies close together not intermingled with bar. You shouldn’t have to search or rely on your ide to find what you’re looking for.

If your tools don’t support this approach then change your tools.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật