You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Hoffer <dh...@gmail.com> on 2012/02/17 18:52:59 UTC

How to exclude resources from war?

I have several folders in src/main/resources that need to be available
during the build (compile phase) but that I do not want added to the
generated war.  As far as I can tell the war plugin ignores requests
to exclude since they are in the standard resources folder (it seems
to only exclude if from custom folders).  So is there a way I can move
these out of resources and still make available when compiling?  Or am
I missing how to exclude from war?

Btw this is a GWT app so it's possible that the gwt-maven-plugin is
the one ignoring the configuration in the war to exclude these
folders.

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


Re: How to exclude resources from war?

Posted by Sebastian Otaegui <fe...@gmail.com>.
Just a guess from the file name.

is that a test logback configuration? if that is the case you may want to
put it in src/test/resources instead.


On Fri, Feb 17, 2012 at 12:36 PM, David Hoffer <dh...@gmail.com> wrote:

> Where is logback-test.xml in your directory structure relative to the pom?
>
> -Dave
>
> On Fri, Feb 17, 2012 at 11:07 AM, Greg Thomas <gr...@gmail.com>
> wrote:
> > On 17 February 2012 17:52, David Hoffer <dh...@gmail.com> wrote:
> >> Or am I missing how to exclude from war?
> >
> > I'm excluding a logback-test.xml file from the WAR using the directive
> >
> >  <plugin>
> >    <groupId>org.apache.maven.plugins</groupId>
> >    <artifactId>maven-war-plugin</artifactId>
> >    <version>2.2</version>
> >    <configuration>
> >      <packagingExcludes>**/logback-test.xml</packagingExcludes>
> >    </configuration>
> >  </plugin>
> >
> > And that seems to work just fine ...
> >
> > Greg
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
Those who do not understand Unix are condemned to reinvent it, poorly.
Any sufficiently recent Microsoft OS contains an ad hoc,
informally-specified, bug-ridden, slow implementation of half of Unix.

Re: How to exclude resources from war?

Posted by David Hoffer <dh...@gmail.com>.
But in that case wouldn't it be excluded in the compile phase too?
I'm looking for a way to include the resources for all uses (i.e.
compile phase) but just not package it in the war.  E.g. as if they
have provided scope.  That just gives me an idea...I might move those
resources to a new module and depend on it with provided scope...seems
like a hack to get around a basic feature the war plugin should
provide/allow.

-Dave

On Sat, Feb 18, 2012 at 5:49 AM, Greg Thomas <gr...@gmail.com> wrote:
> On 18 February 2012 10:55, Greg Thomas <gr...@gmail.com> wrote:
>> On 18 February 2012 10:46, Greg Thomas <gr...@gmail.com> wrote:
>>> On 17 February 2012 18:36, David Hoffer <dh...@gmail.com> wrote:
>>>> Where is logback-test.xml in your directory structure relative to the pom?
>>>
>>> Currently for legacy reasons in src/main/webapp/WEB-INF/classes -
>>> though I'm sure that we have tested it in src/main/resources.
>>
>> Actually, I take that back. I just retested, and it still is included
>> if it's left in src/main/resources - presumably why we've left it in
>> WEB-INF/classes.
>
> That was bugging me; I figured out that to exclude a resource from a
> WAR file you simply need to do something like the following ...
>
>                        <build>
>                                <!-- Don't use the logback-test.xml -->
>                                <resources>
>                                        <resource>
>                                                <directory>src/main/resources</directory>
>                                                <excludes>
>                                                        <exclude>logback-test.xml</exclude>
>                                                </excludes>
>                                        </resource>
>                                </resources>
>                                ...
>                        </build>
>
> HTH,
>
> Greg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

Re: How to exclude resources from war?

Posted by Greg Thomas <gr...@gmail.com>.
On 18 February 2012 10:55, Greg Thomas <gr...@gmail.com> wrote:
> On 18 February 2012 10:46, Greg Thomas <gr...@gmail.com> wrote:
>> On 17 February 2012 18:36, David Hoffer <dh...@gmail.com> wrote:
>>> Where is logback-test.xml in your directory structure relative to the pom?
>>
>> Currently for legacy reasons in src/main/webapp/WEB-INF/classes -
>> though I'm sure that we have tested it in src/main/resources.
>
> Actually, I take that back. I just retested, and it still is included
> if it's left in src/main/resources - presumably why we've left it in
> WEB-INF/classes.

That was bugging me; I figured out that to exclude a resource from a
WAR file you simply need to do something like the following ...

			<build>
				<!-- Don't use the logback-test.xml -->
				<resources>
					<resource>
						<directory>src/main/resources</directory>
						<excludes>
							<exclude>logback-test.xml</exclude>
						</excludes>
					</resource>		
				</resources>			
				...
			</build>

HTH,

Greg

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


Re: How to exclude resources from war?

Posted by Greg Thomas <gr...@gmail.com>.
On 18 February 2012 10:46, Greg Thomas <gr...@gmail.com> wrote:
> On 17 February 2012 18:36, David Hoffer <dh...@gmail.com> wrote:
>> Where is logback-test.xml in your directory structure relative to the pom?
>
> Currently for legacy reasons in src/main/webapp/WEB-INF/classes -
> though I'm sure that we have tested it in src/main/resources.

Actually, I take that back. I just retested, and it still is included
if it's left in src/main/resources - presumably why we've left it in
WEB-INF/classes.

Greg

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


Re: How to exclude resources from war?

Posted by Greg Thomas <gr...@gmail.com>.
On 17 February 2012 18:36, David Hoffer <dh...@gmail.com> wrote:
> Where is logback-test.xml in your directory structure relative to the pom?

Currently for legacy reasons in src/main/webapp/WEB-INF/classes -
though I'm sure that we have tested it in src/main/resources.

On 17 February 2012 18:44, Sebastian Otaegui <fe...@gmail.com> wrote:
> is that a test logback configuration? if that is the case you may want to
> put it in src/test/resources instead.

It's more a development logback configuration. We have both
logback.xml and logback-test.xml under src/main. When running inside
Eclipse, the logback-test takes preference and logs to stdout (i.e.
the Eclipse console) so you can see what's going on as it happens.

When the project is packaged up, that file is excluded and logback.xml
logs to a file.

We also have a src/test/resources/logback.xml that is used when
running JUnit tests.

Greg

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


Re: How to exclude resources from war?

Posted by David Hoffer <dh...@gmail.com>.
Where is logback-test.xml in your directory structure relative to the pom?

-Dave

On Fri, Feb 17, 2012 at 11:07 AM, Greg Thomas <gr...@gmail.com> wrote:
> On 17 February 2012 17:52, David Hoffer <dh...@gmail.com> wrote:
>> Or am I missing how to exclude from war?
>
> I'm excluding a logback-test.xml file from the WAR using the directive
>
>  <plugin>
>    <groupId>org.apache.maven.plugins</groupId>
>    <artifactId>maven-war-plugin</artifactId>
>    <version>2.2</version>
>    <configuration>
>      <packagingExcludes>**/logback-test.xml</packagingExcludes>
>    </configuration>
>  </plugin>
>
> And that seems to work just fine ...
>
> Greg
>
> ---------------------------------------------------------------------
> 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: How to exclude resources from war?

Posted by Greg Thomas <gr...@gmail.com>.
On 17 February 2012 17:52, David Hoffer <dh...@gmail.com> wrote:
> Or am I missing how to exclude from war?

I'm excluding a logback-test.xml file from the WAR using the directive

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <packagingExcludes>**/logback-test.xml</packagingExcludes>
    </configuration>
  </plugin>

And that seems to work just fine ...

Greg

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