I have issues related to Workspace Resolution enabled in Eclipse.
Hope someone can help.
If I understand correctly, workspace resolution enabled means projects don't have to be
installed in the local repository to relate to one another.
Test Environment
Eclipse Indigo (3.7.2)
Eclipse IDE 1.4.2
M2e Maven Integration for Eclipse 1.0.200
M2e Connector for build-helper-maven-plugin 0.14.0
Maven Integration for WTP 0.15.2
Issue Description
You can configure an eclipse project to resolve dependencies from a
workspace. This has the effect of altering the way that Maven locates dependency
artifacts. If a project is configured to resolve dependencies from the
workspace, these artifacts do not need to be present in your local repository.
Assume that project1 and project2 are both in the same Eclipse workspace, and
that project1 (ex, a war project) depends on project2. If workspace resolution
is disabled, the m2eclipse Maven build for project1 will only succeed if
project2's artifact is present in the local repository. If workspace resolution
is enabled, m2eclipse will resolve the dependency via the eclipse workspace. In
other words, when workspace resolution is enabled, projects don't have to be
installed in the local repository to relate to one another.
But for the later, that’s not the case.
[NB1:
For transitive dependencies (e.g project1 depends on both project2 and
project3, and project2 depends on project3) make sure that ‘workspace
resolution’ is enabled for all projects inside the workspace, else we get
unpredictable results: http://jira.codehaus.org/browse/MECLIPSE-348
]
[NB2:
Extract from http://www.theserverside.com/news/1363817/Introduction-to-m2eclipse
]
Now let’s perform the following set of commands through the eclipse IDE to
test what mentioned above
- Workspace Resolution Enabled (cases 2 and 4) or not (cases 1 and 3) on all
related projects (fig 1.1)
- ‘Run As > Maven Clean’ on project1 and project2
- Remove projects from your local Tomcat wtpwebapps and from local maven.repo
- ‘Maven > update dependencies…’ on project1
- Refresh on project1
- Right click on your Tomcat server instance in Eclipse and do ‘clean tomcat
work directory’ and then ‘clean’. The later should republish your resources as
well.
- Start Tomcat
Results obtained are given below.
|
Workspace Resolution OFF |
Workspace Resolution ON |
Project1 opened
Project2 closed |
(1) OK |
(2) OK |
Project1 opened
Project2 opened |
(3) NO
And publish to Tomcat doesn’t work |
(4) NO
But publish to Tomcat works fine |
Fig 1.1
OK: successful deployment of war to tomcat and application runs normally
NO: build errors
The key thing here is that case (4) should have started normally but fails at
step 6.
When we compare the directory structures of case (1) and (4), we notice that
it’s all messed up and that all ‘.class’ files are missing, which is in fact
normal since we didn’t do a ‘maven build/install/package’ of the dependent
projects(fig 1.2).
Fig 1.2
This is in fact an existing bug in Eclipse, but might be deprecated?
A version downgrade/upgrade of m2e doesn’t work either. I tried to migrate from m2eclipse to m2e, no luck. (as done here: http://blog.frankel.ch/migrating-from-m2eclipse-to-m2e)
Bug References
https://issues.sonatype.org/browse/MNGECLIPSE-1755
[notice the creation date, and it is still unresolved]
https://issues.sonatype.org/browse/MNGECLIPSE-1387
[notice the creation date, and it is still unresolved]
http://jira.codehaus.org/browse/MNGECLIPSE-474
http://jira.codehaus.org/browse/MNGECLIPSE-438
http://stackoverflow.com/questions/4262186/missing-maven-dependencies-in-eclipse-project
http://stackoverflow.com/questions/2665904/m2eclipse-workspace-resolution
I was wondering if there are any solutions/workaround/recommendations to solve the bug for case 3 and 4 mentioned above?