views:

119

answers:

1

Edit 4: For the answer to this question see the final comments of the correct answer.


Hi!

I have the following dependency specified in my project's pom:

 <dependency>
  <groupId>org.jboss.client</groupId>
  <artifactId>jbossall-client</artifactId>
  <scope>compile</scope>
 </dependency>

My project itself has to be the child of another pom. And in that one, the following is defined:

<dependency>
   <groupId>org.jboss.client</groupId>
   <artifactId>jbossall-client</artifactId>
   <version>4.2.3.GA</version>
   <scope>provided</scope>
   <type>jar</type>
</dependency>

When I now assembly my program, it seems that the "provided" scope of the parent pom overrides the scope of my project, since the jbossall-client-jar is not included in my assembly. Although it seems illogical to me, maybe it's this feature taking effect here.

Do you know a way to include the dependency in my assembly without touching the parent pom?


Edit: Output of mvn dependency-tree (Updated!):

[dependency:tree]
at.myproject:myproject:jar:0.0.1-SNAPSHOT
+- at.myproject-commons:jar:1.0-SNAPSHOT:compile
|  +- commons-logging:commons-logging:jar:1.0.4:compile
|  +- log4j:log4j:jar:1.2.14:compile
|  +- sv.seucc:seucc-unicode:jar:1.0.1.5:compile
|  +- commons-lang:commons-lang:jar:2.2:compile
|  +- com.thoughtworks.xstream:xstream:jar:1.2.1:compile
|  \- xpp3:xpp3_min:jar:1.1.3.4.O:compile
+- at.myproject-interfaces2:jar:1.0-SNAPSHOT:compile
|  \- at.myproject-service-commons:jar:1.0-SNAPSHOT:compile
+- org.springframework:spring:jar:2.5.6:compile
+- commons-io:commons-io:jar:1.3.1:compile
+- at.myproject-modules:ejb:1.0-SNAPSHOT:compile
\- org.jboss.client:jbossall-client:jar:4.2.3.GA:compile

Edit 2: Here the dependency part of my assembly xml.

 <dependencySets>
  <dependencySet>
   <outputDirectory>lib</outputDirectory>
  </dependencySet>
 </dependencySets>

Edit 3: Here are the files in the lib folder of my obtained assembly.

commons-io-1.3.1.jar
commons-lang-2.2.jar
commons-logging-1.0.4.jar
log4j-1.2.14.jar
seucc-unicode-1.0.1.5.jar
spring-2.5.6.jar
xpp3_min-1.1.3.4.O.jar
xstream-1.2.1.jar
myproject-commons-1.0-SNAPSHOT.jar
myproject-modules-1.0-SNAPSHOT.jar
myproject-service-commons-1.0-SNAPSHOT.jar
myproject-interfaces2-1.0-SNAPSHOT.jar
myproject-0.0.1-SNAPSHOT.jar
+2  A: 

Both dependencies don't have the same groupId so nothing get overridden here, they are treated as distinct artifacts. But I wonder how things work in your child pom (since the jbossall-client doesn't have any version). Do you have a dependencyManagement section?

Anyway, to "debug" this kind of problem, use mvn dependency:tree in your child project (and post the output if you need more help).


Update: The above was my answer to the initial question and does not reflect the current state of the question.

For the sake of clarity, the key of the final solution was to declare a <scope>compile</scope> (which defaults to runtime) in the dependencySet element of the assembly descriptor. See the comments for all details.

See also

Pascal Thivent
When I remove the `<scope>` tag from the jbossall-client in my child pom and then check in Eclipse -> Dependency Hierachy, the jbossall-client's scope is marked as `provided`. Therefore I assumed that it inherits the `<scope>` value from it's parent.I haven't found any `dependencyManagement` section in one of the poms. Where else could I look for?I've appended the output of `mvn dependency:tree` to my original post. See above please.
Bernhard V
@BernhardV: You're very likely inheriting it, but not from where where you think you are. As I said, the dependencies you're showing don't have the same `groupId` and as you can see, you get version 4.2.3, not 4.2.2. Anyway, the dependency tree looks fine and the jbossall-client is there with a compile scope. There must be something else wrong somewhere. Can you show the content of your assembly descriptor and the content of the obtained assembly? Actually, a simplified pom allowing to reproduce would be nice.
Pascal Thivent
I've found out from where I inherit the jbossall-client.jar. In my Eclipse workspace I've checked out an older version of the parent pom than it was specified in the child pom. I've corrected my first post and now the groupId is the same. I had to specify the version too. The strange thing is now, that it is included in my assembly, although I haven't provided a `<scope>` tag. :-\ I'm not sure if I should be happy about this.
Bernhard V
Turns out that I haven't updated the parent's pom version in my child pom. Now I've got the same problem as in the beginning. In the parent the scope is provided, but in the child the scope is compile. But it seems that the parent overrides the child, because it is not included in my assembly. :-(
Bernhard V
I've now added my assembly descriptor and the files in the lib directory to my entry post.
Bernhard V
@BernhardV: I need the up to date output of `dependency:tree` (and just in case, maybe have a look at [8.5.4.3. Including and Excluding Dependencies by Scope](http://www.sonatype.com/books/mvnref-book/reference/assemblies-sect-output-algorithm.html#assemblies-sect-include-by-scope) in the Maven Book).
Pascal Thivent
I've updated the output in my question now.
Bernhard V
I've added `<scope>compile</scope>` to the `dependencySet` in the assembly xml and now it seems to work! The default value is runtime. Thank you very much.
Bernhard V