You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Vaidya, Supriya A (US - Chicago)" <su...@deloitte.com> on 2007/06/28 23:49:05 UTC

URGENT: Renaming files during compile time

Hi:
 
Here is what needs to be achieved:
 
I have 3 different configuration files: application-dev.properties,
application-int.properties, application-prod.properties. Depending on
the value taken by a certain variable (where and how do shoudl I define
this variable??), I need to have one of the above files copied to a
certain directory, and renamed.
 
How do I achieve this with Maven?
 
I have tried using the maven-dependency-plugin, but am not sure how to
define the artifacts...
 
  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                  <artifactItem>
                     <groupId>my-application</groupId>     
                    <artifactId>application-prod.xml</artifactId>
                     <type>file</type>
                     <overWrite>false</overWrite>
 
<outputDirectory>${project.build.directory}</outputDirectory>
                     <destFileName>application.xml</destFileName>
                   </artifactItem>
                 </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin> 


This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law.  If you are not the intended recipient, you should delete this message. 


Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. [v.E.1]

Re: URGENT: Renaming files during compile time

Posted by Steven Rowe <sa...@syr.edu>.
How about maven-antrun-plugin, using the Ant <copy> task?

About the variable naming, it depends on where the information comes
from - can it be set on the cmdline?  Is it available as an environment
variable?

Profiles are a standard Maven mechanism to get the build to respond
differently to different conditions:

http://maven.apache.org/guides/introduction/introduction-to-profiles.html

Steve

Vaidya, Supriya A (US - Chicago) wrote:
> Hi:
>  
> Here is what needs to be achieved:
>  
> I have 3 different configuration files: application-dev.properties,
> application-int.properties, application-prod.properties. Depending on
> the value taken by a certain variable (where and how do shoudl I define
> this variable??), I need to have one of the above files copied to a
> certain directory, and renamed.
>  
> How do I achieve this with Maven?
>  
> I have tried using the maven-dependency-plugin, but am not sure how to
> define the artifacts...
>  
>   <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-dependency-plugin</artifactId>
>         <executions>
>           <execution>
>             <id>copy</id>
>             <phase>package</phase>
>             <goals>
>               <goal>copy</goal>
>             </goals>
>             <configuration>
>                 <artifactItems>
>                   <artifactItem>
>                      <groupId>my-application</groupId>     
>                     <artifactId>application-prod.xml</artifactId>
>                      <type>file</type>
>                      <overWrite>false</overWrite>
>  
> <outputDirectory>${project.build.directory}</outputDirectory>
>                      <destFileName>application.xml</destFileName>
>                    </artifactItem>
>                  </artifactItems>
>             </configuration>
>           </execution>
>         </executions>
>       </plugin> 
> 
> 
> This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law.  If you are not the intended recipient, you should delete this message. 
> 
> 
> Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. [v.E.1]
> 


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


Re: URGENT: Renaming files during compile time

Posted by Wayne Fay <wa...@gmail.com>.
As others have mentioned, profiles are the proper way to proceed with
this requirement. This same thing was just discussed in the last day
or two, so check the archives or Nabble.com and you're bound to find
more examples and discussion on this topic.

About the "URGENT" in your subject -- I'd leave that out of future
emails. Every question on this list is urgent to the person who needs
the help. If anything, I actually go a little out of my way to IGNORE
these emails. Just FYI...

Wayne

