We're using maven 2.2.1 with cargo on REST client & server Java packages, let's call it foo (all the pom goodness will be below). It's got separate foo-client and foo-server projects, and the client's integration test starts up an instance of the foo-server. When using version 1.1.3 of cargo, this works fine, but on 1.1.4 I get the following error when running the cargo:stop goal:
Artifact [com.opower:foo-server:war] is not a dependency of the project.
Can anybody help point me at the cause and a decent solution to this issue? I've found two workarounds for this issue, neither of which feels like an ideal solution:
1. adding a "<version>1.1.3</version>" specifier to cargo's <plugin> block causes the build to work fine
2. removing the cargo:stop goal and letting maven forcefully shut it down also works
I'm a bit of a maven n00b and I hope that I've included enough information to be helpful without writing a novel... if you scroll you'll see the foo-client pom, the maven output (v1.1.4), the maven output using version 1.1.3 with no failure, and finally the foo-server pom.
-Tyler
The project is set up with a parent pom.xml and the following child projects:
foo/
foo-parent/
foo-server/
foo-client/
foo-client's pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.opower</groupId>
<artifactId>foo-parent</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../foo-parent</relativePath>
</parent>
<artifactId>foo-client</artifactId>
<packaging>jar</packaging>
<version>1.6.0-SNAPSHOT</version>
<name>Foo Service Client</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>foo-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.opower</groupId>
<artifactId>foo-server</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>jetty6x</containerId>
<type>embedded</type>
</container>
<configuration>
<deployables>
<deployable>
<properties>
<context>/</context>
</properties>
<groupId>com.opower</groupId>
<artifactId>foo-server</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
<wait>false</wait>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Console output from running a build:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Foo Service Client
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /opt/git/shared/foo/foo-client/target
[INFO] [svn-revision-number:revision {execution: default}]
[INFO] inspecting /opt/git/shared/foo/foo-client
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/version
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/patches
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/postpatches
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/ami_schema
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 7 source files to /opt/git/shared/foo/foo-client/target/classes
[INFO] [checkstyle:checkstyle {execution: checkstyle}]
[INFO] Starting audit...
Audit done.
[INFO] [scala:compile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,]
[INFO] excludes = []
[WARNING] No source files found.
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 19 resources
[INFO] Copying 1 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 2 source files to /opt/git/shared/foo/foo-client/target/test-classes
[INFO] [scala:testCompile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,]
[INFO] excludes = []
[WARNING] No source files found.
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: /opt/git/shared/foo/foo-client/target/surefire-reports
<unit tests omitted>
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT.jar
[INFO] Preparing source:jar
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation.
[INFO] [svn-revision-number:revision {execution: default}]
[INFO] inspecting /opt/git/shared/foo/foo-client
[WARNING] the "artifact.svn.info.repository" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.path" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.revision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.mixedRevisions" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.committedRevision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.committedDate" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.status" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.specialStatus" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[INFO] [source:jar {execution: attach-sources}]
[INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT-sources.jar
[INFO] [cargo:start {execution: start-container}]
[INFO] [beddedLocalContainer] Jetty 6.x Embedded starting...
<server startup and test output lines omitted>
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
[INFO] [cargo:stop {execution: stop-container}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Artifact [com.foo-server:war] is not a dependency of the project.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19 seconds
[INFO] Finished at: Mon Dec 19 17:02:13 EST 2011
[INFO] Final Memory: 76M/145M
[INFO] ------------------------------------------------------------------------
2011-12-19 17:02:13.583:INFO::Shutdown hook executing
2011-12-19 17:02:13.590:INFO:/:Closing Spring root WebApplicationContext
2011-12-19 17:02:13,590 INFO [Shutdown] [] [r.spring.WebApplicationContext] Closing Root WebApplicationContext: startup date [Mon Dec 19 17:02:09 EST 2011]; root of context hierarchy
2011-12-19 17:02:13,590 DEBUG [Shutdown] [] [r.spring.WebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.context.event.ContextClosedEvent[source=Root WebApplicationContext: startup date [Mon Dec 19 17:02:09 EST 2011]; root of context hierarchy]
2011-12-19 17:02:13.608:INFO:/:Shutting down log4j
log4j: [/private/var/folders/5g/_jfmsv892jl_3dcx3rvsy9xc0000gp/T/foo.server.1.6.0.SNAPSHOT.war____.gqkpbp/webapp/WEB-INF/classes/config/log4j.properties] does not exist.
2011-12-19 17:02:13.742:INFO::Shutdown hook complete
By specifying the 1.1.3 version of the cargo plugin, the same build cycle succeeds as shown here:
$ mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Foo Service Client
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] Unable to find resource 'org.codehaus.cargo:cargo-maven2-plugin:pom:1.1.3' in repository opower_releases (scp://
mvn.opower.com/opt/releases)
[INFO] Unable to find resource 'org.codehaus.cargo:cargo-maven2-plugin:maven-plugin:1.1.3' in repository opower_releases (scp://
mvn.opower.com/opt/releases)
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /opt/git/shared/foo/foo-client/target
[INFO] [svn-revision-number:revision {execution: default}]
[INFO] inspecting /opt/git/shared/foo/foo-client
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/version
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/patches
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/postpatches
[INFO] skip non existing resourceDirectory /opt/git/shared/foo/foo-client/db/ami_schema
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 7 source files to /opt/git/shared/foo/foo-client/target/classes
[INFO] [checkstyle:checkstyle {execution: checkstyle}]
[INFO] Starting audit...
Audit done.
[INFO] [scala:compile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,]
[INFO] excludes = []
[WARNING] No source files found.
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 19 resources
[INFO] Copying 1 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 2 source files to /opt/git/shared/foo/foo-client/target/test-classes
[INFO] [scala:testCompile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,]
[INFO] excludes = []
[WARNING] No source files found.
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: /opt/git/shared/foo/foo-client/target/surefire-reports
<tests omitted>
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT.jar
[INFO] Preparing source:jar
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation.
[INFO] [svn-revision-number:revision {execution: default}]
[INFO] inspecting /opt/git/shared/foo/foo-client
[WARNING] the "artifact.svn.info.repository" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.path" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.revision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.mixedRevisions" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.committedRevision" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.committedDate" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.status" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[WARNING] the "artifact.svn.info.specialStatus" property is already defined, its value will be overwritten. Consider another value for the entry properties prefix.
[INFO] [source:jar {execution: attach-sources}]
[INFO] Building jar: /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT-sources.jar
[INFO] [cargo:start {execution: start-container}]
[INFO] [beddedLocalContainer] Jetty 6.x Embedded starting...
<server startup and integration tests omitted>
[INFO] [cargo:stop {execution: stop-container}]
[INFO] [beddedLocalContainer] Jetty 6.x Embedded is stopping...
2011-12-19 17:16:24.652:INFO:/:Closing Spring root WebApplicationContext
2011-12-19 17:16:24,652 INFO [Thread-22] [] [r.spring.WebApplicationContext] Closing Root WebApplicationContext: startup date [Mon Dec 19 17:16:20 EST 2011]; root of context hierarchy
2011-12-19 17:16:24,653 DEBUG [Thread-22] [] [r.spring.WebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.context.event.ContextClosedEvent[source=Root WebApplicationContext: startup date [Mon Dec 19 17:16:20 EST 2011]; root of context hierarchy]
2011-12-19 17:16:24.671:INFO:/:Shutting down log4j
log4j: [/private/var/folders/5g/_jfmsv892jl_3dcx3rvsy9xc0000gp/T/Jetty_0_0_0_0_8080_foo.server.1.6.0.SNAPSHOT.war____.gqkpbp/webapp/WEB-INF/classes/config/log4j.properties] does not exist.
[INFO] [beddedLocalContainer] Jetty 6.x Embedded is stopped
[INFO] [install:install {execution: default-install}]
[INFO] Installing /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT.jar to /opt/.m2repository/com/opower/foo-client/1.6.0-SNAPSHOT/foo-client-1.6.0-SNAPSHOT.jar
[INFO] Installing /opt/git/shared/foo/foo-client/target/foo-client-1.6.0-SNAPSHOT-sources.jar to /opt/.m2repository/com/opower/foo-client/1.6.0-SNAPSHOT/foo-client-1.6.0-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29 seconds
[INFO] Finished at: Mon Dec 19 17:16:31 EST 2011
[INFO] Final Memory: 73M/142M
[INFO] ------------------------------------------------------------------------
2011-12-19 17:16:32.057:INFO::Shutdown hook executing
2011-12-19 17:16:32.057:INFO::Shutdown hook complete
And as a final postscript, the foo-server POM:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.opower</groupId>
<artifactId>foo-parent</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../foo-parent</relativePath>
</parent>
<artifactId>foo-server</artifactId>
<packaging>war</packaging>
<name>Foo Server</name>
<version>1.6.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>foo-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.22</version>
</plugin>
</plugins>
</build>
</project>