Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven war plugin: archiveClasses without archiving resources

There is an archiveClasses option in maven-war-plugin, which packages all the classes in a single .jar, and then creates .war file with that jar in lib/ folder.

I need to do the same, but leave resource files in classes directory, so that they are still accessible from the classpath but easy to modify.

What is the easiest way to do that?

like image 260
weekens Avatar asked Jul 18 '11 13:07

weekens


2 Answers

Maybe you can try to configure your resources folder as a WebResource in the plugin configuration.

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <archiveClasses>true</archiveClasses>
        <webResources>
            <resource>
                <directory>src/main/resources</directory>
                <targetPath>WEB-INF/classes</targetPath>
                <filtering>true</filtering>
            </resource>
        </webResources>
    </configuration>
</plugin>
like image 155
Charles Hu Avatar answered Sep 28 '22 00:09

Charles Hu


One line answer : There are no options provided in maven-war-plugin to exclude the resources from the jar created using archiveClasses flag.

The possible and easiest workaround for this problem is to move the files present under src/main/java/resources directory to src/main/java/webapp/WEB-INF/classes directory.

like image 42
Raja Anbazhagan Avatar answered Sep 28 '22 02:09

Raja Anbazhagan