Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven add properties file to jar file

I am using the following plugin configuration to make a jar file and I want to include non-java src files in the same place in the output jar as described here.

        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <compilerArgument>-Xlint:all</compilerArgument>
            <showWarnings>true</showWarnings>
            <showDeprecation>true</showDeprecation>   
            <!-- include non-java src files in the same place in the output jar -->
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.properties</include>
                    </includes>
                    <filtering>true</filtering>
                </resource>
            </resources>                                     
        </configuration>  

The above does not work and neither does the following:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
            <!-- include non-java src files in the same place in the output jar -->
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.properties</include>
                    </includes>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </configuration>
    </plugin>        

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <compilerArgument>-Xlint:all</compilerArgument>
            <showWarnings>true</showWarnings>
            <showDeprecation>true</showDeprecation>                    
        </configuration>                
    </plugin>
like image 883
AKZ Avatar asked Jun 02 '14 05:06

AKZ


1 Answers

Add file in the same package (folder) in src/main/resources instead of src/main/java or see my answer With maven - clean package, xml source files are not included in classpath

like image 127
Andrzej Jozwik Avatar answered Sep 20 '22 17:09

Andrzej Jozwik