You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by S5 <su...@gmail.com> on 2009/11/27 05:58:21 UTC

Process webapp files between "copying webapp resources" and "building war"

Hello

I am using Maven 2.2.1

In my project I want to process some of the resource files. This needs to
happen after "copying webapp resources" step and before "building war" step.

Here's the log:

[war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources[myapp\src\main\webapp]
============> Need to process my resources here
[INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war

Is there a way to accomplish this?

Thanks

Re: Process webapp files between "copying webapp resources" and "building war"

Posted by Wayne Fay <wa...@gmail.com>.
>> Is there a way to run a command to build a war file from a webapp
>> directory?
>> Is there a way to rebuild the war during install phase?
>> Any other workaround or hook to accomplishing what I need to do?

The assembly plugin can construct just about any package you want.

You may need to build your war, install it, then depend on it in
another module where you unzip it, mess with the files, and then
install under a different GAV or using a classifier.

Wayne

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


Re: Process webapp files between "copying webapp resources" and "building war"

Posted by S5 <su...@gmail.com>.
I meant to write we can *not* control the order in which the plugins are
executed within a phase.

On Sun, Nov 29, 2009 at 7:27 PM, S5 <su...@gmail.com> wrote:

> Hi
>
> Thanks for the suggestion. Here's another attempt at explaining my problem:
>
> During war:war, packaging of webapp commences.
>
> Step 1: Assemble webapp
> Step 2: Process Overlay (if any)
> Step 3: Copy webapp webResources
> Step 4: Copy webapp resources
> Step 5: webapp assembly completed
> Step 6: Build war
>
> *It is between step 5 and step 6 that I want to run the ant task as I want
> to change some custom settings in the files that are in the webapp folder.
> *
>
> When I run my ant task, with the phase being "package", I can accomplish my
> changes to the files under target/myapp-webapp folder. However, since
> myapp-webapp.war is built before ant task is run, these changes are not
> getting to be a part of that war file. Consequently, the install phase is
> installing the war without the changes to files in webapp folder. I read
> somewhere that we can control the order in which the plugins are executed
> within a phase! :-(
>
> Is there a way to run a command to build a war file from a webapp
> directory?
> Is there a way to rebuild the war during install phase?
> Any other workaround or hook to accomplishing what I need to do?
>
> Thanks
>
>
>
> On Fri, Nov 27, 2009 at 12:43 PM, Anders Hammar <an...@hammar.net> wrote:
>
>> OK. There are different ways to solve this I think. Please understand that
>> the steps below are written theoretically, I haven't actually tried them.
>> I
>> leave that for you to do and report back to the community. :-)
>>
>> Solution 1:
>> 1. Create a new folder where you put the files you want to be processed.
>> 2. Bind the antrun plugin to a suitable phase and configure it to process
>> the files. The processed files should be placed in some folder in target/
>> (the build dir).
>> 3. Configure the war plugin (war:war) to include this folder (target/xxx)
>> as
>> a webResource. You can see how to do this here:
>>
>> http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
>>
>> Solution 2:
>> 1. Bind the antrun plugin to a suitable phase and configure it to process
>> the files in the src\main\webapp folder you want to process. Either place
>> the processed files in the correct folder structure under target/ (the
>> build
>> dir) so that they end up correctly in the war file, or put the in a
>> new/separate output folder under target/. The latter will force you to
>> configure the war plugin according to step 3 in solution 1.
>> 2. Configure the war plugin to exclude the files that you process through
>> the antrun plguin. Examples of this are found here:
>>
>> http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
>>
>> I'd say that solution 1 is the more robust solution. Solution 2 is cleaner
>> folder wise, but more error prune.
>>
>> Hope it helps,
>> /Anders
>>
>> PS. If you really need special processing you might want to consider
>> writing
>> a real maven plugin for that, instead of using the antrun plugin.
>>
>> On Fri, Nov 27, 2009 at 07:56, S5 <su...@gmail.com> wrote:
>>
>> > I would like to run an ant plugin here to process some custom strings in
>> > the
>> > resource files. Maven's filtering won't work for our case.
>> >
>> > Thanks
>> >
>> > On Fri, Nov 27, 2009 at 12:20 PM, Anders Hammar <an...@hammar.net>
>> wrote:
>> >
>> > > I think it will be easier for us to help you if you tell us what kind
>> of
>> > > processing you want to do.
>> > >
>> > > You cannot insert a process step within the war plugin execution of
>> the
>> > war
>> > > goal (which is what you say in your log output). TO do that you need
>> to
>> > > adapt the plugin itself. However, the war plugin supports filtering (a
>> > type
>> > > of processing) and you can also have several web resources. Depending
>> on
>> > > what you want to do one of these possibilities could be your solution,
>> > > possibly together with some other plugin (doing the processing).
>> > >
>> > > /Anders
>> > >
>> > > On Fri, Nov 27, 2009 at 05:58, S5 <su...@gmail.com> wrote:
>> > >
>> > > > Hello
>> > > >
>> > > > I am using Maven 2.2.1
>> > > >
>> > > > In my project I want to process some of the resource files. This
>> needs
>> > to
>> > > > happen after "copying webapp resources" step and before "building
>> war"
>> > > > step.
>> > > >
>> > > > Here's the log:
>> > > >
>> > > > [war:war {execution: default-war}]
>> > > > [INFO] Packaging webapp
>> > > > [INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
>> > > > [INFO] Processing war project
>> > > > [INFO] Copying webapp resources[myapp\src\main\webapp]
>> > > > ============> Need to process my resources here
>> > > > [INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war
>> > > >
>> > > > Is there a way to accomplish this?
>> > > >
>> > > > Thanks
>> > > >
>> > >
>> >
>>
>
>

Re: Process webapp files between "copying webapp resources" and "building war"

Posted by Anders Hammar <an...@hammar.net>.
Where do the files you want to alter come from? Is any of the ones that
you've put in resources of webResource folder? If so solution 1 or 2 as I
listed earlier should work. Or go with Wayne's solution.

/Anders

On Sun, Nov 29, 2009 at 14:57, S5 <su...@gmail.com> wrote:

> Hi
>
> Thanks for the suggestion. Here's another attempt at explaining my problem:
>
> During war:war, packaging of webapp commences.
>
> Step 1: Assemble webapp
> Step 2: Process Overlay (if any)
> Step 3: Copy webapp webResources
> Step 4: Copy webapp resources
> Step 5: webapp assembly completed
> Step 6: Build war
>
> *It is between step 5 and step 6 that I want to run the ant task as I want
> to change some custom settings in the files that are in the webapp folder.*
>
> When I run my ant task, with the phase being "package", I can accomplish my
> changes to the files under target/myapp-webapp folder. However, since
> myapp-webapp.war is built before ant task is run, these changes are not
> getting to be a part of that war file. Consequently, the install phase is
> installing the war without the changes to files in webapp folder. I read
> somewhere that we can control the order in which the plugins are executed
> within a phase! :-(
>
> Is there a way to run a command to build a war file from a webapp
> directory?
> Is there a way to rebuild the war during install phase?
> Any other workaround or hook to accomplishing what I need to do?
>
> Thanks
>
>
>
> On Fri, Nov 27, 2009 at 12:43 PM, Anders Hammar <an...@hammar.net> wrote:
>
> > OK. There are different ways to solve this I think. Please understand
> that
> > the steps below are written theoretically, I haven't actually tried them.
> I
> > leave that for you to do and report back to the community. :-)
> >
> > Solution 1:
> > 1. Create a new folder where you put the files you want to be processed.
> > 2. Bind the antrun plugin to a suitable phase and configure it to process
> > the files. The processed files should be placed in some folder in target/
> > (the build dir).
> > 3. Configure the war plugin (war:war) to include this folder (target/xxx)
> > as
> > a webResource. You can see how to do this here:
> >
> >
> http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
> >
> > Solution 2:
> > 1. Bind the antrun plugin to a suitable phase and configure it to process
> > the files in the src\main\webapp folder you want to process. Either place
> > the processed files in the correct folder structure under target/ (the
> > build
> > dir) so that they end up correctly in the war file, or put the in a
> > new/separate output folder under target/. The latter will force you to
> > configure the war plugin according to step 3 in solution 1.
> > 2. Configure the war plugin to exclude the files that you process through
> > the antrun plguin. Examples of this are found here:
> >
> >
> http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
> >
> > I'd say that solution 1 is the more robust solution. Solution 2 is
> cleaner
> > folder wise, but more error prune.
> >
> > Hope it helps,
> > /Anders
> >
> > PS. If you really need special processing you might want to consider
> > writing
> > a real maven plugin for that, instead of using the antrun plugin.
> >
> > On Fri, Nov 27, 2009 at 07:56, S5 <su...@gmail.com> wrote:
> >
> > > I would like to run an ant plugin here to process some custom strings
> in
> > > the
> > > resource files. Maven's filtering won't work for our case.
> > >
> > > Thanks
> > >
> > > On Fri, Nov 27, 2009 at 12:20 PM, Anders Hammar <an...@hammar.net>
> > wrote:
> > >
> > > > I think it will be easier for us to help you if you tell us what kind
> > of
> > > > processing you want to do.
> > > >
> > > > You cannot insert a process step within the war plugin execution of
> the
> > > war
> > > > goal (which is what you say in your log output). TO do that you need
> to
> > > > adapt the plugin itself. However, the war plugin supports filtering
> (a
> > > type
> > > > of processing) and you can also have several web resources. Depending
> > on
> > > > what you want to do one of these possibilities could be your
> solution,
> > > > possibly together with some other plugin (doing the processing).
> > > >
> > > > /Anders
> > > >
> > > > On Fri, Nov 27, 2009 at 05:58, S5 <su...@gmail.com> wrote:
> > > >
> > > > > Hello
> > > > >
> > > > > I am using Maven 2.2.1
> > > > >
> > > > > In my project I want to process some of the resource files. This
> > needs
> > > to
> > > > > happen after "copying webapp resources" step and before "building
> > war"
> > > > > step.
> > > > >
> > > > > Here's the log:
> > > > >
> > > > > [war:war {execution: default-war}]
> > > > > [INFO] Packaging webapp
> > > > > [INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
> > > > > [INFO] Processing war project
> > > > > [INFO] Copying webapp resources[myapp\src\main\webapp]
> > > > > ============> Need to process my resources here
> > > > > [INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war
> > > > >
> > > > > Is there a way to accomplish this?
> > > > >
> > > > > Thanks
> > > > >
> > > >
> > >
> >
>

Re: Process webapp files between "copying webapp resources" and "building war"

Posted by S5 <su...@gmail.com>.
Hi

Thanks for the suggestion. Here's another attempt at explaining my problem:

During war:war, packaging of webapp commences.

Step 1: Assemble webapp
Step 2: Process Overlay (if any)
Step 3: Copy webapp webResources
Step 4: Copy webapp resources
Step 5: webapp assembly completed
Step 6: Build war

*It is between step 5 and step 6 that I want to run the ant task as I want
to change some custom settings in the files that are in the webapp folder.*

When I run my ant task, with the phase being "package", I can accomplish my
changes to the files under target/myapp-webapp folder. However, since
myapp-webapp.war is built before ant task is run, these changes are not
getting to be a part of that war file. Consequently, the install phase is
installing the war without the changes to files in webapp folder. I read
somewhere that we can control the order in which the plugins are executed
within a phase! :-(

Is there a way to run a command to build a war file from a webapp directory?
Is there a way to rebuild the war during install phase?
Any other workaround or hook to accomplishing what I need to do?

Thanks



On Fri, Nov 27, 2009 at 12:43 PM, Anders Hammar <an...@hammar.net> wrote:

> OK. There are different ways to solve this I think. Please understand that
> the steps below are written theoretically, I haven't actually tried them. I
> leave that for you to do and report back to the community. :-)
>
> Solution 1:
> 1. Create a new folder where you put the files you want to be processed.
> 2. Bind the antrun plugin to a suitable phase and configure it to process
> the files. The processed files should be placed in some folder in target/
> (the build dir).
> 3. Configure the war plugin (war:war) to include this folder (target/xxx)
> as
> a webResource. You can see how to do this here:
>
> http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
>
> Solution 2:
> 1. Bind the antrun plugin to a suitable phase and configure it to process
> the files in the src\main\webapp folder you want to process. Either place
> the processed files in the correct folder structure under target/ (the
> build
> dir) so that they end up correctly in the war file, or put the in a
> new/separate output folder under target/. The latter will force you to
> configure the war plugin according to step 3 in solution 1.
> 2. Configure the war plugin to exclude the files that you process through
> the antrun plguin. Examples of this are found here:
>
> http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
>
> I'd say that solution 1 is the more robust solution. Solution 2 is cleaner
> folder wise, but more error prune.
>
> Hope it helps,
> /Anders
>
> PS. If you really need special processing you might want to consider
> writing
> a real maven plugin for that, instead of using the antrun plugin.
>
> On Fri, Nov 27, 2009 at 07:56, S5 <su...@gmail.com> wrote:
>
> > I would like to run an ant plugin here to process some custom strings in
> > the
> > resource files. Maven's filtering won't work for our case.
> >
> > Thanks
> >
> > On Fri, Nov 27, 2009 at 12:20 PM, Anders Hammar <an...@hammar.net>
> wrote:
> >
> > > I think it will be easier for us to help you if you tell us what kind
> of
> > > processing you want to do.
> > >
> > > You cannot insert a process step within the war plugin execution of the
> > war
> > > goal (which is what you say in your log output). TO do that you need to
> > > adapt the plugin itself. However, the war plugin supports filtering (a
> > type
> > > of processing) and you can also have several web resources. Depending
> on
> > > what you want to do one of these possibilities could be your solution,
> > > possibly together with some other plugin (doing the processing).
> > >
> > > /Anders
> > >
> > > On Fri, Nov 27, 2009 at 05:58, S5 <su...@gmail.com> wrote:
> > >
> > > > Hello
> > > >
> > > > I am using Maven 2.2.1
> > > >
> > > > In my project I want to process some of the resource files. This
> needs
> > to
> > > > happen after "copying webapp resources" step and before "building
> war"
> > > > step.
> > > >
> > > > Here's the log:
> > > >
> > > > [war:war {execution: default-war}]
> > > > [INFO] Packaging webapp
> > > > [INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
> > > > [INFO] Processing war project
> > > > [INFO] Copying webapp resources[myapp\src\main\webapp]
> > > > ============> Need to process my resources here
> > > > [INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war
> > > >
> > > > Is there a way to accomplish this?
> > > >
> > > > Thanks
> > > >
> > >
> >
>

Re: Process webapp files between "copying webapp resources" and "building war"

Posted by Anders Hammar <an...@hammar.net>.
OK. There are different ways to solve this I think. Please understand that
the steps below are written theoretically, I haven't actually tried them. I
leave that for you to do and report back to the community. :-)

Solution 1:
1. Create a new folder where you put the files you want to be processed.
2. Bind the antrun plugin to a suitable phase and configure it to process
the files. The processed files should be placed in some folder in target/
(the build dir).
3. Configure the war plugin (war:war) to include this folder (target/xxx) as
a webResource. You can see how to do this here:
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

Solution 2:
1. Bind the antrun plugin to a suitable phase and configure it to process
the files in the src\main\webapp folder you want to process. Either place
the processed files in the correct folder structure under target/ (the build
dir) so that they end up correctly in the war file, or put the in a
new/separate output folder under target/. The latter will force you to
configure the war plugin according to step 3 in solution 1.
2. Configure the war plugin to exclude the files that you process through
the antrun plguin. Examples of this are found here:
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

I'd say that solution 1 is the more robust solution. Solution 2 is cleaner
folder wise, but more error prune.

Hope it helps,
/Anders

PS. If you really need special processing you might want to consider writing
a real maven plugin for that, instead of using the antrun plugin.

On Fri, Nov 27, 2009 at 07:56, S5 <su...@gmail.com> wrote:

> I would like to run an ant plugin here to process some custom strings in
> the
> resource files. Maven's filtering won't work for our case.
>
> Thanks
>
> On Fri, Nov 27, 2009 at 12:20 PM, Anders Hammar <an...@hammar.net> wrote:
>
> > I think it will be easier for us to help you if you tell us what kind of
> > processing you want to do.
> >
> > You cannot insert a process step within the war plugin execution of the
> war
> > goal (which is what you say in your log output). TO do that you need to
> > adapt the plugin itself. However, the war plugin supports filtering (a
> type
> > of processing) and you can also have several web resources. Depending on
> > what you want to do one of these possibilities could be your solution,
> > possibly together with some other plugin (doing the processing).
> >
> > /Anders
> >
> > On Fri, Nov 27, 2009 at 05:58, S5 <su...@gmail.com> wrote:
> >
> > > Hello
> > >
> > > I am using Maven 2.2.1
> > >
> > > In my project I want to process some of the resource files. This needs
> to
> > > happen after "copying webapp resources" step and before "building war"
> > > step.
> > >
> > > Here's the log:
> > >
> > > [war:war {execution: default-war}]
> > > [INFO] Packaging webapp
> > > [INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
> > > [INFO] Processing war project
> > > [INFO] Copying webapp resources[myapp\src\main\webapp]
> > > ============> Need to process my resources here
> > > [INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war
> > >
> > > Is there a way to accomplish this?
> > >
> > > Thanks
> > >
> >
>

Re: Process webapp files between "copying webapp resources" and "building war"

Posted by S5 <su...@gmail.com>.
I would like to run an ant plugin here to process some custom strings in the
resource files. Maven's filtering won't work for our case.

Thanks

On Fri, Nov 27, 2009 at 12:20 PM, Anders Hammar <an...@hammar.net> wrote:

> I think it will be easier for us to help you if you tell us what kind of
> processing you want to do.
>
> You cannot insert a process step within the war plugin execution of the war
> goal (which is what you say in your log output). TO do that you need to
> adapt the plugin itself. However, the war plugin supports filtering (a type
> of processing) and you can also have several web resources. Depending on
> what you want to do one of these possibilities could be your solution,
> possibly together with some other plugin (doing the processing).
>
> /Anders
>
> On Fri, Nov 27, 2009 at 05:58, S5 <su...@gmail.com> wrote:
>
> > Hello
> >
> > I am using Maven 2.2.1
> >
> > In my project I want to process some of the resource files. This needs to
> > happen after "copying webapp resources" step and before "building war"
> > step.
> >
> > Here's the log:
> >
> > [war:war {execution: default-war}]
> > [INFO] Packaging webapp
> > [INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
> > [INFO] Processing war project
> > [INFO] Copying webapp resources[myapp\src\main\webapp]
> > ============> Need to process my resources here
> > [INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war
> >
> > Is there a way to accomplish this?
> >
> > Thanks
> >
>

Re: Process webapp files between "copying webapp resources" and "building war"

Posted by Anders Hammar <an...@hammar.net>.
I think it will be easier for us to help you if you tell us what kind of
processing you want to do.

You cannot insert a process step within the war plugin execution of the war
goal (which is what you say in your log output). TO do that you need to
adapt the plugin itself. However, the war plugin supports filtering (a type
of processing) and you can also have several web resources. Depending on
what you want to do one of these possibilities could be your solution,
possibly together with some other plugin (doing the processing).

/Anders

On Fri, Nov 27, 2009 at 05:58, S5 <su...@gmail.com> wrote:

> Hello
>
> I am using Maven 2.2.1
>
> In my project I want to process some of the resource files. This needs to
> happen after "copying webapp resources" step and before "building war"
> step.
>
> Here's the log:
>
> [war:war {execution: default-war}]
> [INFO] Packaging webapp
> [INFO] Assembling webapp[myapp] in [**\target\myapp-1.0-SNAPSHOT]
> [INFO] Processing war project
> [INFO] Copying webapp resources[myapp\src\main\webapp]
> ============> Need to process my resources here
> [INFO] Building war: myapp\target\myapp-1.0-SNAPSHOT.war
>
> Is there a way to accomplish this?
>
> Thanks
>