Quantcast

replace parameters when overlaying in maven

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

replace parameters when overlaying in maven

mavenbabuk
This post was updated on .
Hi,

     Using assembly i have generated a parent war. I need to use this parent war in another child project, This parent war also having parameters like ${path}.
    Now i run install command for child project. The parent war getting extracted.
    But i unable to replace the ${path} parameter value using the child pom.


Thanks
Babu K
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

Ron Wheeler
What is a parent war?

Describe your application a bit more and environment a bit more.

Ron


On 09/04/2012 2:30 AM, mavenbabuk wrote:

> Hi,
>
>       Using assembly i have generated a parent war. I need to use this parent
> war in another child project, This parent war also having parameters like
> ${path}.
>      Now i run install command for child project. The parent war getting
> extracted.
>      But i unable to replace the ${path} parameter value from the child pom.
>
>
>      Thank for the people who try to give answer.
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Need-to-change-parameters-of-War-when-overlay-tp5626856p5626856.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Ron Wheeler
President
Artifact Software Inc
email: [hidden email]
skype: ronaldmwheeler
phone: 866-970-2435, ext 102




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

offbyone
In reply to this post by mavenbabuk
I recently dealt with this exact challenge.

In the "child" war project that you are overlaying the parent with, you
need to configure the webResource section and turn filtering on like so:

In this example I will filter on any xml file in the WEB-INF folder.
 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <webResource>

<directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <includes>
                                <!--filter on xml files-->
                                <include>**.xml</include>
                            </includes>
                            <targetPath>WEB-INF</targetPath>
                            <filtering>true</filtering>
<!-***************HERE****************-->
                        </webResource>
                    </webResources>
                </configuration>
            </plugin>



On Sun, Apr 8, 2012 at 11:30 PM, mavenbabuk <[hidden email]> wrote:

> Hi,
>
>     Using assembly i have generated a parent war. I need to use this parent
> war in another child project, This parent war also having parameters like
> ${path}.
>    Now i run install command for child project. The parent war getting
> extracted.
>    But i unable to replace the ${path} parameter value from the child pom.
>
>
>    Thank for the people who try to give answer.
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Need-to-change-parameters-of-War-when-overlay-tp5626856p5626856.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

mavenbabuk
In reply to this post by Ron Wheeler
       
      Environment Details,
                Apache Maven 2.2.1
                Java version: 1.6.0_20
                Spring2

        Generating Parent War
        I have create a war from the common resource without mention the property value.
        This war has been generated by maven-assembly command.
        Then, i am getting the war in my target folder as "rdpv-core-webapp-1.1.war".
        This war will be used as parent war.

        (For example consider one of my common resource is "applicationContext-service.xml"
        This xml file handle a property "${current.vertical.title}" as given below,

                     <bean class="com.radaptive.rdpv.admin.service.impl.AccountServiceImpl">
                                <property name="accountDAO">
                                        <ref bean="accountDAO" />
                                </property>
                                <property name="userCache">
                                        <ref bean="userCache" />
                                </property>
                                <property name="messageResource">
                                        <ref bean="logResourceForService" />
                                </property>
                                <property name="auditLogSerivce">
                                        <ref bean="auditLogSerivce"/>
                                </property>
                                <property name="currentVertical"><value>${current.vertical.title}</value></property>
                        </bean>
        )
       
        Deploy Child Project
        Now, I create a child project with parent war dependency as given below,

                <dependency>
                        <groupId>org.radaptive.core</groupId>
                        <artifactId>rdpv-core-webapp</artifactId>
                        <version>1.1</version>
                        <type>war</type>
                </dependency>

        Also i mention the property value in this pom.xml as "<current.vertical.title>IDEAMED</current.vertical.title>"

       
        Here my complexity is,
                When i run install command for child project, this parent war getting extracted in my deploy path.
                But, Still the replacement of the property values change does not occur.

Thanks,
Babu K,
Ideas2it Technologies,
Mob: +91 95002 96737,
Email: babui2it@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

