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/include-exclude.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 <
[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to