Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude certain resources from the maven war plugin war file?

Tags:

maven

war

We've been using war:exploded for a while now and I'm trying to do away with it. I've added the following to my pom:

<resource>
    <directory>src/main/webapp</directory>
</resource>

This copies files such as the in src/main/webapp/keystore into target/classes/keystore so my local UI launcher works and sees everything. Score!

However, by adding to the resources list, this means that the same files also show up in the war file as keystore (correct) and WEB-INF/classes/keystore (wrong). It also means there there is a WEB-INF/classes/WEB-INF directory (blah). I'm trying to exclude the resource files from src/main/webapp resource since src/main/webapp/WEB-INF is already a resource.

I'm trying not to specifically exclude keystore and other files since we add/delete from that list semi-often. I've tried to add the following (and a number of other variants) to the war plugin configuration without results:

<webResources>
   <resource>
      <directory>src/main/webapp</directory>
      <excludes>
         <exclude>**</exclude>
      </excludes>
   </resource>
</webResources>

I've also read a number of other SO questions and I've spent at least an hour reading docs on from the maven war plugin page and tried other configs without success.

Any idea what magic I need to do here? Thanks in advance.

like image 792
Gray Avatar asked Oct 03 '13 20:10

Gray


1 Answers

warSourceExcludes worked for me. for example.To exclude js folder and scss folder from my war i tried...

 <configuration>
   <warSourceExcludes>js/*.*,scss/*.*</warSourceExcludes>      
   <webResources>
     <resource>
     <directory>src/main/webapp</directory>
     <filtering>true</filtering>
        <includes>
            <include>WEB-INF/web.xml</include>
        </includes>
     </resource>
   </webResources>
</configuration>
like image 79
Bibin Chorickanpara Avatar answered Nov 02 '22 12:11

Bibin Chorickanpara