Discussion:
dependencies to projects in the workspace
Bruno Haible
11 years ago
Permalink
Hi,

With m2e 1.4.0.20130601 I observe that the "Maven Dependencies" container
of a
Java project with m2e nature will contain
* references to artifacts for
- projects that are not loaded in the workspace,
- projects that are loaded in the workspace and don't have m2e nature,
- third-party libraries.
* references to workspace projects for
- projects that are loaded in the workspace and have m2e nature.

The developer experience in Eclipse is much better when using references
to
workspace projects than with artifacts:
- After navigating to a class, the developer can directly edit its
source code.
Whereas an artifact's source code cannot be edited.
- When debugging, it provides a great productivity boost to be able to
edit
the source code on the fly, save it, and continue with the same
debugging
session.
- When not debugging, changes to the other project's source code are
taken
into account directly by Eclipse, when no artifacts are used. Whereas
with
artifacts, the developer needs to launch a Maven build and then a
Refresh
on the project that uses the artifact.

What I would like to have is that the "Maven Dependencies" container
contains
* references to artifacts for
- projects that are not loaded in the workspace,
- third-party libraries.
* references to workspace projects for
- projects that are loaded in the workspace and have m2e nature,
- projects that are loaded in the workspace and don't have m2e nature,

Is there a way to configure m2e to this effect?

If not, is it a bug or a design choice?

Best regards,
----------------------------------------------------------------------------
Bruno Haible Email: <***@de.ibm.com>
IBM Deutschland
Wilhelm-Fay-Straße 30-34
65936 Frankfurt am Main
Germany
----------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
Igor Fedorenko
11 years ago
Permalink
m2e populates "Maven Dependencies" container based on Maven dependency
information provided by project pom.xml file. It is not possible to
match pom.xml <dependency> elements to non-Maven workspace projects in a
generic way, so the behaviour you see is expected and not a bug.

Having said that, there are couple of ways you can make m2e do what you
want.

It is possible to manually add classpath entries to Maven projects using
JDT standard "Java Build Path" project properties page. m2e will
preserve such entries during project configuration update and you can
even check in .classpath files to git (or whatever scm you use) so all
members of your team will use the same classpath.

It is also possible to implement m2e project configurator that will
create additional classpath entries automatically. If you want to try
this, I can provide some pointers on m2e-dev list.

--
Regards,
Igor
...
Bruno Haible
11 years ago
Permalink
Hi Igor,
Post by Igor Fedorenko
m2e populates "Maven Dependencies" container based on Maven dependency
information provided by project pom.xml file. It is not possible to
match pom.xml <dependency> elements to non-Maven workspace projects in a
generic way, so the behaviour you see is expected and not a bug.
have the right version
All dependencies I'm talking about (in our case) have a pom.xml, and the
version contained in this pom.xml is the same as the version specified
in the <dependency> element. (In fact, all these versions are
'Main-SNAPSHOT' in my case.)

I can understand that you require the dependency to be a Maven project
and that the version is correct.

The problem is the requirement that the dependency has m2e nature declared
in its .project file.

The project hierarchy in my case is like this:

A1 A2 A3 A4
\ \ / /
\ | | /
\ \ / /
\ | | /
\ || /

B

/ | \
/ | \
/ | \
/ | \
/ | \
/ | \
/ | \
C D E
/ \ / \ / \
/ \ / \ / \
C1 C2 D1 D2 E1 E2

All projects have a pom.xml, and we have a build system that publishes new
shapshots for all projects once a day.

The people working on A1, A2, A3, A4 would like to check out only their
project
in their Eclipse workspace. They want to use B, C*, D*, E* as snapshots.
For
them, m2e is useful.

The people working on C would like to check out all of C, C1, C2 into
their
Eclipse workspace. For them, m2e is not useful: the download of new
snapshots
every day is just a nuisance. Likewise for the people working on D and E.

But now, due to the reported problem between a project B that has m2e
nature
and a project C that does not have m2e nature, we are being pushed to an
all-or-nothing decision: Use m2e for all projects, or don't use m2e at
all.
Post by Igor Fedorenko
Having said that, there are couple of ways you can make m2e do what you
want.
It is possible to manually add classpath entries to Maven projects using
JDT standard "Java Build Path" project properties page. m2e will
preserve such entries during project configuration update and you can
even check in .classpath files to git (or whatever scm you use)
Thanks, I'll consider this solution.
Post by Igor Fedorenko
It is also possible to implement m2e project configurator that will
create additional classpath entries automatically. If you want to try
this, I can provide some pointers on m2e-dev list.
That's beyond me, sorry. I was hoping to see this functionality in m2e
itself.

Bruno
Igor Fedorenko
11 years ago
Permalink
I am still not clear what is the real problem you are trying to solve
and what is the solution you have in mind.

Developers who want to use m2e have to import all projects as Maven
projects. I think this is reasonable and consistent with Eclipse IDE
guidelines. Developers who don't want m2e will need to import their
projects as non-Maven projects... they are missing out, but I don't see
how m2e can help if they explicitly don't want to use it.

Also, I'd like to understand why m2e is not useful for C, D and E
developers. These projects look very similar to A and B on the diagram,
just with fewer dependencies. I would assume m2e should provide same
benefits to all projects, no?

As for "download new snapshots every day", m2e does not do this, or at
least it is not supposed to. If you see this happening with recent 1.5
milestone builds, I would like to understand scenarios when this happens.

Beyond daily snapshot download, are there any other problems developers
have with m2e?

--
Regards,
Igor
...
Adrien Rivard
11 years ago
Permalink
Hi
Post by Bruno Haible
Hi,
With m2e 1.4.0.20130601 I observe that the "Maven Dependencies" container
of a
Java project with m2e nature will contain
* references to artifacts for
- projects that are not loaded in the workspace,
- projects that are loaded in the workspace and don't have m2e nature,
- third-party libraries.
* references to workspace projects for
- projects that are loaded in the workspace and have m2e nature.
IIRC it is more exactly

- projects that are loaded in the workspace and have m2e nature *and have
the right version*.

IMO this is the point that will be hard to do right if you want to have
workspace reference for non m2e project.


The developer experience in Eclipse is much better when using references
...
--
Adrien Rivard
Continue reading on narkive:
Loading...