Maven2 issue

I'm not sure if this is a bug or me doing something incorrectly, but I'm having recurring problems using Maven2 in IntelliJ.

We have a maven2 repository at work and everything works great as long as the proper snapshots are available on the network. When I go home, even with "offline" mode checked I will invariably get incorrect dependencies generated when I resynchronize the project.

Our structures looks something like:

Project 1:-----+
                   


Project 3:-------+
Project 2:-----+                            

                                                 |----


Project 6
Project 4:--


Project 5-----+




I'm trying to work on Project 6 and it works fine as far as mvn compile or mvn install from the command line.

In IntelliJ though, if I resynchronize then I only get projects 3 and 5 as dependencies (this is when my repository isn't available remember, though the snapshots are all in my local ~/.m2/repository). I can go into each import statement and do an alt-enter to add the jar file to my classpath automatically, but it takes forever.

Help please!

10 comments

Hi,

What does you diagram mean? I don't quite understand.
Could you please send me you pom files, so I could reproduce your problem?

Thanks

0

I guess his diagram is a dependency graph, that is, his problem is that transitive dependencies doesn't work.

Regards,
Stig

0

But, if a maven module has a compile dependency on a library, shouldn't it declare it in its direct dependencies anywway ?

0

My understanding was that maven calculates transitive dependancies for you. And indeed, it works fine if I "mvn compile or mvn install or even mvn idea:idea"

I'll try to work up a pom that I can send but it might be difficult. :\ I was hoping it might be a problem someone had seen before.

0

Also, transitive dependencies even work in IntelliJ as long as I can reach the repository. It just doesn't seem to work if all I have available is local snapshots.

0

The reason (as far as I have gathered) for introducing transitive dependencies, are for cases where B needs C in its classpath, and A needs B, but A does not need C. In Maven 1 you had to include C in A's dependencies as it didn't have transitive dependencies, but in Maven 2 you don't need this.

Not a very good explanation, I'm afraid, but hope you understood.

So you are correct, Project 6 should really put Project 1 and 2 in its dependency list if it needs it and don't (mis)use transitive dependencies for this.

Regards,
Stig

0

this is also what I had understood

0

Shouldn't IntelliJ/Maven integration be able to do the same things that the command line maven client can?

Regardless of your opinion of the correctness of using transitive depencies this way, the maven client copes with it perfectly.

0

Sure it should. I think IntelliJ uses the Maven embedder (that is a library from the Maven folks that makes it easy to embed Maven), so it might be a bug in that.

I didn't mean to imply that you were doing anything very wrong. The only thing, as far as I can see, that makes your setup (and a lot of others, including some of my own :) a little bit harder to work with, is to easy see which direct dependencies a project has. To help out here, you can use the maven-dependency-plugin to list the correct dependencies for a project.


Regards,
Stig

0

Aaron,

we've done our best trying to reproduce your problem, but we couldn't manage that.
Please, try to create simple project structure that demonstrates the problem and send it.

Thanks

0

Please sign in to leave a comment.