You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jacek Laskowski <ja...@laskowski.net.pl> on 2007/04/05 15:52:14 UTC

How to pass M2 properties to surefire plugin's argLine

Hi,

I wonder how people work out the issue with passing properties to
surefire plugin's argLine attribute? I'd like to execute tests with
Cayenne's java agent and don't know how to point it out to the
artifact in the m2 local repo.

I'd like to run m2-ized project with the following in its pom.xml:

  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <forkMode>once</forkMode>
      <argLine>-javaagent:${maven.repo.local}/org/apache/cayenne/cayenne-agent/3.0-SNAPSHOT/cayenne-agent-3.0-SNAPSHOT.jar</argLine>
    </configuration>
  </plugin>

maven.repo.local property's not resolved. How can I achieve that it is.

Any help appreciated.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

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


RE: How to pass M2 properties to surefire plugin's argLine

Posted by David Jackman <Da...@fastsearch.com>.
The short answer: it didn't work.  Surefire doesn't consider any of the
dependencies when it starts the JVM to run the tests--it figures it will
be applying those dependencies to the custom classloader it uses when it
loads the test classes later on.  There aren't any configuration
properties in surefire to add to the JVM classpath.

We went a step further to work around this issue by putting all the
classes from the dependent jars into the agent jar (so the agent jar is
the only one that's necessary).  That allowed the agent to load, but
when the tests were run the agent wasn't there any more.  I haven't gone
into the surefire code to figure out why that would be.

In our case, having the agent in place to run the tests wasn't
essential, so we've given up on the whole thing.  We'll just stick to
the tests that don't need the agent.

If you're able to get surefire to run correctly with an agent (which, I
believe, will require some enhancements to surefire), I'll be
interested.

..David..
 

-----Original Message-----
From: eljotpl@gmail.com [mailto:eljotpl@gmail.com] On Behalf Of Jacek
Laskowski
Sent: Thursday, April 05, 2007 9:00 AM
To: users@maven.apache.org
Subject: Re: How to pass M2 properties to surefire plugin's argLine

On 4/5/07, David Jackman <Da...@fastsearch.com> wrote:
> I'm trying to do almost exactly the same thing (different agent jar, 
> though).  Rather than trying to have the agent point to the repo, I 
> used the dependency plugin to copy the jar from the repository to a 
> location under the build directory, then reference it there.

That's the idea! Thanks for sharing it...so lightning fast.

> That much is working okay.  What isn't working now is the fact that my

> java agent has dependencies of its own that aren't in the surefire 
> classpath.  Wayne gave me something to try to get around this problem.

Why doesn't declaring a dependency on the agent work? The deps should be
managed by m2 and should be passed to surefire-plugin and be on the
classpath.

> I'll keep you posted on whether I'm able to get it all working.  
> Please do the same for me if you're able to get it working on your
end.

Definitely. Thanks again for the tip.

Jacek

--
Jacek Laskowski
http://www.JacekLaskowski.pl

---------------------------------------------------------------------
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: How to pass M2 properties to surefire plugin's argLine

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/5/07, David Jackman <Da...@fastsearch.com> wrote:
> I'm trying to do almost exactly the same thing (different agent jar,
> though).  Rather than trying to have the agent point to the repo, I used
> the dependency plugin to copy the jar from the repository to a location
> under the build directory, then reference it there.

That's the idea! Thanks for sharing it...so lightning fast.

> That much is working okay.  What isn't working now is the fact that my
> java agent has dependencies of its own that aren't in the surefire
> classpath.  Wayne gave me something to try to get around this problem.

Why doesn't declaring a dependency on the agent work? The deps should
be managed by m2 and should be passed to surefire-plugin and be on the
classpath.

> I'll keep you posted on whether I'm able to get it all working.  Please
> do the same for me if you're able to get it working on your end.

Definitely. Thanks again for the tip.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

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


Re: How to pass M2 properties to surefire plugin's argLine

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/5/07, David Jackman <Da...@fastsearch.com> wrote:

> That much is working okay.  What isn't working now is the fact that my
> java agent has dependencies of its own that aren't in the surefire
> classpath.  Wayne gave me something to try to get around this problem.

