Discussion:
Excluding certain file types using the maven-war-plugin
Alex Coles
2008-10-13 02:07:35 UTC
Permalink
I am encountering problems trying to exclude certain file types from
my WAR files. My WAR files are bloated, and becoming difficult to very
cumbersome to deploy to production servers.

Here's the two main types of files that should not be included in my WARs:
* Versioning Control Files (.git, .gitignore, .svn; I am using git's
submodules feature with one particular directory, but certainly do not
want to deploy a whole .git repository with my WAR)
* Photoshop PSD files, of which most are contained within a
assets/src-images folder.

This issue is somewhat similar to the issue raised here, over 2 years ago:
http://www.mail-archive.com/***@maven.apache.org/msg41790.html
http://markmail.org/message/qeoprewtxngxlaom

I have tried two configurations:

[1]

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>

<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>

<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>


[2]

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>

<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>

<webResources>

<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>

[1] doesn't seem to be working. the excludes are simply ignored.
[2] throws a NullPointerException if the directory element is omitted.
This appears to contradict the fourth example in the documentation
(under Includes/Excludes here:
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html)
which shows the directory element may be omitted.

Thanks for any advice you can give.

Alex Coles
Wayne Fay
2008-10-13 04:05:55 UTC
Permalink
You are specifying version 2.0.2.

The website docs appear to be for 2.1-alpha-2 (note the Last Published
etc near the top left corner). I would try that version instead, with
this configuration, perhaps the NPE will go away.

Wayne
Post by Alex Coles
I am encountering problems trying to exclude certain file types from
my WAR files. My WAR files are bloated, and becoming difficult to very
cumbersome to deploy to production servers.
* Versioning Control Files (.git, .gitignore, .svn; I am using git's
submodules feature with one particular directory, but certainly do not
want to deploy a whole .git repository with my WAR)
* Photoshop PSD files, of which most are contained within a
assets/src-images folder.
http://markmail.org/message/qeoprewtxngxlaom
[1]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>
[2]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<webResources>
<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
[1] doesn't seem to be working. the excludes are simply ignored.
[2] throws a NullPointerException if the directory element is omitted.
This appears to contradict the fourth example in the documentation
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html)
which shows the directory element may be omitted.
Thanks for any advice you can give.
Alex Coles
---------------------------------------------------------------------
Alex Coles
2008-10-13 04:18:58 UTC
Permalink
Post by Wayne Fay
You are specifying version 2.0.2.
The website docs appear to be for 2.1-alpha-2 (note the Last Published
etc near the top left corner). I would try that version instead, with
this configuration, perhaps the NPE will go away.
Wayne
Post by Alex Coles
I am encountering problems trying to exclude certain file types from
my WAR files. My WAR files are bloated, and becoming difficult to very
cumbersome to deploy to production servers.
* Versioning Control Files (.git, .gitignore, .svn; I am using git's
submodules feature with one particular directory, but certainly do not
want to deploy a whole .git repository with my WAR)
* Photoshop PSD files, of which most are contained within a
assets/src-images folder.
http://markmail.org/message/qeoprewtxngxlaom
[1]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>
[2]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<webResources>
<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
[1] doesn't seem to be working. the excludes are simply ignored.
[2] throws a NullPointerException if the directory element is omitted.
This appears to contradict the fourth example in the documentation
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html)
which shows the directory element may be omitted.
Thanks for any advice you can give.
Alex Coles
Thanks, Wayne. I tried upgrading to 2.1-alpha-2, per your suggestion.
Unfortunately, no change.

Going with configuration
[1] still isn't working.
[2] still throws a NullPointerException. The stack trace for which
I've posted here: http://pastie.org/private/l8nmhtepm74dm7idpuszlg

In addition, with 2.1-alpha-2, I am getting the following warning:
[WARNING] DEPRECATED [dependentWarExcludes]: use the excludes in the
overlay object instead

Alex
Wayne Fay
2008-10-13 05:57:53 UTC
Permalink
You can see the line causing the NPE here:
http://maven.apache.org/plugins/maven-war-plugin/xref/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.html

I'd grab the source, add some debugging/tracing log entries, trace
down (and fix) the issue, and contribute it back via JIRA. Or open an
issue in JIRA, attach a sample project which demonstrates the bug, and
wait for someone else to fix it for you.

