What I was attempting to recommend shouldn't cause the war file to become environment dependent, but I may not have understood.

I'm assuming that you have a pom file that is executing tests, and which also produces a war file. In the test environment for the war producing module you need to reference a properties file which is located in the tomcat/lib directory. The creation of the war file and the things that go into it shouldn't include any of the artifacts from the test phase. Your war file should not become environment dependent based on artifacts that you need for testing. If all that you need to do is add the properties file to the classpath of the surefire plugin for the test phase, the example that I pasted in an earlier message ought to work, even without using profiles. If your testing and test environments vary by "development environment" then profiles are a perfectly reasonable way to allow the same pom to satisfy multiple circumstances. If you need the artifact to be available for more than just the test phase, you can use the build-helper-maven-plugin to add artifacts to the classpath.

You can configure the Maven archiver in the config of the maven-war-plugin to control what goes into your war file if for some reason things that you don't want are appearing there.

Here is the surefire plugin example configuration again:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <additionalClasspathElements>
            
<additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
            
<additionalClasspathElement>path/to/additional/jar</additionalClasspathElement>
          </additionalClasspathElements>
        </configuration>
      </plugin>
    </plugins>
  </build>

Again, if I'm getting something wrong, please explain more clearly.


On 8/31/11 11:36 AM, Benjamin Dreux wrote:
In fact my issue is that these property are in the environement when
the war is builded.
But we need this file also when the test are running.
But since the file is environement dependent, i don't want to have
this file staying in the repositry

So i decided to add a copy of this file in the test environement.
But i need to add this file to the classpath for the tests.

And for the moment i can't
Here is the issue.

Since i'm using some profile for each environment, i could add some
task to the profiles.

Any other idea ?

And in a later post you wrote:

I have a properties file that i want to keep in my environnement.
This is because this way the war file is environnement independant.

I put the property file in the tomcat/lib folder.

But when i'm running my tests, i also need the property file, to
define things like db url ...

And i don't want to change the pom because if i do so, the war will be
no more environnement independant

I the hope that now it's more clear what i want to do.


And in a later post you wrote:

I have a properties file that i want to keep in my environnement.
This is because this way the war file is environnement independant.

I put the property file in the tomcat/lib folder.

But when i'm running my tests, i also need the property file, to
define things like db url ...

And i don't want to change the pom because if i do so, the war will be
no more environnement independant

I the hope that now it's more clear what i want to do.



2011/8/31 Andy Glick<andygl...@gmail.com>:
Hi,

I'm sorry to say it, but I believe that you aren't thinking about this from
a "Maven" perspective. Your build is specified in your pom. There is "some
feature" of your build that requires a reference to some artifact outside
the scope of your module. The normal way to resolve this "not recommended
practice" is to modify the pom in some way to handle your "special case".
The build-helper-maven-plugin was written to allow people to solve this
class of problem. It would see particularly appropriate when you only want
to add the external artifact to the classpath for a single phase.

I'm not a Maven developer, but it seems like a stretch to imagine that there
is some way to hack the classpath once from the outside and get the results
that you desire. Maven "manipulates" the classpath across all of the
lifecycle phases. I can't tell you that what you are asking about won't
work, it might, but it just seems counter intuitive.

What is your concern about modifying the pom in question to resolve this
requirement?

On 8/31/11 10:58 AM, Benjamin Dreux wrote:
I'm sorry but i don't want to modify my pom
I just want to change the maven parameters, or a env variable

Is there a way you know to achieve this ??

2011/8/31 Brian Topping<topp...@codehaus.org>:
http://mojo.codehaus.org/build-helper-maven-plugin/add-source-mojo.html
added to the verify phase might be what you are looking for?

If not, there are a lot of other goals in that plugin that have similar
functionality, maybe one of them is better suited.

On Aug 31, 2011, at 10:34 AM, Benjamin Dreux wrote:

Hi
I want to add a folder to the classpath used during the maven build
(verify pase to be precise)
This folder must not be in the project (not inside src or any other
child)
How could i add  something to the classpath used my maven.

I've seen solution using the pom.xml, be since the folder is not in my
source file, i don't want it in my pom neigther.

I suspect it's possible using the command line, maybe something like
-Dclassapth
But i'm not sure

thanks for your help

--
Benjamin Dreux
Analyste-Programmeur
Chaire de logiciel libre-Finance Social et solidaire
UQAM
Montréal

---------------------------------------------------------------------
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




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





Reply via email to