资源目录可以是maven中源的子目录吗?

发布于 2024-12-02 08:35:22 字数 843 浏览 4 评论 0原文

我正在尝试为我们的一个遗留项目创建一个 Maven 构建。由于要求之一是仍然与旧版 ant 构建脚本兼容,因此我无法更改项目目录结构。

问题是当前的目录结构如下:

+ src
  + java
    + com
      + whatever
        + whatever2
          + resources (!)

我的目标是拥有源目录 src/java 和资源目录 src/java/com/whatever/whatever2/resources 。

显然我需要设置src/java。这很好。

但我还需要创建 resources maven 资源目录。尝试以下操作:

    <resources>
       <resource>
           <directory>src/java/com/whatever/whatever2/resources</directory>
       </resource>
    </resources>

但是一旦我执行此操作并运行 mvn clean package ,它就会给我:

[INFO] No sources to compile

一旦删除 部分,模块就会编译得很好并且拥有所有内容里面的课程。关于如何解决这个问题有什么建议吗?谢谢

I am trying to create a maven build for one of our legacy projects. Since one of the requirements is to be still compatible with the legacy ant build script I can't change the project directory structure.

The problem is the current directory structure which is as follows:

+ src
  + java
    + com
      + whatever
        + whatever2
          + resources (!)

My goal is to have source directory src/java and resource directory src/java/com/whatever/whatever2/resources.

Obviously I need to set <sourceDirectory>src/java</sourceDirectory>. This is fine.

But I would also need to make the resources maven resource directory. Trying the following:

    <resources>
       <resource>
           <directory>src/java/com/whatever/whatever2/resources</directory>
       </resource>
    </resources>

But once I do this and run mvn clean package it gives me:

[INFO] No sources to compile

Once I remove the <resources> section the module is compiled just fine and have all the classes inside. Any tips on how to solve this? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

澉约 2024-12-09 08:35:22

我们有类似的设置(XMBean 描述符位于使用它们的 MBean 实现旁边),但从资源中排除 java 文件:

<resource>
  <directory>src/main/java</directory>
  <excludes>
    <exclude>**/*.java</exclude>
  </excludes>
</resource>

We have a similar setup (XMBean descriptors next to the MBean implementations using them), but exclude java files from the resources:

<resource>
  <directory>src/main/java</directory>
  <excludes>
    <exclude>**/*.java</exclude>
  </excludes>
</resource>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文