Jan Zyka
Jan Zyka

Reputation: 17898

Can resource directory be a subdirectory of sources in maven?

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

Upvotes: 0

Views: 770

Answers (1)

Thomas
Thomas

Reputation: 88707

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>

Upvotes: 3

Related Questions