You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Nick Bolton <nb...@unicon.net> on 2006/05/15 00:26:05 UTC

War plugin and filtering webapp files

Hello list. :)

I'm new to using maven2 and I'm having a problem using the maven-war-plugin
plugin when files in the webapp directory are tokenized and I want to have a
filter applied before they get war'ed.  I see there's an issue already -
MPWAR-46.  Could someone point me to some documentation that describes how
to apply what's given in MPWAR-46?  I'm new to maven plugin development.

Also, as a workaround, I was trying to copy files with filtering="on" using
the maven-antrun-plugin plugin into a different directory, then specify that
directory as the warSourceDirectory attribute.  But when they're copied it
doesn't filter them with the filters specified in the <build> element nor
with filtersets I place within the ant tasks.

Is there a trick applying the filters within ant tasks that I'm missing?

TIA

-nick



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


Re: War plugin and filtering webapp files

Posted by Brett Porter <br...@gmail.com>.
On 5/15/06, Julian Wood <wo...@ucalgary.ca> wrote:
> I take it this doesn't apply to the war plugin release then? This
> patch does not appear to have any docs, certainly not in the site
> folder from svn. Nevertheless, this is excellent news!

I think this came in before we started to clamp down.

The format is right, just change the surrounding tags to webResources.

>                      <resources>
>                          <resource>

> You should get filtering, right? Doesn't work. But, place that
> resources element inside the build element, and you will get
> filtering as per normal. Changing the resources element in the plugin
> configuration to a webResources element doesn't work either.

Ok, that's odd. I'll have to look into it - I'm just going based on
what I saw in the JIRA issue.

- Brett

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


Re: War plugin and filtering webapp files

Posted by Pete Marvin King <la...@gmail.com>.
  what war plugin version are you currently using?
 


Julian Wood wrote:
> On 15-May-06, at 1:51 PM, Julian Wood wrote:
>>
>> PS. I do regularly use the trick where you configure the war plugin
>> to use a resources directory which was the target of a regular
>> resource filtering process, and this works well, but adds a lot of
>> ambiguity to the pom.
>
> Hmm, I've just noticed that this trick seems to have broken with the
> latest war plugin. I'm not getting filtering on any of my old projects
> which employ this technique. It depends on:
>
>             <plugin>
>                 <artifactId>maven-war-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <goals>
>                             <goal>war</goal>
>                         </goals>
>                         <configuration>
>                            
> <warSourceDirectory>${project.build.directory}/filtered-webapp-resources</warSourceDirectory>
>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>
> where you've filtered resources as normal to the
> filtered-webapp-resources dir. That part still works of course, but
> the maven-war-plugin now seems to ignore it's source directory and
> figure out its resources differently.
>
> I would normally think this was okay, since it forces you to upgrade
> to a more transparent method of filtering (though there are still
> problems with that), but now that I think about it, none of my
> released (tagged) builds will build properly anymore, which seems like
> a bad thing.
>
> J
> -- 
> Julian Wood <wo...@ucalgary.ca>
>
> Software Engineer
> Teaching & Learning Centre
> University of Calgary
>
> http://tlc.ucalgary.ca
>
>
>
> ---------------------------------------------------------------------
> 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: War plugin and filtering webapp files

Posted by Julian Wood <wo...@ucalgary.ca>.
On 15-May-06, at 1:51 PM, Julian Wood wrote:
>
> PS. I do regularly use the trick where you configure the war plugin  
> to use a resources directory which was the target of a regular  
> resource filtering process, and this works well, but adds a lot of  
> ambiguity to the pom.

Hmm, I've just noticed that this trick seems to have broken with the  
latest war plugin. I'm not getting filtering on any of my old  
projects which employ this technique. It depends on:

             <plugin>
                 <artifactId>maven-war-plugin</artifactId>
                 <executions>
                     <execution>
                         <goals>
                             <goal>war</goal>
                         </goals>
                         <configuration>
                             <warSourceDirectory>$ 
{project.build.directory}/filtered-webapp-resources</warSourceDirectory>
                         </configuration>
                     </execution>
                 </executions>
             </plugin>

