flybyray / maven-play-plugin

Automatically exported from code.google.com/p/maven-play-plugin
0 stars 0 forks source link

allow play testing to use environment variables when server is started up e.g. -DrunEnv=local #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I've tried setting the runEnv variable in the maven-surfire plugin in my 
maven pom.xml hoping that it gets used when selenium testing is performed.
      <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                    <environmentVariables>
                        <runEnv>local</runEnv>
                    </environmentVariables>
            <systemProperties>
               <argLine>-DrunEnv=local</argLine>
            </systemProperties>
                </configuration>
            </plugin>

2. my play application.conf contains this

@include.config=app-config-${runEnv}.conf

3. when i type the command mvn clean verify site
the runEnv is not passed through.

What is the expected output? What do you see instead?
same behaviour as running the command
play test -DrunEnv=local or play run -DrunEnv=local

the maven-play-plugin does not use the environment variable set in the maven 
scripts.

What version of the product are you using? On what operating system?

 <parent>
        <groupId>com.google.code.maven-play-plugin</groupId>
        <artifactId>play-app-default-parent</artifactId>
        <version>1.0.0-beta2-SNAPSHOT</version>
    </parent>

Please provide any additional information below.

Original issue reported on code.google.com by share.re...@gmail.com on 19 May 2012 at 10:00

GoogleCodeExporter commented 9 years ago
Hi

Two side notes first:
1.
In your case "runEnv" is not an environment variable. Environment variable are 
for example "PATH" or "JAVA_HOME". "runEnv" is a system property.
2.
Surefire is used for unit and functional tests. For Selenium tests you have to 
configure Failsafe plugin.

Arguments passed to Play! server starting commands (including starting Play! 
for Selenium tests) are not supported yet.
I will implement it.

When running unit and functional tests with Surefire, Play! server is not being 
started, only core Play engine (Play.java class) is initialized. Passing system 
property should work, but you should configure it like this:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <systemProperties>
      <property>
        <name>runEnv</name>
        <value>local</value>
      </property>
    </systemProperties>
  </configuration>
</plugin>

or better:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <systemPropertyVariables>
      <runEnv>local</runEnv>
    </systemPropertyVariables>
  </configuration>
</plugin>

because <systemProperties> parameter is deprecated. Read more here:
http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties
.html

Original comment by gslowiko...@gmail.com on 21 May 2012 at 1:03

GoogleCodeExporter commented 9 years ago
svn rev.9285 - added "serverJvmArgs" configuration property used in: "run", 
"test", "start", "start-server" and "precompile" (only if "precompileFork" = 
true) mojos.

Original comment by gslowiko...@gmail.com on 22 May 2012 at 12:58

GoogleCodeExporter commented 9 years ago
svn rev.9286 - in "precompile" and Play! server starting mojos WITHOUT forking 
system properties are extracted from "serverJvmArgs" configuration parameter 
and passed to Ant task.

Original comment by gslowiko...@gmail.com on 22 May 2012 at 12:58

GoogleCodeExporter commented 9 years ago
Functionality implemented, snapshot deployed.

You should add plugin configuration:

<plugin>
    <groupId>com.google.code.maven-play-plugin</groupId>
    <artifactId>play-maven-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <serverJvmArgs>-DrunEnv=local</serverJvmArgs>
    </configuration>
</plugin>

or specify it in Maven invocation, for example:

mvn play:start -Dplay.serverJvmArgs="-DrunEnv=local"

It works for: "run", "test", "start" and "precompile" mojos.

Original comment by gslowiko...@gmail.com on 22 May 2012 at 1:17

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for fixing this, i will try it out soon.

Original comment by share.re...@gmail.com on 24 May 2012 at 11:10

GoogleCodeExporter commented 9 years ago
Hi Grzegorz Słowikowski

Will you be creating a new snapshot version so that i can try this fix, i
noticed that the lastest snapshot build is still
1.0.0-beta2-SNAPSHOT/<http://maven-play-plugin.googlecode.com/svn/mavenrepo/snap
shots/com/google/code/maven-play-plugin/maven-parent/1.0.0-beta2-SNAPSHOT/>

Original comment by share.re...@gmail.com on 25 May 2012 at 12:45

GoogleCodeExporter commented 9 years ago
New snapshot has been created, you don't have to change anything, your local 
version will be upgraded, this it the way snapshots work in Maven.

Look here: 
https://maven-play-plugin.googlecode.com/svn/mavenrepo/snapshots/com/google/code
/maven-play-plugin/play-maven-plugin/1.0.0-beta2-SNAPSHOT/
There are many versions of 1.0.0-beta2-SNAPSHOT, and Maven is responsible for 
downloading the most recent for you.

Original comment by gslowiko...@gmail.com on 25 May 2012 at 7:51

GoogleCodeExporter commented 9 years ago
Hi Grzegorz,

That worked well, thank you for fixing it so fast. You must spend a lot of
time of this project especially since you are doing it all in your spare
time.
Let me know when the play PDF module is ready i would be have happy to use
it, i wish i knew what was involved in mavenizing this project and i would
help you out.

Original comment by share.re...@gmail.com on 26 May 2012 at 12:40