Why are project layout resources kept separate from Java sources?

后端 未结 8 2132
小鲜肉
小鲜肉 2020-12-10 02:05

Why does maven keep resources in a separate \"source folder\" from the Java sources?

From my experience, in Java the resource files are mostly treated like Java sou

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 02:12

    1) What do you think?

    I thinks, it's an excellent convention.

    2) Is there a good reason why maven keeps resources separate from sources?

    Yes. You follow the convention. Everyone, who has got your project code's access will know where to look for code and where for everything else. And certainly, where for test cases. And what will happen to which file when that plugin will be executed.

    3) Is there any counter indication in not using src/main/resources and src/test/resources and keeping resources in src/main/java and src/test/java using maven?

    There isn't a counter indication. It's matter of convention, nothing's wrong with the way you arrange your own code. In fact, if you ever created a Wicket project, you will see your HTML and your Java code stays side-by-side in Java package. But, it is just Wicket where you know the HTML is going to be by the side of Java files. But everything else goes in resources folder.

提交回复
热议问题