where you've filtered resources as normal to the filtered-webapp- 
resources dir. That part still works of course, but the maven-war- 
plugin now seems to ignore it's source directory and figure out its  
resources differently.

I would normally think this was okay, since it forces you to upgrade  
to a more transparent method of filtering (though there are still  
problems with that), but now that I think about it, none of my  
released (tagged) builds will build properly anymore, which seems  
like a bad thing.

J
--
Julian Wood <wo...@ucalgary.ca>

Software Engineer
Teaching & Learning Centre
University of Calgary

http://tlc.ucalgary.ca



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


Re: War plugin and filtering webapp files

Posted by Mark Hobson <ma...@gmail.com>.
http://jira.codehaus.org/browse/MWAR-43

On 19/05/06, Jorg Heymans <jo...@gmail.com> wrote:
> i'ld file it in jira, seems like enough people have tried to use it without
> success.
>
> Jorg
>
> On 5/19/06, Mark Hobson <ma...@gmail.com> wrote:
> >
> > Any update on this?  I'm getting a similar problem with filtered
> > webapp resources not expanding ${project.xxx} properties.
> >
> > Cheers,
> >
> > Mark
> >
> > On 17/05/06, Kris Nuttycombe <Kr...@noaa.gov> wrote:
> > > Is there a reason why the common functionality can't be factored out of
> > > the resources plugin so that there isn't code duplication between war
> > > and resources? I hate to see copy-and-paste coding in a situation like
> > this.
> > >
> > > Kris
> > >
> > > Jorg Heymans wrote:
> > >
> > > > This is something i couldn't get to work either.
> > > >
> > > > A brief look at the code reveils that it's doing exactly the same as
> > the
> > > > resources plugin to get the project properties, so i'm wondering if
> > > > this is
> > > > not working for normal resources as well.
> > > >
> > > >    private Properties getBuildFilterProperties()
> > > >        throws MojoExecutionException
> > > >    {
> > > >        // System properties
> > > >        Properties filterProperties = new Properties(
> > > > System.getProperties() );
> > > >
> > > >        // Project properties
> > > >        filterProperties.putAll( project.getProperties() );
> > > >
> > > >        for ( Iterator i = filters.iterator(); i.hasNext(); )
> > > >        {
> > > >            String filtersfile = (String) i.next();
> > > >
> > > >            try
> > > >            {
> > > >                Properties properties =
> > > > PropertyUtils.loadPropertyFile( new File( filtersfile ), true, true );
> > > >
> > > >                filterProperties.putAll( properties );
> > > >            }
> > > >            catch ( IOException e )
> > > >            {
> > > >                throw new MojoExecutionException( "Error loading
> > > > property file '" + filtersfile + "'", e );
> > > >            }
> > > >        }
> > > >        return filterProperties;
> > > >    }
> > > >
> > > >
> > > >
> > > > On 5/16/06, Julian Wood <wo...@ucalgary.ca> wrote:
> > > >
> > > >>
> > > >> Yes that works. The only mod I had to make was adding a filter file.
> > > >>
> > > >> http://jira.codehaus.org/browse/MWAR-12
> > > >>
> > > >> shows the filters in the configuration element of the maven-war-
> > > >> plugin, which _doesn't_ work. Moving the filters element up to be a
> > > >> child of the build element is the necessary fix.
> > > >>
> > > >> There would still appear to be a problem though - how can you get
> > > >> access to, say, ${project.version}. It would seem you would need to
> > > >> take a resource, filter it normally, then use the filtered resource
> > > >> as the filter file for the war plugin. Or how can you access a
> > > >> property set in a profile? These should all be available for
> > > >> filtering, and we shouldn't need to specify a filter file, if we want
> > > >> to be consistent with regular resource filtering.
> > > >>
> > > >> Should I file a JIRA issue, or are there more hidden gems that I'm
> > > >> missing?
> > > >>
> > > >> Thanks,
> > > >>
> > > >> J
> > > >>
> > > >>
> > > >> On 16-May-06, at 2:14 AM, Jorg Heymans wrote:
> > > >>
> > > >> > You need to make sure you add a filter. Below config works file for
> > > >> > me.
> > > >> >
> > > >> >  <build>
> > > >> >    <filters>
> > > >> >      <filter>your filter file here</filter>
> > > >> >    </filters>
> > > >> >    <plugins>
> > > >> >      <plugin>
> > > >> >        <groupId>org.apache.maven.plugins</groupId>
> > > >> >        <artifactId>maven-war-plugin</artifactId>
> > > >> >       ...
> > > >> >      </plugin>
> > > >> >    </plugins>
> > > >> >  </build>
> > > >>
> > > >> --
> > > >> Julian Wood <wo...@ucalgary.ca>
> > > >>
> > > >> Software Engineer
> > > >> Teaching & Learning Centre
> > > >> University of Calgary
> > > >>
> > > >> http://tlc.ucalgary.ca
> > > >>
> > > >>
> > > >>
> > > >> ---------------------------------------------------------------------
> > > >> 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
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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: War plugin and filtering webapp files

Posted by Jorg Heymans <jo...@gmail.com>.
i'ld file it in jira, seems like enough people have tried to use it without
success.

Jorg

On 5/19/06, Mark Hobson <ma...@gmail.com> wrote:
>
> Any update on this?  I'm getting a similar problem with filtered
> webapp resources not expanding ${project.xxx} properties.
>
> Cheers,
>
> Mark
>
> On 17/05/06, Kris Nuttycombe <Kr...@noaa.gov> wrote:
> > Is there a reason why the common functionality can't be factored out of
> > the resources plugin so that there isn't code duplication between war
> > and resources? I hate to see copy-and-paste coding in a situation like
> this.
> >
> > Kris
> >
> > Jorg Heymans wrote:
> >
> > > This is something i couldn't get to work either.
> > >
> > > A brief look at the code reveils that it's doing exactly the same as
> the
> > > resources plugin to get the project properties, so i'm wondering if
> > > this is
> > > not working for normal resources as well.
> > >
> > >    private Properties getBuildFilterProperties()
> > >        throws MojoExecutionException
> > >    {
> > >        // System properties
> > >        Properties filterProperties = new Properties(
> > > System.getProperties() );
> > >
> > >        // Project properties
> > >        filterProperties.putAll( project.getProperties() );
> > >
> > >        for ( Iterator i = filters.iterator(); i.hasNext(); )
> > >        {
> > >            String filtersfile = (String) i.next();
> > >
> > >            try
> > >            {
> > >                Properties properties =
> > > PropertyUtils.loadPropertyFile( new File( filtersfile ), true, true );
> > >
> > >                filterProperties.putAll( properties );
> > >            }
> > >            catch ( IOException e )
> > >            {
> > >                throw new MojoExecutionException( "Error loading
> > > property file '" + filtersfile + "'", e );
> > >            }
> > >        }
> > >        return filterProperties;
> > >    }
> > >
> > >
> > >
> > > On 5/16/06, Julian Wood <wo...@ucalgary.ca> wrote:
> > >
> > >>
> > >> Yes that works. The only mod I had to make was adding a filter file.
> > >>
> > >> http://jira.codehaus.org/browse/MWAR-12
> > >>
> > >> shows the filters in the configuration element of the maven-war-
> > >> plugin, which _doesn't_ work. Moving the filters element up to be a
> > >> child of the build element is the necessary fix.
> > >>
> > >> There would still appear to be a problem though - how can you get
> > >> access to, say, ${project.version}. It would seem you would need to
> > >> take a resource, filter it normally, then use the filtered resource
> > >> as the filter file for the war plugin. Or how can you access a
> > >> property set in a profile? These should all be available for
> > >> filtering, and we shouldn't need to specify a filter file, if we want
> > >> to be consistent with regular resource filtering.
> > >>
> > >> Should I file a JIRA issue, or are there more hidden gems that I'm
> > >> missing?
> > >>
> > >> Thanks,
> > >>
> > >> J
> > >>
> > >>
> > >> On 16-May-06, at 2:14 AM, Jorg Heymans wrote:
> > >>
> > >> > You need to make sure you add a filter. Below config works file for
> > >> > me.
> > >> >
> > >> >  <build>
> > >> >    <filters>
> > >> >      <filter>your filter file here</filter>
> > >> >    </filters>
> > >> >    <plugins>
> > >> >      <plugin>
> > >> >        <groupId>org.apache.maven.plugins</groupId>
> > >> >        <artifactId>maven-war-plugin</artifactId>
> > >> >       ...
> > >> >      </plugin>
> > >> >    </plugins>
> > >> >  </build>
> > >>
> > >> --
> > >> Julian Wood <wo...@ucalgary.ca>
> > >>
> > >> Software Engineer
> > >> Teaching & Learning Centre
> > >> University of Calgary
> > >>
> > >> http://tlc.ucalgary.ca
> > >>
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> 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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: War plugin and filtering webapp files

Posted by Mark Hobson <ma...@gmail.com>.
Any update on this?  I'm getting a similar problem with filtered
webapp resources not expanding ${project.xxx} properties.

Cheers,

Mark

On 17/05/06, Kris Nuttycombe <Kr...@noaa.gov> wrote:
> Is there a reason why the common functionality can't be factored out of
> the resources plugin so that there isn't code duplication between war
> and resources? I hate to see copy-and-paste coding in a situation like this.
>
> Kris
>
> Jorg Heymans wrote:
>
> > This is something i couldn't get to work either.
> >
> > A brief look at the code reveils that it's doing exactly the same as the
> > resources plugin to get the project properties, so i'm wondering if
> > this is
> > not working for normal resources as well.
> >
> >    private Properties getBuildFilterProperties()
> >        throws MojoExecutionException
> >    {
> >        // System properties
> >        Properties filterProperties = new Properties(
> > System.getProperties() );
> >
> >        // Project properties
> >        filterProperties.putAll( project.getProperties() );
> >
> >        for ( Iterator i = filters.iterator(); i.hasNext(); )
> >        {
> >            String filtersfile = (String) i.next();
> >
> >            try
> >            {
> >                Properties properties =
> > PropertyUtils.loadPropertyFile( new File( filtersfile ), true, true );
> >
> >                filterProperties.putAll( properties );
> >            }
> >            catch ( IOException e )
> >            {
> >                throw new MojoExecutionException( "Error loading
> > property file '" + filtersfile + "'", e );
> >            }
> >        }
> >        return filterProperties;
> >    }
> >
> >
> >
> > On 5/16/06, Julian Wood <wo...@ucalgary.ca> wrote:
> >
> >>
> >> Yes that works. The only mod I had to make was adding a filter file.
> >>
> >> http://jira.codehaus.org/browse/MWAR-12
> >>
> >> shows the filters in the configuration element of the maven-war-
> >> plugin, which _doesn't_ work. Moving the filters element up to be a
> >> child of the build element is the necessary fix.
> >>
> >> There would still appear to be a problem though - how can you get
> >> access to, say, ${project.version}. It would seem you would need to
> >> take a resource, filter it normally, then use the filtered resource
> >> as the filter file for the war plugin. Or how can you access a
> >> property set in a profile? These should all be available for
> >> filtering, and we shouldn't need to specify a filter file, if we want
> >> to be consistent with regular resource filtering.
> >>
> >> Should I file a JIRA issue, or are there more hidden gems that I'm
> >> missing?
> >>
> >> Thanks,
> >>
> >> J
> >>
> >>
> >> On 16-May-06, at 2:14 AM, Jorg Heymans wrote:
> >>
> >> > You need to make sure you add a filter. Below config works file for
> >> > me.
> >> >
> >> >  <build>
> >> >    <filters>
> >> >      <filter>your filter file here</filter>
> >> >    </filters>
> >> >    <plugins>
> >> >      <plugin>
> >> >        <groupId>org.apache.maven.plugins</groupId>
> >> >        <artifactId>maven-war-plugin</artifactId>
> >> >       ...
> >> >      </plugin>
> >> >    </plugins>
> >> >  </build>
> >>
> >> --
> >> Julian Wood <wo...@ucalgary.ca>
> >>
> >> Software Engineer
> >> Teaching & Learning Centre
> >> University of Calgary
> >>
> >> http://tlc.ucalgary.ca
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>

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


Re: War plugin and filtering webapp files

Posted by Kris Nuttycombe <Kr...@noaa.gov>.
Is there a reason why the common functionality can't be factored out of 
the resources plugin so that there isn't code duplication between war 
and resources? I hate to see copy-and-paste coding in a situation like this.

Kris

Jorg Heymans wrote:

> This is something i couldn't get to work either.
>
> A brief look at the code reveils that it's doing exactly the same as the
> resources plugin to get the project properties, so i'm wondering if 
> this is
> not working for normal resources as well.
>
>    private Properties getBuildFilterProperties()
>        throws MojoExecutionException
>    {
>        // System properties
>        Properties filterProperties = new Properties( 
> System.getProperties() );
>
>        // Project properties
>        filterProperties.putAll( project.getProperties() );
>
>        for ( Iterator i = filters.iterator(); i.hasNext(); )
>        {
>            String filtersfile = (String) i.next();
>
>            try
>            {
>                Properties properties =
> PropertyUtils.loadPropertyFile( new File( filtersfile ), true, true );
>
>                filterProperties.putAll( properties );
>            }
>            catch ( IOException e )
>            {
>                throw new MojoExecutionException( "Error loading
> property file '" + filtersfile + "'", e );
>            }
>        }
>        return filterProperties;
>    }
>
>
>
> On 5/16/06, Julian Wood <wo...@ucalgary.ca> wrote:
>
>>
>> Yes that works. The only mod I had to make was adding a filter file.
>>
>> http://jira.codehaus.org/browse/MWAR-12
>>
>> shows the filters in the configuration element of the maven-war-
>> plugin, which _doesn't_ work. Moving the filters element up to be a
>> child of the build element is the necessary fix.
>>
>> There would still appear to be a problem though - how can you get
>> access to, say, ${project.version}. It would seem you would need to
>> take a resource, filter it normally, then use the filtered resource
>> as the filter file for the war plugin. Or how can you access a
>> property set in a profile? These should all be available for
>> filtering, and we shouldn't need to specify a filter file, if we want
>> to be consistent with regular resource filtering.
>>
>> Should I file a JIRA issue, or are there more hidden gems that I'm
>> missing?
>>
>> Thanks,
>>
>> J
>>
>>
>> On 16-May-06, at 2:14 AM, Jorg Heymans wrote:
>>
>> > You need to make sure you add a filter. Below config works file for
>> > me.
>> >
>> >  <build>
>> >    <filters>
>> >      <filter>your filter file here</filter>
>> >    </filters>
>> >    <plugins>
>> >      <plugin>
>> >        <groupId>org.apache.maven.plugins</groupId>
>> >        <artifactId>maven-war-plugin</artifactId>
>> >       ...
>> >      </plugin>
>> >    </plugins>
>> >  </build>
>>
>> -- 
>> Julian Wood <wo...@ucalgary.ca>
>>
>> Software Engineer
>> Teaching & Learning Centre
>> University of Calgary
>>
>> http://tlc.ucalgary.ca
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: War plugin and filtering webapp files

Posted by Julian Wood <wo...@ucalgary.ca>.
On 17-May-06, at 1:14 AM, Jorg Heymans wrote:

> This is something i couldn't get to work either.
>
> A brief look at the code reveils that it's doing exactly the same  
> as the
> resources plugin to get the project properties, so i'm wondering if  
> this is
> not working for normal resources as well.

Filtering is working fine for normal resources. Maybe it's time to  
dive into the code and see what's up - it looks like it is a strange  
and unexpected bug, as you point out.

J

--

Julian Wood <wo...@ucalgary.ca>

Software Engineer
Teaching & Learning Centre
University of Calgary

http://tlc.ucalgary.ca



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


Re: War plugin and filtering webapp files

Posted by Jorg Heymans <jo...@gmail.com>.
This is something i couldn't get to work either.

A brief look at the code reveils that it's doing exactly the same as the
resources plugin to get the project properties, so i'm wondering if this is
not working for normal resources as well.

    private Properties getBuildFilterProperties()
        throws MojoExecutionException
    {
        // System properties
        Properties filterProperties = new Properties( System.getProperties() );

        // Project properties
        filterProperties.putAll( project.getProperties() );

        for ( Iterator i = filters.iterator(); i.hasNext(); )
        {
            String filtersfile = (String) i.next();

            try
            {
                Properties properties =
PropertyUtils.loadPropertyFile( new File( filtersfile ), true, true );

                filterProperties.putAll( properties );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Error loading
property file '" + filtersfile + "'", e );
            }
        }
        return filterProperties;
    }



On 5/16/06, Julian Wood <wo...@ucalgary.ca> wrote:
>
> Yes that works. The only mod I had to make was adding a filter file.
>
> http://jira.codehaus.org/browse/MWAR-12
>
> shows the filters in the configuration element of the maven-war-
> plugin, which _doesn't_ work. Moving the filters element up to be a
> child of the build element is the necessary fix.
>
> There would still appear to be a problem though - how can you get
> access to, say, ${project.version}. It would seem you would need to
> take a resource, filter it normally, then use the filtered resource
> as the filter file for the war plugin. Or how can you access a
> property set in a profile? These should all be available for
> filtering, and we shouldn't need to specify a filter file, if we want
> to be consistent with regular resource filtering.
>
> Should I file a JIRA issue, or are there more hidden gems that I'm
> missing?
>
> Thanks,
>
> J
>
>
> On 16-May-06, at 2:14 AM, Jorg Heymans wrote:
>
> > You need to make sure you add a filter. Below config works file for
> > me.
> >
> >  <build>
> >    <filters>
> >      <filter>your filter file here</filter>
> >    </filters>
> >    <plugins>
> >      <plugin>
> >        <groupId>org.apache.maven.plugins</groupId>
> >        <artifactId>maven-war-plugin</artifactId>
> >       ...
> >      </plugin>
> >    </plugins>
> >  </build>
>
> --
> Julian Wood <wo...@ucalgary.ca>
>
> Software Engineer
> Teaching & Learning Centre
> University of Calgary
>
> http://tlc.ucalgary.ca
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: War plugin and filtering webapp files

Posted by Julian Wood <wo...@ucalgary.ca>.
Yes that works. The only mod I had to make was adding a filter file.

http://jira.codehaus.org/browse/MWAR-12

shows the filters in the configuration element of the maven-war- 
plugin, which _doesn't_ work. Moving the filters element up to be a  
child of the build element is the necessary fix.

There would still appear to be a problem though - how can you get  
access to, say, ${project.version}. It would seem you would need to  
take a resource, filter it normally, then use the filtered resource  
as the filter file for the war plugin. Or how can you access a  
property set in a profile? These should all be available for  
filtering, and we shouldn't need to specify a filter file, if we want  
to be consistent with regular resource filtering.

Should I file a JIRA issue, or are there more hidden gems that I'm  
missing?

Thanks,

J


On 16-May-06, at 2:14 AM, Jorg Heymans wrote:

> You need to make sure you add a filter. Below config works file for  
> me.
>
>  <build>
>    <filters>
>      <filter>your filter file here</filter>
>    </filters>
>    <plugins>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-war-plugin</artifactId>
> 	...
>      </plugin>
>    </plugins>
>  </build>

--
Julian Wood <wo...@ucalgary.ca>

Software Engineer
Teaching & Learning Centre
University of Calgary

http://tlc.ucalgary.ca



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


Re: War plugin and filtering webapp files

Posted by Jorg Heymans <jo...@gmail.com>.
You need to make sure you add a filter. Below config works file for me.

  <build>
    <filters>
      <filter>your filter file here</filter>
    </filters>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <warSourceDirectory>src/main/webapp</warSourceDirectory>
              <webResources>
                <resource>
                  <directory>src/main/webapp</directory>
                  <filtering>true</filtering>
                  <includes>
                    <include>**/*.xml</include>
                  </includes>
                </resource>
              </webResources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Re: War plugin and filtering webapp files

Posted by Julian Wood <wo...@ucalgary.ca>.
On 14-May-06, at 5:46 PM, Brett Porter wrote:

> No, but there should be. We're no longer accepting patches like this
> without docs.

I take it this doesn't apply to the war plugin release then? This  
patch does not appear to have any docs, certainly not in the site  
folder from svn. Nevertheless, this is excellent news!

>
> It's basically a identical to a normal <resources> element, but inside
> the plugin configuration.

So by that token, if you create the webapp archetype:

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes - 
DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.0- 
alpha-4 -DgroupId=ca.ucalgary.tlc -DartifactId=my-webapp

And then add this to the pom.xml:

     <build>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
                 <version>2.0</version>
                 <configuration>
                     <resources>
                         <resource>
                             <filtering>true</filtering>
                             <directory>${basedir}/src/main/webapp</ 
directory>
                             <includes>
                                 <include>**/*.xml</include>
                             </includes>
                         </resource>
                     </resources>
                 </configuration>
             </plugin>
         </plugins>
     </build>

And finally change the web.xml produced by the archetype so there is  
something to filter:

<web-app>
   <display-name>${project.name}</display-name>
</web-app>

You should get filtering, right? Doesn't work. But, place that  
resources element inside the build element, and you will get  
filtering as per normal. Changing the resources element in the plugin  
configuration to a webResources element doesn't work either.

Has anyone got this working? What's the trick? (says I refusing to  
look through source code).

Thanks, J

PS. I do regularly use the trick where you configure the war plugin  
to use a resources directory which was the target of a regular  
resource filtering process, and this works well, but adds a lot of  
ambiguity to the pom.

PPS. http://jira.codehaus.org/browse/MWAR-12 has lots of hints, but  
all to no avail.




>
> - Brett
>
> On 5/14/06, Nick Bolton <nb...@unicon.net> wrote:
>> Thanks, Brett.  Are there any examples of how to use the webResources
>> element?
>>
>> Thanks!
>> -nick
>>
>>
>> On 5/14/06 4:11 PM, "Brett Porter" <br...@gmail.com> wrote:
>>
>> > MPWAR is for the Maven1 plugin.
>> >
>> > You want to use the <webResources> element inside the WAR  
>> plugin, new
>> > as of v2.0 released yesterday.
>> >
>> > - Brett
>> >
>> > On 5/14/06, Nick Bolton <nb...@unicon.net> wrote:
>> >> Hello list. :)
>> >>
>> >> I'm new to using maven2 and I'm having a problem using the  
>> maven-war-plugin
>> >> plugin when files in the webapp directory are tokenized and I  
>> want to have a
>> >> filter applied before they get war'ed.  I see there's an issue  
>> already -
>> >> MPWAR-46.  Could someone point me to some documentation that  
>> describes how
>> >> to apply what's given in MPWAR-46?  I'm new to maven plugin  
>> development.
>> >>
>> >> Also, as a workaround, I was trying to copy files with  
>> filtering="on" using
>> >> the maven-antrun-plugin plugin into a different directory, then  
>> specify that
>> >> directory as the warSourceDirectory attribute.  But when  
>> they're copied it
>> >> doesn't filter them with the filters specified in the <build>  
>> element nor
>> >> with filtersets I place within the ant tasks.
>> >>
>> >> Is there a trick applying the filters within ant tasks that I'm  
>> missing?
>> >>
>> >> TIA
>> >>
>> >> -nick
>> >>
>> >>
>> >>
>> >>  
>> ---------------------------------------------------------------------
>> >> 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
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>

--
Julian Wood <wo...@ucalgary.ca>

Software Engineer
Teaching & Learning Centre
University of Calgary

http://tlc.ucalgary.ca



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


Re: War plugin and filtering webapp files

Posted by Brett Porter <br...@gmail.com>.
No, but there should be. We're no longer accepting patches like this
without docs.

It's basically a identical to a normal <resources> element, but inside
the plugin configuration.

- Brett

On 5/14/06, Nick Bolton <nb...@unicon.net> wrote:
> Thanks, Brett.  Are there any examples of how to use the webResources
> element?
>
> Thanks!
> -nick
>
>
> On 5/14/06 4:11 PM, "Brett Porter" <br...@gmail.com> wrote:
>
> > MPWAR is for the Maven1 plugin.
> >
> > You want to use the <webResources> element inside the WAR plugin, new
> > as of v2.0 released yesterday.
> >
> > - Brett
> >
> > On 5/14/06, Nick Bolton <nb...@unicon.net> wrote:
> >> Hello list. :)
> >>
> >> I'm new to using maven2 and I'm having a problem using the maven-war-plugin
> >> plugin when files in the webapp directory are tokenized and I want to have a
> >> filter applied before they get war'ed.  I see there's an issue already -
> >> MPWAR-46.  Could someone point me to some documentation that describes how
> >> to apply what's given in MPWAR-46?  I'm new to maven plugin development.
> >>
> >> Also, as a workaround, I was trying to copy files with filtering="on" using
> >> the maven-antrun-plugin plugin into a different directory, then specify that
> >> directory as the warSourceDirectory attribute.  But when they're copied it
> >> doesn't filter them with the filters specified in the <build> element nor
> >> with filtersets I place within the ant tasks.
> >>
> >> Is there a trick applying the filters within ant tasks that I'm missing?
> >>
> >> TIA
> >>
> >> -nick
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
>
>
> ---------------------------------------------------------------------
> 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: War plugin and filtering webapp files

Posted by Nick Bolton <nb...@unicon.net>.
Thanks, Brett.  Are there any examples of how to use the webResources
element?

Thanks!
-nick


On 5/14/06 4:11 PM, "Brett Porter" <br...@gmail.com> wrote:

> MPWAR is for the Maven1 plugin.
> 
> You want to use the <webResources> element inside the WAR plugin, new
> as of v2.0 released yesterday.
> 
> - Brett
> 
> On 5/14/06, Nick Bolton <nb...@unicon.net> wrote:
>> Hello list. :)
>> 
>> I'm new to using maven2 and I'm having a problem using the maven-war-plugin
>> plugin when files in the webapp directory are tokenized and I want to have a
>> filter applied before they get war'ed.  I see there's an issue already -
>> MPWAR-46.  Could someone point me to some documentation that describes how
>> to apply what's given in MPWAR-46?  I'm new to maven plugin development.
>> 
>> Also, as a workaround, I was trying to copy files with filtering="on" using
>> the maven-antrun-plugin plugin into a different directory, then specify that
>> directory as the warSourceDirectory attribute.  But when they're copied it
>> doesn't filter them with the filters specified in the <build> element nor
>> with filtersets I place within the ant tasks.
>> 
>> Is there a trick applying the filters within ant tasks that I'm missing?
>> 
>> TIA
>> 
>> -nick
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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
> 



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


