Maven文件夹结构之外的文件可以编译吗? [英] Can files outside of the Maven folder structure get compiled?

查看:118
本文介绍了Maven文件夹结构之外的文件可以编译吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Java项目,该项目根据日期在2年前进行了修改. 该项目使用了Play框架,正如我记得的那样,该框架是在2012年建成并运行良好的. 开发人员显然试图将项目更改为Maven项目,但是文件夹结构无处不在,而不在Maven src文件夹结构内. 尝试运行Play命令在构建项目时不再起作用,并且使用Maven命令不会编译代码. 发生的只是将所有文件夹和源代码打包到一个.jar文件中.

所以问题是可以编译Maven文件夹结构外部的文件吗?"如果是这样, OR 我是否需要重组所有代码以放入适当的Maven文件夹结构中,以尝试使其再次正常工作?

感谢您的时间.

下面的文件夹树的概略图:无法像在另一个系统上那样张贴POM


  • 项目名称
    • src
      • main/java/
    • 树干
      • 项目名称
        • ...在这里蚀,模块,预编译,tmp中播放框架文件夹结构
        • conf
        • lib
    • 网页内容
      • META-INF
      • WEB-INF

解决方案

是的,您可以在非标准Maven文件夹结构中编译文件. Maven本机支持多个源目录,以用于生成源.

阅读《 Maven使用指南》. t使用约定

使用多个源目录当您生成一个 单个JAR(或其他工件),并具有多个源目录 与您要包含的课程.

此答案显示了如何通过指定适当的属性以从superpom中覆盖来在Maven中编辑目录结构. /p>

Maven pom文档显示了上面链接中提到的构建元素集.

作为旁注此答案涵盖了用于进行战争的非标准目录布局.

We have a Java project that was modified about 2 years ago based on the dates. The project uses a the Play Framework which as I recalled built and ran just fine back in 2012. The developer apparently had tried to change the project to be a Maven project but the folder structure is all over the place and not within the Maven src folder structure. Attempting to run the Play commands does not work on building the project any longer and using the Maven commands does not compile the code. What occurs is just the packaging of all of the folders and source code into a .jar file.

So the question is 'Can files outside of the Maven folder structure get compiled?' if so how, OR do I need to restructure all the code to be placed into the proper Maven folder structure to try and get this to work again?

Thanks for your time.

Rough view of the folder tree below: Unable to post the POM as it is on another system


  • Project Name
    • src
      • main/java/
    • trunk
      • Project Name
        • ... play framework folder structure in here eclipse, modules, precompiled, tmp
        • conf
        • lib
    • Web Content
      • META-INF
      • WEB-INF

解决方案

Yes you can compile files in a non-standard Maven folder structure. Maven natively supports multiple source directories for the purposes of generated sources.

Read the Maven use guide When You Can't Use the Conventions

Using Multiple Source Directories This occurs when you are producing a single JAR (or other artifact), and have several source directories with classes you want to include.

This answer shows how to edit the directory structure in Maven by specifying the appropriate properties to override from the superpom.

The Maven pom docs show the build element set mentioned in the link above.

As a side note this answer covers a non standard directory layout for building war.

这篇关于Maven文件夹结构之外的文件可以编译吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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