Wayne
Post by Alex Coles
Post by Wayne Fay
You are specifying version 2.0.2.
The website docs appear to be for 2.1-alpha-2 (note the Last Published
etc near the top left corner). I would try that version instead, with
this configuration, perhaps the NPE will go away.
Wayne
Post by Alex Coles
I am encountering problems trying to exclude certain file types from
my WAR files. My WAR files are bloated, and becoming difficult to very
cumbersome to deploy to production servers.
* Versioning Control Files (.git, .gitignore, .svn; I am using git's
submodules feature with one particular directory, but certainly do not
want to deploy a whole .git repository with my WAR)
* Photoshop PSD files, of which most are contained within a
assets/src-images folder.
http://markmail.org/message/qeoprewtxngxlaom
[1]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>
[2]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<webResources>
<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
[1] doesn't seem to be working. the excludes are simply ignored.
[2] throws a NullPointerException if the directory element is omitted.
This appears to contradict the fourth example in the documentation
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html)
which shows the directory element may be omitted.
Thanks for any advice you can give.
Alex Coles
Thanks, Wayne. I tried upgrading to 2.1-alpha-2, per your suggestion.
Unfortunately, no change.
Going with configuration
[1] still isn't working.
[2] still throws a NullPointerException. The stack trace for which
I've posted here: http://pastie.org/private/l8nmhtepm74dm7idpuszlg
[WARNING] DEPRECATED [dependentWarExcludes]: use the excludes in the
overlay object instead
Alex
---------------------------------------------------------------------
Alex Coles
2008-10-13 21:39:54 UTC
Permalink
Post by Wayne Fay
http://maven.apache.org/plugins/maven-war-plugin/xref/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.html
I'd grab the source, add some debugging/tracing log entries, trace
down (and fix) the issue, and contribute it back via JIRA. Or open an
issue in JIRA, attach a sample project which demonstrates the bug, and
wait for someone else to fix it for you.
Wayne
Post by Alex Coles
Post by Wayne Fay
You are specifying version 2.0.2.
The website docs appear to be for 2.1-alpha-2 (note the Last Published
etc near the top left corner). I would try that version instead, with
this configuration, perhaps the NPE will go away.
Wayne
Post by Alex Coles
I am encountering problems trying to exclude certain file types from
my WAR files. My WAR files are bloated, and becoming difficult to very
cumbersome to deploy to production servers.
* Versioning Control Files (.git, .gitignore, .svn; I am using git's
submodules feature with one particular directory, but certainly do not
want to deploy a whole .git repository with my WAR)
* Photoshop PSD files, of which most are contained within a
assets/src-images folder.
http://markmail.org/message/qeoprewtxngxlaom
[1]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>
[2]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<webResources>
<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
[1] doesn't seem to be working. the excludes are simply ignored.
[2] throws a NullPointerException if the directory element is omitted.
This appears to contradict the fourth example in the documentation
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html)
which shows the directory element may be omitted.
Thanks for any advice you can give.
Alex Coles
Thanks, Wayne. I tried upgrading to 2.1-alpha-2, per your suggestion.
Unfortunately, no change.
Going with configuration
[1] still isn't working.
[2] still throws a NullPointerException. The stack trace for which
I've posted here: http://pastie.org/private/l8nmhtepm74dm7idpuszlg
[WARNING] DEPRECATED [dependentWarExcludes]: use the excludes in the
overlay object instead
Alex
Thanks for your suggestion. I can create a JIRA ticket (or even
attempt to create a patch for the NPE -- the code looks reasonably
straightforward).

However, there still is the discrepancy with the documentation.

Which syntax should I be using to exclude various file patterns from
the resultant WAR?


[1]

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>

<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>

<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>


[2]

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>

<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>

<webResources>

<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>

Cheers

Alex
Alex Coles
2008-10-14 15:52:26 UTC
Permalink
Post by Alex Coles
Thanks for your suggestion. I can create a JIRA ticket (or even
attempt to create a patch for the NPE -- the code looks reasonably
straightforward).
However, there still is the discrepancy with the documentation.
Which syntax should I be using to exclude various file patterns from
the resultant WAR?
[1]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</configuration>
</plugin>
[2]
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
<webResources>
<resource>
<!--<directory>resource2</directory>-->
<excludes>
<exclude>**/.git</exclude>
<exclude>**/.gitignore</exclude>
<exclude>**/*.psd</exclude>
<exclude>assets/src-images/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
Cheers
Alex
I worked out that I should be using the following:

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>

<dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>


<excludes>**/.git/**,**/*.gitignore,assets/src-images/**,**/*.psd,**/*.fla</excludes>
</configuration>
</plugin>

<excludes> should take a pattern, not a series of <exclude> elements.
Loading...