I have a huge Maven multi-module project. With similar structure
parentA
- subA1
- subA3
- subA3
- subA2
parentB
- subB1
- subB2
etc
The problem is, that parentA and subA1 does not contains any code inside it, but I can still see them in project explorer. But I would like to hide them or organize in tree hierarchy like in an explorer. Right now there are over 30 projects and just 20 of them contains Java code. Others simply contains others modules references. I see all 30 projects in plain form in project explorer.
The first idea - was using working set, but I can't include working set in another working set. What is the common practice to handle this issue for eclipse users
go:
Windows -> Preferences -> Maven -> Hide folders of physically nested modules
and re-import your project.
We can also use working sets.
Choose Top level Elements as 'Working Sets' from Package Explorer / Project Explorer view.
Configure "Working Sets" to manage your projects. Move the Parent project to a different working set and child project in different working sets.
In Project Explorer, there's a down arrow, if you hover over it, it shows "View Menu".
Click on it, Project Presentation -> Hierarchical
Try using Projects View. It does it for me in these kind of situations.
Also, you can put filters to exclude certain projects in Package Explorer or other views that you prefer like this: go to PackageExplorer, select View Menu - Filters, check Name filter Patterns and enter the names of the projects you want to hide, separated by commas.
In other views, instead of View Menu - Filters is View Menu - Customize View.
You can find a tutorial here but instead selecting Closed Projects enter the name of the projects as I mentioned above.
As for the tree view I don't think you achieve that because in Eclipse there is no notion of sub-project. Have a look here.
From the Package Explorer view select filter from 'view menu'. Then select filters, and exclude Non-java projects.
On the package explorer window:
-> Select the three dots menu -> Then Package Presentation -> And then change from Flat to "Hierarchical"
And you are done :D
Change project view image
I have 3 projects in Eclipse that are bound to eachother. With bound i mean this:
Everytime i add a class in one of the projects, the other projects also updates themselves and add the class
Now i want to add another project to these, but i don't know how to bind it together with the other projects.
Any suggestions?
Edit:
alt text http://img218.imageshack.us/img218/8441/eclipsesymbol2.png
This is how the projects are listed in eclipse.
Any explanation about the [smax3]?
Any explanation about the ">"?
Thanks
Thanks in advance!
(See Java Build Path Eclipse Help page)
In the build path of a project, you can declare a project in the dependency list of another.
In the tab "Projects", add the project "P" you depend on.
Each time that project "P" is changed, your project will take the modifications into account.
See that old but still accurate article Configuring an Eclipse Java Project
This illustrates two project under version control (CVS or more probably SVN with Subversive or SubClipse).
See the label decoration help page.
Here: "[smax3]" is the name of name of the SVN repo, with an "Outgoing flag" (the '>'), meaning some resources within the project need to be committed and published to the SVN repo.
I've been working with branches for quite some time now, but I always used command-line tools to do the actual merging. However, now I need to do it from Eclipse only. Branching and merging being a widely used feature of SCM systems for many years now, I expected Eclipse to have good had support for it, but it just doesn't seem to be the case.
Currently I'm working on a product that is built up of several projects that need to be branched together. When merging changes from trunk to a branch, normally I would execute the following from the root of the branches checkout: (I'm using Subversion as an example here, but the problems should apply to other SCM tools as well.)
svn update
svn merge ^/trunk
svn commit -m "Merged from trunk"
Maybe fix some conflicts in the middle, but that's about all I have to do. However, in Eclipse I can only merge on the project level, which has the following disadvantages:
I cannot merge the contents of the root folder, only the contents of the individual projects. Same goes for updating, BTW.
If the project structure is modified on trunk (e.g. a new project has been added), those changes don't get merged at all. Same for update, again.
The merge is not atomic. If a commit happens on trunk during the merge, things can get messed up in my working copy. (This can be worked around, but not conveniently.)
These limitations seem pretty straightforward from the fact that Eclipse does not know about the root folder, as it checks out individual projects from SVN.
My question is: am I missing something, or is it really impossible to use Eclipse in a way similar to what I'd do from the command line? And if it is indeed impossible, then how do others cope with this? Does everyone use external tools like the command-line, or TortoiseSVN?
Your observation is correct. Eclipse manages "team" operations like svn on project level only. So, you're not missing anything ;-)
Yes, you have to use external tools for merging whole branches. Tortoise does it nicely.
Multi-project merging can be done with the Eclipse plugin CollabNet Subversion Merge Client. You can find it at com.collabnet.subversion.merge.
Enable it in the preferences:
Eclipse Preferences > Team > SVN > Diff/Merge
and there: Merge Implementation: CollabNet Desktop
What you mention is indeed a limitation. I normally checkout the whole folder structure and then import the individual projects into eclipse. When I need to do an operation on the whole repository, I do it outside from eclipse using either the command line or Tortoise SVN.
It is also a pain, that when someone adds a new plug-in (I am developing an Eclipse RCP application), I need to manually add it to the project list as Eclipse does not know about the root of all the projects.
In Eclipse, SVN branching and merging works nicely for single projects, I have not had any issues when dealing with single projects that have been branched and need to be merged.
However, if multiple projects need to be dealt with a single unit, then this does not seem to be possible to deal with directly in eclipse, each project would need to be dealt with individually.
For example,
I don't want to use org.testng.v6.Maps, (I want com.google.common.collect.Maps)
I don't want to use org.hibernate.mapping.List, (I want java.util.List like everyone else!)
Is there a way to tell Eclipse not to suggest these in the autocomplete box?
Yup - I have exactly this problem at work for a few classes too.
Preferences -> Java -> Appearance -> Type Filters.
Re-arrange your dependencies in the library path according to the order you want them to be.
Right click on project > Properties
Java Build Path
Order and Export tab
This should give priority to the dependencies you do prefer. (Although on second thought I am not sure this is reflected in the auto-complete boxes.)
I'm in the process of converting my projects to OSGI bundles using maven and eclipse. Maven builds the stuff just fine, only I get the above error now within Eclipse. How can I find out which project causes this? Is there a special view or something? How can this happen, I would expect that maven can detect cyclic dependencies as well?
Update
Ok, I found something
here
and
here
Could this be caused by the felix maven-bundle-plugin which does for each export also an import?
Mark circular dependencies as "Warning" in Eclipse tool to avoid "A CYCLE WAS DETECTED IN THE BUILD PATH" error.
In Eclipse go to:
Windows -> Preferences -> Java-> Compiler -> Building -> Circular Dependencies
When we have multiple projects in workspace, we have to set the references between the projects, not among the projects. If P1 references P2, P2 references P3, and P3 reference back to P1. That will cause a cycle.
The Solution is to draw a Diagram of the reference between projects in workspace. Check the Java Build Path of each of the projects to see the Tab of the Projects window. Take out the Project that are refering back to the main project, e.g. P3 references P1, in this example above.
Detailed operation is to select P3 project in RAD OR eclipse, right click on the project and choose the properties option, it brings up a new window for properties of P3. Click on the "Java Build Path" section, Choose the "Projects" option Tab. You can see the P3 has referenced P1 in the field. Select the P1 reference, click "Remove" button on the right side of the window. Then, click okay. The IDE will start to reset the path automatically.
Done.
Keep find all of the mis-referenced reference in every each projects until you have the right references to each of the projects in your Diagram. Good Luck!
I had this due to one project referencing another.
Remove reference from project A to project B
Try running stuff, it will break
Re-add reference
Clean/Clean and build
Back in business
Sometimes marking as Warning
Windows -> Preferences -> Java-> Compiler -> Building -> Circular Dependencies
doesn't solve the problem because eclipse don't compile the projects that have another project in the dependencies that isn't compiled.
So to solve this problem you can try forcing Eclipse to compile every class that it be able to.
To make this just:
Deselect
Windows -> Preferences -> Java-> Compiler -> Building -> Abort build when build path error occur
Clean and rebuild all project
Project -> Clean...
Reselect:
Windows -> Preferences -> Java-> Compiler -> Building -> Abort build when build path error occur
If you have the Automatic Build selected then you will not need to do this every time that you change the code
In simple terms, a cycle is when bundle A depends on bundle B which depends on bundle A. If this is source code, then there's no way of building the bundles seperately in one pass.
Since the problem only shows in Eclipse, it may be a binary circular dependency as opposed
to a source code circular dependency.
There is support for binary cycles in recent versions of Eclipse: Eclipsesource Blog
If the cycle is in your code, then I suggest refactoring the code by breaking out some of the code to a 3rd bundle to remove the circular dependency.
And watch out if you are using OSGi fragments (a common pattern for unit testing) as it is very easy to introduce cycles.
Eclipse's manifest editor does have functionality on the "Dependencies" tab for looking for cycles (you need to click on "Dependency Analysis"), but I've never seen it show a cycle even when Eclipse has a big red X telling me there's a cycle!
I faced similar problem a while ago and decided to write Eclipse plug-in that shows complete build path dependency tree of a Java project (although not in graphic mode - result is written into file). The plug-in's sources are here http://github.com/PetrGlad/dependency-tree
Problem
I have an old project that tests two different implementations of a Dictionary interface. One is an unsorted ArrayList and the other is a HashTable. The two implementations are timed, so that a comparison can be made. You can choose which data structure from the command line args. Now.. I have another data structure which is a tree structure. I want to test the time of it, in order to compare it to the HashTable. So.. In the new dataStructure project, I need to implement the Dictionary interface. In the Dictionary project, I need to be able to add code specific to my new dataStructure project. There is a circular dependency. This means that when Eclipse goes to find out which projects are dependent on project A, then it finds project B. When it needs to find out the sub-dependencies of the dependent projects, it finds A, which is again, dependent on B. There is no tree, rather a graph with a cycle.
Solution
When you go to configure your build path, instead of entering dependent projects ('projects' tab), go to the Libraries tab. Click the 'Add Class Folder...' button (assuming that your referenced projects are in your workspace), and select the class folder. Mine is \target. Select this as a library folder. Do this in project A, to reference project B. Do this in project B to reference project A. Make sure that you don't reference \target\projectNameFolder or you won't have a matching import. Now you won't have to remove a dependency and then reset it, in order to force a rebuild.
Use class libraries instead of project references.
Maven will fail the build if it detects a cycle, as the dependencies must be a tree.
You may find that you have additional declarations in the manifest.mf over those defined in the pom.xml. any extra declaration could introduce a cycle that wouldn't be apparent to Maven.
As well as the Require-Bundle form of dependency management (most similar to Maven's pom dependencies), it's also possible to have Import-Package dependencies. It's much easier to introduce circular dependencies with Import-Package than Require-Bundle, but YMMV.
Also, Eclipse projects have a 'project references' which says which other projects it depends on. Eclipse uses this at a high level to decide what projects to build, and in which order, so it's quite possible that your Manifest.MF lists everything correctly but the project references are out of whack. Right click on a project and then go to properties - you'll see which projects you depend on. If you're a text kind of person, open up the .project files and see which ones you depend on there - it's probable that a project cyclic link is being defined at that level instead (often caused when you have an A-B dependency and then flipped from B-A but without updating the .project references).
When I've had these problems it always has been a true cycle in the dependencies expressed in Manifest.mf
So open the manifest of the project in question, on the Dependencies Tab, look at the "Required Plugins" entry. Then follow from there to the next project(s), and repeat eventually the cycle will become clear.
You can simpify this task somewhat by using the Dependency Analysis links in the bottom right corner of the Dependencies Tab, this has cycle detection and easier navigation depdendencies.
I also don't know why Maven is more tolerant,
Try to delete references and add it back, some times eclipse behave weird because until and unless you fix that error it wont allow you refresh. so try to delete all dependencies project and add it back
Clean and build
Just restarting Eclipse fixed the issue in my project
Although "Mark Circular Dependencies" enables you to compile the code, it may lead to a slower environment and future issues.
That's happening because at some point Eclipse has lost it's directions on your build path.
1 - Remove the project and it's references from the workspace.
2 - Import it back again.
3 - Check the references.
It is the best solution.
I faced this same problem today. The error was apt. By mistake, I added cyclic dependency. A was dependent on B. In my case, by mistake, apart from adding B as dependent to A. I added A as dependent to B too. It was a foolish mistake.
I have this problem,too.I just disable Workspace resolution,and then all was right.enter image description here
This could happen when you have several projects that include each other in JAR form.
What I did was remove all libraries and project dependencies on buildpath, for all projects. Then, one at a time, I added the project dependencies on the Project Tab, but only the ones needed.
This is because you can add a project which in turn has itself referenced or another project which is referencing some other project with this self-referencing issue.
This resolved my issue.
Eclipse had a bug which reported more cycles than necessary. This has been fixed with the 2019-12 release. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=551105