mavenbabuk
In reply to this post by offbyone

      Here i am given the problem in detail..      

      Environment Details,
                Apache Maven 2.2.1
                Java version: 1.6.0_20
                Spring2

        Generating Parent War
        I have create a war from the common resource without mention the property value.
        This war has been generated by maven-assembly command.
        Then, i am getting the war in my target folder as "rdpv-core-webapp-1.1.war".
        This war will be used as parent war.

        (For example consider one of my common resource is "applicationContext-service.xml"
        This xml file handle a property "${current.vertical.title}" as given below,

                     <bean class="com.radaptive.rdpv.admin.service.impl.AccountServiceImpl">
                                <property name="accountDAO">
                                        <ref bean="accountDAO" />
                                </property>
                                <property name="userCache">
                                        <ref bean="userCache" />
                                </property>
                                <property name="messageResource">
                                        <ref bean="logResourceForService" />
                                </property>
                                <property name="auditLogSerivce">
                                        <ref bean="auditLogSerivce"/>
                                </property>
                                <property name="currentVertical"><value>${current.vertical.title}</value></property>
                        </bean>
        )
       
        Deploy Child Project
        Now, I create a child project with parent war dependency as given below,

                <dependency>
                        <groupId>org.radaptive.core</groupId>
                        <artifactId>rdpv-core-webapp</artifactId>
                        <version>1.1</version>
                        <type>war</type>
                </dependency>

        Also i mention the property value in this pom.xml as "<current.vertical.title>IDEAMED</current.vertical.title>"

       
        Here my complexity is,
                When i run install command for child project, this parent war getting extracted in my deploy path.
                But, Still the replacement of the property values change does not occur.

Thanks,
Babu K,
Ideas2it Technologies,
Mob: +91 95002 96737,
Email: babui2it@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

Ansgar Konermann
You could externalize the configuration bits of "current.vertical.title"
into a config file or jndi parameter and have the web application read it
at runtime/during startup.

I doubt the WAR plugin can filter resources which are already packaged as
WAR, that is: have already gone through phase process-resources during
build of your "parent war". It *might*  be possible with a bunch of plugin
configuration (rtfm), but me personally would go for the "externalize"
solution.

Regards

Ansgar
Am 10.04.2012 08:35 schrieb "mavenbabuk" <[hidden email]>:

>
>      Here i am given the problem in detail..
>
>      *Environment Details*,
>                Apache Maven 2.2.1
>                Java version: 1.6.0_20
>                Spring2
>
>        *Generating Parent War*
>        I have create a war from the common resource without mention the
> property
> value.
>        This war has been generated by maven-assembly command.
>        Then, i am getting the war in my target folder as
> "rdpv-core-webapp-1.1.war".
>        This war will be used as parent war.
>
>        (For example consider one of my common resource is
> "applicationContext-service.xml"
>        This xml file handle a property *"${current.vertical.title}"* as
> given
> below,
>
>                     <bean
> class="com.radaptive.rdpv.admin.service.impl.AccountServiceImpl">
>                                <property name="accountDAO">
>                                        <ref bean="accountDAO" />
>                                </property>
>                                <property name="userCache">
>                                        <ref bean="userCache" />
>                                </property>
>                                <property name="messageResource">
>                                        <ref bean="logResourceForService" />
>                                </property>
>                                <property name="auditLogSerivce">
>                                        <ref bean="auditLogSerivce"/>
>                                </property>
>                                <property
>
> name="currentVertical"><value>*${current.vertical.title}*</value></property>
>                        </bean>
>        )
>
>        *Deploy Child Project*
>        Now, I create a child project with parent war dependency as given
> below,
>
>                <dependency>
>                        <groupId>org.radaptive.core</groupId>
>                        <artifactId>rdpv-core-webapp</artifactId>
>                        <version>1.1</version>
>                        <type>war</type>
>                </dependency>
>
>        Also i mention the property value in this pom.xml as
> *"<current.vertical.title>IDEAMED</current.vertical.title>"*
>
>
>        *Here my complexity* is,
>                When i run install command for child project, this parent
> war getting
> extracted in my deploy path.
>                But, Still the replacement of the property values change
> does not occur.
>
> Thanks,
> Babu K,
> Ideas2it Technologies,
> Mob: +91 95002 96737,
> Email: [hidden email]
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/replace-parameters-when-overlaying-in-maven-tp5626856p5629115.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

mavenbabuk

        I have tried with externalize property file named as "my-file.properties". I configured in pom for externalize as given below,

                        <plugin>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>properties-maven-plugin</artifactId>
                                    <version>1.0-alpha-1</version>
                                    <executions>
                                        <execution>
                                            <phase>initialize</phase>
                                            <goals>
                                                <goal>read-project-properties</goal>
                                            </goals>
                                            <configuration>
                                                <files>
                                                    <file>my-file.properties</file>
                                                </files>
                                            </configuration>
                                        </execution>
                                    </executions>
                                </plugin>
        But, It does not support.

        Please suggest me best way to externalize properties.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

