Search code examples
javamavennetbeansjarpackaging

.dat files not packaged in jar in Netbeans


I have a maven Java project projA that build into a jar. I have another maven Web project projB that holds a dependency of projA.

In proj A one of my classes accesses the resources located in the packages in projA.

When I expand the jar shown under dependencies in projB, I see that it does not contain the resource files (.dat).

What setting I need to do to copy these files into the jar when I build my projA in Netbeans

I am using NetBeans IDE 8.0.2 / Java 1.8


Solution

  • In your pom.xml, include something along the line like this:

    <build>
        <resources>
            <resource>
                <filtering>false</filtering>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.dat</include>
                </includes>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
    [...]