21

My module contains some non java files along the java source files. When the module is built, the java files are copied to the bin folder (and included in the jar artifact), but the non java files are left out.

I need them to be copied as well (this is what Eclipse does). Note, that they do appear in the project tree view on the left, I did not exclude them in any way.

How can I make them get into the bin folder (jar artifact)?

Thanks.

mark
  • 59,016
  • 79
  • 296
  • 580

4 Answers4

27

Settings (Preferences on Mac) | Compiler | Resource Patterns.

This question duplicates/relates to:

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 6
    In IDEA 12 it was changed to **Exclude** patterns (defaults to `!*.form;!*.java;!*.class;!*.groovy;!*.as;!*.flex;!*.kt`), so all the other files will be copied by default. This will make it a less popular question. – CrazyCoder Jun 24 '12 at 12:33
  • @CrazyCoder Is there any bug related to this in IDEA 12.0.4? It seems that only rebuild copies resources to classpath, not make. BTW I had filed an issue also. – Cemo Mar 01 '13 at 23:30
  • @Cemo try [12.1 EAP build](http://confluence.jetbrains.com/display/IDEADEV/IDEA+12.1+EAP). – CrazyCoder Mar 02 '13 at 05:56
  • @CrazyCoder Even though it was been changed to Exclude file types, the implicitly included file types **DO NOT** encompass all file types other than the exclusions. Thus, you still need to manually include your file type if you're not getting your resource. – NoName Jul 21 '17 at 19:20
7

On IDEA 14.1.4, the xml file in src/main/java/my/package folder is not copied. My compiler settings are !?*.java;!?*.form;!?*.class;!?*.groovy;!?*.scala;!?*.flex;!?*.kt;!?*.clj;!?*.aj.

I changed the gradle file by adding:

test {
    resources {
        srcDir 'src/main/java'
        include '**/*.xml'
    }
}

It starts working. I am not sure if I have missed anything, but I could not find that part reflected on project settings.

If you are working with Maven, the following code should have the same effect:

<build>
    <testResources>
        <testResource>
            <filtering>false</filtering>
            <directory>src/test/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </testResource>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>
</build>

I posted it here as an answer, because it may help someone who has the same issue and the above answers may not work.

Devs love ZenUML
  • 11,344
  • 8
  • 53
  • 67
1

Uncheck use external build in project compiler setting.

Morn
  • 11
  • 1
0

Using CrazyCoder's info about version 12 (which I'm not using), I added the following as my resource pattern which worked well:

*.*;!*.form;!*.java;!*.class;!*.groovy;!*.as;!*.flex;!*.kt
genspire
  • 136
  • 6