Re: War plugin and filtering webapp files

Posted by Brett Porter <br...@gmail.com>.
MPWAR is for the Maven1 plugin.

You want to use the <webResources> element inside the WAR plugin, new
as of v2.0 released yesterday.

- Brett

On 5/14/06, Nick Bolton <nb...@unicon.net> wrote:
> Hello list. :)
>
> I'm new to using maven2 and I'm having a problem using the maven-war-plugin
> plugin when files in the webapp directory are tokenized and I want to have a
> filter applied before they get war'ed.  I see there's an issue already -
> MPWAR-46.  Could someone point me to some documentation that describes how
> to apply what's given in MPWAR-46?  I'm new to maven plugin development.
>
> Also, as a workaround, I was trying to copy files with filtering="on" using
> the maven-antrun-plugin plugin into a different directory, then specify that
> directory as the warSourceDirectory attribute.  But when they're copied it
> doesn't filter them with the filters specified in the <build> element nor
> with filtersets I place within the ant tasks.
>
> Is there a trick applying the filters within ant tasks that I'm missing?
>
> TIA
>
> -nick
>
>
>
> ---------------------------------------------------------------------
> 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: War plugin and filtering webapp files

Posted by Theo Platt <th...@beausejour.net>.
Following this thread and the JIRA issue at the end, if you use the 2.0.1
war-plugin the filtering now works. My pom.xml looks like - 

    <build>
        <finalName>mywebapp</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0.1</version>
                <configuration>
                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                           
<directory>${basedir}/src/main/webapp</directory>
                            <includes>
                                <include>**/*.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>


and in my web.xml I have - 

<display-name>${project.name} v${project.version}</display-name>

Hope this helps someone else coming across this thread

Cheers

Theo
-- 
View this message in context: http://www.nabble.com/War-plugin-and-filtering-webapp-files-tf1617964s177.html#a7736926
Sent from the Maven - Users mailing list archive at Nabble.com.


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