You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alex Coles <al...@gmail.com> on 2008/10/13 04:07:35 UTC

Excluding certain file types using the maven-war-plugin

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/users@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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Excluding certain file types using the maven-war-plugin

Posted by Alex Coles <al...@gmail.com>.
On Mon, Oct 13, 2008 at 11:39 PM, Alex Coles <al...@gmail.com> wrote:
>
> 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.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Excluding certain file types using the maven-war-plugin

Posted by Alex Coles <al...@gmail.com>.
On Mon, Oct 13, 2008 at 7:57 AM, Wayne Fay <wa...@gmail.com> wrote:
> 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
>
> On Sun, Oct 12, 2008 at 9:18 PM, Alex Coles <al...@gmail.com> wrote:
>> On Mon, Oct 13, 2008 at 6:05 AM, Wayne Fay <wa...@gmail.com> wrote:
>>> 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
>>>
>>> On Sun, Oct 12, 2008 at 7:07 PM, Alex Coles <al...@gmail.com> wrote:
>>>> 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/users@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
>>>>
>>
>> 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

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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Excluding certain file types using the maven-war-plugin

Posted by Wayne Fay <wa...@gmail.com>.
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

On Sun, Oct 12, 2008 at 9:18 PM, Alex Coles <al...@gmail.com> wrote:
> On Mon, Oct 13, 2008 at 6:05 AM, Wayne Fay <wa...@gmail.com> wrote:
>> 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
>>
>> On Sun, Oct 12, 2008 at 7:07 PM, Alex Coles <al...@gmail.com> wrote:
>>> 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/users@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
>>>
>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Excluding certain file types using the maven-war-plugin

Posted by Alex Coles <al...@gmail.com>.
On Mon, Oct 13, 2008 at 6:05 AM, Wayne Fay <wa...@gmail.com> wrote:
> 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
>
> On Sun, Oct 12, 2008 at 7:07 PM, Alex Coles <al...@gmail.com> wrote:
>> 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/users@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
>>

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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Excluding certain file types using the maven-war-plugin

Posted by Wayne Fay <wa...@gmail.com>.
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

On Sun, Oct 12, 2008 at 7:07 PM, Alex Coles <al...@gmail.com> wrote:
> 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/users@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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org