IntelliJ: how to make non java files copied to the bin directory as well?

前端 未结 4 1552
失恋的感觉
失恋的感觉 2020-12-08 16:02

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),

相关标签:
4条回答
  • 2020-12-08 16:32

    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
    
    0 讨论(0)
  • 2020-12-08 16:37

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

    This question duplicates/relates to:

    • copy jbehave stories into target directory using IntelliJ Idea
    • IntelliJ, Akka and Configuration files
    • IntelliJ IDEA 11.1.2 does not copy SQL files to the out folder
    • Add a properties file to IntelliJ's classpath
    • import images into an intelliJ Java project
    • Intellij - how do I add a text file to the resources
    • Null Pointer Exception for read properties file in Idea
    • IntelliJ Idea - resource SQL files not being copied to target
    • Scala getClass.getResource() returning null
    0 讨论(0)
  • 2020-12-08 16:47

    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.

    0 讨论(0)
  • 2020-12-08 16:48

    Uncheck use external build in project compiler setting.

    0 讨论(0)
提交回复
热议问题