On 6/28/07, Terala, Satish (IS Consultant) <ST...@consultantemail.com> wrote:
> You should do this using profiles.
> Typically you would define a profile for each environment
>        <profile>
>            <id>dev</id>
>            <activation>
>                <property>
>                    <name>target-env</name>
>                    <value>dev</value>
>                </property>
>            </activation>
>            <properties>
> <resource.filter.file>src/main/filters/dev.filter.properties</resource.f
> ilter.file>
>            </properties>
>  </profile>
>
> Depending on the env you want to build for dev/prod/stage , you can pass
> in the appropriate value with -Dtarget-env=<env.name> when running a
> maven goal.
>
> I am not sure if you have a plugin that will rename the files (you can
> definitely use a ant task to do that), instead the way its recommended
> is by using  a filter file instead.
>
> Have the application.xml define variables for property values you want
> to change, and replace those with values from the appropriate
> environment filters file.
>
> -Satish
>
>
>
> -----Original Message-----
> From: Vaidya, Supriya A (US - Chicago)
> [mailto:supriyavaidya@deloitte.com]
> Sent: Thursday, June 28, 2007 5:49 PM
> To: users@maven.apache.org
> Subject: URGENT: Renaming files during compile time
>
> Hi:
>
> Here is what needs to be achieved:
>
> I have 3 different configuration files: application-dev.properties,
> application-int.properties, application-prod.properties. Depending on
> the value taken by a certain variable (where and how do shoudl I define
> this variable??), I need to have one of the above files copied to a
> certain directory, and renamed.
>
> How do I achieve this with Maven?
>
> I have tried using the maven-dependency-plugin, but am not sure how to
> define the artifacts...
>
>  <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-dependency-plugin</artifactId>
>        <executions>
>          <execution>
>            <id>copy</id>
>            <phase>package</phase>
>            <goals>
>              <goal>copy</goal>
>            </goals>
>            <configuration>
>                <artifactItems>
>                  <artifactItem>
>                     <groupId>my-application</groupId>
>                    <artifactId>application-prod.xml</artifactId>
>                     <type>file</type>
>                     <overWrite>false</overWrite>
>
> <outputDirectory>${project.build.directory}</outputDirectory>
>                     <destFileName>application.xml</destFileName>
>                   </artifactItem>
>                 </artifactItems>
>            </configuration>
>          </execution>
>        </executions>
>      </plugin>
>
>
> This message (including any attachments) contains confidential
> information intended for a specific individual and purpose, and is
> protected by law.  If you are not the intended recipient, you should
> delete this message.
>
>
> Any disclosure, copying, or distribution of this message, or the taking
> of any action based on it, is strictly prohibited. [v.E.1]
>
> ---------------------------------------------------------------------
> 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: URGENT: Renaming files during compile time

Posted by "Terala, Satish (IS Consultant)" <ST...@consultantemail.com>.
You should do this using profiles.
Typically you would define a profile for each environment 
        <profile>
            <id>dev</id>
            <activation>
                <property>
                    <name>target-env</name>
                    <value>dev</value>
                </property>
            </activation>
            <properties>
<resource.filter.file>src/main/filters/dev.filter.properties</resource.f
ilter.file>
            </properties>
  </profile>

Depending on the env you want to build for dev/prod/stage , you can pass
in the appropriate value with -Dtarget-env=<env.name> when running a
maven goal.

I am not sure if you have a plugin that will rename the files (you can
definitely use a ant task to do that), instead the way its recommended
is by using  a filter file instead. 

Have the application.xml define variables for property values you want
to change, and replace those with values from the appropriate
environment filters file.

-Satish



-----Original Message-----
From: Vaidya, Supriya A (US - Chicago)
[mailto:supriyavaidya@deloitte.com] 
Sent: Thursday, June 28, 2007 5:49 PM
To: users@maven.apache.org
Subject: URGENT: Renaming files during compile time

Hi:
 
Here is what needs to be achieved:
 
I have 3 different configuration files: application-dev.properties,
application-int.properties, application-prod.properties. Depending on
the value taken by a certain variable (where and how do shoudl I define
this variable??), I need to have one of the above files copied to a
certain directory, and renamed.
 
How do I achieve this with Maven?
 
I have tried using the maven-dependency-plugin, but am not sure how to
define the artifacts...
 
  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                  <artifactItem>
                     <groupId>my-application</groupId>     
                    <artifactId>application-prod.xml</artifactId>
                     <type>file</type>
                     <overWrite>false</overWrite>
 
<outputDirectory>${project.build.directory}</outputDirectory>
                     <destFileName>application.xml</destFileName>
                   </artifactItem>
                 </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin> 


This message (including any attachments) contains confidential
information intended for a specific individual and purpose, and is
protected by law.  If you are not the intended recipient, you should
delete this message. 


Any disclosure, copying, or distribution of this message, or the taking
of any action based on it, is strictly prohibited. [v.E.1]

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