Great solution!!! Thanks both

I someone has the same issue, visit:

http://www.manydesigns.com/documentation/tutorials/using-maven-profiles-and-
resource-filtering.html



-----Mensaje original-----
De: hermod.opstv...@dnbnor.no [mailto:hermod.opstv...@dnbnor.no] 
Enviado el: viernes, 13 de noviembre de 2009 10:15
Para: users@maven.apache.org
Asunto: RE: Doubt about packaging using profiles

Hi

This is easly solved using filters and profiles. Define your environment
specific variables in your filter and subsitute that into your log4j
file. I do this all the time, because the disk drive and path to the
log4j files are different from test to productio.

Hermod 
-----Original Message-----
From: anders.g.ham...@gmail.com [mailto:anders.g.ham...@gmail.com] On
Behalf Of Anders Hammar
Sent: Friday, November 13, 2009 10:04 AM
To: Maven Users List
Subject: Re: Doubt about packaging using profiles

Environment specific files should be read from the class path. Then keep
them out of your bundle (ear for instance) and add them to the
environment (app server for instance) in such a way that they end up on
the classpath.

/Anders

On Fri, Nov 13, 2009 at 09:40, Exposito Aguilera, Francisco <
francisco.expos...@es.issworld.com> wrote:

> If I create only one build, how can I select the prod or test file? 
> (only inside the build I can do the include/exclude file option). 
> Then, I need two builds, one for selecting prod file and one for test 
> (one for profile)
>
> Could you add an example of how to do what you say?
>
> /Paco
>
>
>
> -----Mensaje original-----
> De: anders.g.ham...@gmail.com [mailto:anders.g.ham...@gmail.com] En 
> nombre de Anders Hammar Enviado el: viernes, 13 de noviembre de 2009 
> 8:31
> Para: Maven Users List
> Asunto: Re: Doubt about packaging using profiles
>
> First, having different builds for different environments are 
> generally a bad idea. That's, IMHO, a general Java rule so I won't go 
> into that any further but I wanted to mention that.
>
> The, I think you should solve your issue by configuring the resources 
> plugin in to only include the right log4j files. I would set up my pom

> so that the prod file is being used. And then create a profile for 
> development use where the dev log4j file is being used instead.
>
> Regarding deleting the already existing files in the output folder, 
> one could argue that that should be taken care of by executing "mvn
clean".
>
> Here's how you configure the resources plugin to include/exclude:
>
> http://maven.apache.org/plugins/maven-resources-plugin/examples/includ
> e-excl 
> ude.html<http://maven.apache.org/plugins/maven-resources-plugin/exampl
> es/include-excl%0Aude.html>
>
> What's going on in your current case is that the resources plugin will

> copy all log4j files. The resources plugin is bound to the lifecycle 
> by default (for a jar project for instance). That's why you see all 
> log4j (actually all files in the resources folder) end up in the 
> output directory.
>
> /Anders
>
> On Fri, Nov 13, 2009 at 08:04, Exposito Aguilera, Francisco < 
> francisco.expos...@es.issworld.com> wrote:
>
> > My pom.xml file has two profiles which must delete and copy files in

> > a place. If I want the war for production, I need the log4j_prod.xml

> > and if
> I
> > want the war for test I need the log4j.xml file. I show the test
profile:
> >
> > <profiles>
> > <profile>
> >  <id>test</id>
> >  <build>
> >  <resources>
> >  </resources>
> >  <filters>
> >  </filters>
> >  <plugins>
> >  <plugin>
> >  <artifactId>maven-antrun-plugin</artifactId>
> >  <executions>
> >   <execution>
> >   <phase>test</phase>
> >   <goals>
> >    <goal>run</goal>
> >   </goals>
> >   <configuration>
> >    <tasks>
> >     <delete file="${project.build.outputDirectory}/log4j.xml" />
> >     <delete file="${project.build.outputDirectory}/log4j_prod.xml"
/>
> >     <copy file="src/main/resources/log4j.xml"
> >             tofile="${project.build.outputDirectory}/log4j.xml" />
> >    </tasks>
> >   </configuration>
> >  </execution>
> >  </executions>
> > </plugin>
> > <plugin>
> >  <artifactId>maven-surefire-plugin</artifactId>
> >  <configuration>
> >  <skip>true</skip>
> >  </configuration>
> > </plugin>
> > <plugin>
> >  <artifactId>maven-war-plugin</artifactId>
> >  <executions>
> >  <execution>
> >   <phase>package</phase>
> >   <goals>
> >    <goal>war</goal>
> >   </goals>
> >   <configuration>
> >    <classifier>test</classifier>
> >   </configuration>
> >  </execution>
> >  </executions>
> > </plugin>
> > </plugins>
> > </build>
> > </profile>
> > </profiles>
> >
> > Then I go to Run as --> Run configurations and I create a new Maven 
> > build with these options:
> >
> > Base directory: I select the project root
> > Goals: package
> > Profiles: test
> >
> > And when I execute, in target classes the file tasks are done, but 
> > inside the war file both log4j xml files are copied.
> >
> > Any help, please?
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence
with
customers as a part of an email. 

This email message has been virus checked by the anti virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


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

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

Reply via email to