Ansgar Konermann
You cannot use *Maven* properties in your application. You need to use some
Java JRE call or equivalent in your application to load the configuration
at startup or run time. Your pom is merely loading the properties from a
file so that *maven* can use them during build time, i. e. you could
reference them in your pom like ${my.property.name}. This will *not* by
itself make this property available to your application.
Am 10.04.2012 14:23 schrieb "mavenbabuk" <[hidden email]>:

>
>        I have tried with externalize property file named as
> *"my-file.properties"*. I configured in pom for externalize as given below,
>
>                        <plugin>
>                                    <groupId>org.codehaus.mojo</groupId>
>
>  <artifactId>properties-maven-plugin</artifactId>
>                                    <version>1.0-alpha-1</version>
>                                    <executions>
>                                        <execution>
>                                            <phase>initialize</phase>
>                                            <goals>
>
>  <goal>read-project-properties</goal>
>                                            </goals>
>                                            <configuration>
>                                                <files>
>
>  <file>*my-file.properties*</file>
>                                                </files>
>                                            </configuration>
>                                        </execution>
>                                    </executions>
>                                </plugin>
>        But, It does not support.
>
>        Please *suggest* me best way to *externalize properties*.
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/replace-parameters-when-overlaying-in-maven-tp5626856p5629742.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

Wayne Fay
In reply to this post by mavenbabuk
>        *Here my complexity* is,
>                When i run install command for child project, this parent war getting
> extracted in my deploy path.
>                But, Still the replacement of the property values change does not occur.

Ryan gave you an answer with a sample plugin configuration. Why didn't
you try it, or tell him why it isn't working for you?

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

mavenbabuk

    I excuse for not properly execute of Ryan sample plugin configuration.
    Now, Once again i tried and i faced the problem as given below,

    While install command executes, First child application deploy with filtering, then parent war getting overlay.
    How to change this order, when install.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

Ron Wheeler
As mentioned earlier, you are probably trying to do something that you
should not.

You might want to look at 2 blog articles that I wrote, with some help
from Stephen Connolly, that gives you a better approach to your problem.

http://blog.artifact-software.com/tech/?p=150

http://blog.artifact-software.com/tech/?p=58

A lot of people use Spring in multiple environments - test, development,
production for different client run-times, etc..
Your approach is not the right way to do it.
- JNDI is.
- There are other tools as well.

I am sure that if you ask in the Springframework forum about the best
way to use Maven to produce Spring WARs targeted at different run-time
environments, you will get a lot of good answers.

The people helping you have the best of intentions but are helping you
to go where you will always be unhappy.
You are trying to make Maven solve a Spring design problem.

Ron


On 10/04/2012 11:15 AM, mavenbabuk wrote:

>      I excuse for not properly execute of Ryan sample plugin configuration.
>      Now, Once again i tried and i faced the problem as given below,
>
>      While install command executes, First child application deploy with
> filtering, then parent war getting overlay.
>      How to change this order, when install.
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/replace-parameters-when-overlaying-in-maven-tp5626856p5630218.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Ron Wheeler
President
Artifact Software Inc
email: [hidden email]
skype: ronaldmwheeler
phone: 866-970-2435, ext 102




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

offbyone
In reply to this post by mavenbabuk
I am not sure I understand the problem exactly.  But one option you could
look at is separating the two tasks.
You could first use the maven dependency plugin to unpack the parent war.

<resources>
            <!--Reference the build directory so we can apply the resource
filtering to it-->
            <resource>
                <directory>${project.build.directory}/</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <!--We bind to generate resources phase so the
resource filtering can be applied to the result -->
                        <phase>generate-resources</phase>
                        <configuration>

<outputDirectory>${project.build.directory}/</outputDirectory>

<includeArtifactIds>parent-war</includeArtifactIds>
                            <excludeTransitive>true</excludeTransitive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Next, you could then assemble a new war using the assembly plugin.

The order at which each step occurs can be dictated by the lifecycle phase
you select for each:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference



On Tue, Apr 10, 2012 at 8:15 AM, mavenbabuk <[hidden email]> wrote:

>
>    I excuse for not properly execute of Ryan sample plugin configuration.
>    Now, Once again i tried and i faced the problem as given below,
>
>    While install command executes, First child application deploy with
> filtering, then parent war getting overlay.
>    How to change this order, when install.
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/replace-parameters-when-overlaying-in-maven-tp5626856p5630218.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need to change parameters of War, when overlay.

mavenbabuk

  Yes, You given correct solution to me.

        Thank you all.
Loading...