开发者

Can resource directory be a subdirectory of sources in maven?

开发者 https://www.devze.com 2023-04-01 15:50 出处:网络
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 struc

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


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号