Hi David,

I could run the Cayenne java agent with your help successfully (it's
not the result I'd expected, but it's closer than I'd been before your
advice).

I double-checked the deps of the agent *were* in the classpath. When I
removed the deps and left only the agent the test failed due to
missing classes. Once the deps were in again, it worked better. So, I
can't understand why it doesn't work for you.

Here's the cayenne profile configuration. It runs with M2 2.0.6 much,
much better now. Thanks for the advice.

    <profile>
      <id>cayenne</id>
      <dependencies>
        <dependency>
          <groupId>org.apache.cayenne</groupId>
          <artifactId>cayenne-agent</artifactId>
          <version>3.0-SNAPSHOT</version>
        </dependency>
        <dependency>
          <groupId>javax.persistence</groupId>
          <artifactId>persistence-api</artifactId>
          <version>1.0</version>
        </dependency>
        <dependency>
          <groupId>org.apache.cayenne</groupId>
          <artifactId>cayenne-server</artifactId>
          <version>3.0-SNAPSHOT</version>
        </dependency>
        <dependency>
          <groupId>org.apache.cayenne</groupId>
          <artifactId>cayenne-client</artifactId>
          <version>3.0-SNAPSHOT</version>
        </dependency>
        <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.1</version>
        </dependency>
        <dependency>
          <groupId>commons-collections</groupId>
          <artifactId>commons-collections</artifactId>
          <version>3.2</version>
        </dependency>
        <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.14</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.apache.cayenne</groupId>
                      <artifactId>cayenne-agent</artifactId>
                      <version>3.0-SNAPSHOT</version>
                      <type>jar</type>
                      <overWrite>true</overWrite>

<outputDirectory>${project.build.directory}</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <forkMode>once</forkMode>
              <argLine>-javaagent:${project.build.directory}/cayenne-agent-3.0-SNAPSHOT.jar</argLine>
            </configuration>
          </plugin>
        </plugins>
        <resources>
          <resource>
            <directory>src/main/resources/cayenne</directory>
          </resource>
        </resources>
      </build>
      <repositories>
        <repository>
          <id>apache-snapshots</id>
          <name>Apache Snapshots Repository</name>
          <url>http://people.apache.org/maven-snapshot-repository</url>
          <layout>default</layout>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
          </snapshots>
          <releases>
            <enabled>false</enabled>
          </releases>
        </repository>
      </repositories>
    </profile>

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

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


RE: How to pass M2 properties to surefire plugin's argLine

Posted by David Jackman <Da...@fastsearch.com>.
I'm trying to do almost exactly the same thing (different agent jar,
though).  Rather than trying to have the agent point to the repo, I used
the dependency plugin to copy the jar from the repository to a location
under the build directory, then reference it there. 

That much is working okay.  What isn't working now is the fact that my
java agent has dependencies of its own that aren't in the surefire
classpath.  Wayne gave me something to try to get around this problem.

I'll keep you posted on whether I'm able to get it all working.  Please
do the same for me if you're able to get it working on your end.  

..David..


-----Original Message-----
From: eljotpl@gmail.com [mailto:eljotpl@gmail.com] On Behalf Of Jacek
Laskowski
Sent: Thursday, April 05, 2007 7:52 AM
To: users@maven.apache.org
Subject: How to pass M2 properties to surefire plugin's argLine

Hi,

I wonder how people work out the issue with passing properties to
surefire plugin's argLine attribute? I'd like to execute tests with
Cayenne's java agent and don't know how to point it out to the artifact
in the m2 local repo.

I'd like to run m2-ized project with the following in its pom.xml:

  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <forkMode>once</forkMode>
 
<argLine>-javaagent:${maven.repo.local}/org/apache/cayenne/cayenne-agent
/3.0-SNAPSHOT/cayenne-agent-3.0-SNAPSHOT.jar</argLine>
    </configuration>
  </plugin>

maven.repo.local property's not resolved. How can I achieve that it is.

Any help appreciated.

Jacek

--
Jacek Laskowski
http://www.JacekLaskowski.pl

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