organize maven multi-module project in eclipse - java

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

Related

How to add same perspective in Eclipse in Other Projects?

I have saved a custom perspective in one of my projects and now I want to use that same again in my other java project but upon looking for perspectives category, my custom perspective is not showing up in the new project but is visible in the previous project.
I want my perspective to applied on all java projects which I ever I open automatically.
Is there any way we can export our perspective to a file format (like XML or something which eclipse can read on importing it again) and upon working on new project we can simply import them using the export file.
I don't know any solution to it but I have attached images for your references:
Java CP 2 is my custom perspective but it is not visible in another project.
How can I do something so that it is visible globally (in my IDE) and at present, I have to manually set up a perspective for each project I open.
Screenshot 1 - Java CP 2 Perspective
Screenshot 2 - Java CP 2 Perspective is not present

Is there a way to make empty packages visible in Eclipse?

Is there a way in Eclipse, to see empty parent packages? I have an issue freely viewing/accessing package new.galaxywar.client.resources.images.game that only contains 2 sub-packages:
I tried creating that package again, because I thought that i might not have it in my eclipse project, but it won't let me:
How do I prevent "views from filtering empty parent packages"?
In "Project Explorer" panel, click on the "View Menu" button (represented as a triangle).
Then go to "Customize View..." and deselect "Empty parent packages".
This should do the trick.
While I'm not sure how to perfectly solve the problem, I do know that you can still access the package if you try creating a new file in there, for example package-info.java.
Try doing that by starting to add a Class as usual, but specify the package to be the package you can't seem to access in the Package Explorer.
In recent versions of Eclipse, the steps in the accepted answer have slightly changed:
In Project Explorer panel,click on View Menu button
Then click on Filter
Deselect Empty Parent Packages
Eclipse IDE for Java Developers |
Version: Photon Release (4.8.0)
Build id: 20180619-1200
In Eclipse Version: 2019-03 (4.11.0)
On the Project Explorer tab press the triangle in the upper right corner.
In the menu choose Filters and Customization...
In the Filters and Customization menu unmark Empty packages and Empty parent packages.
Press OK
Now you should see the empty packages.
It's been 6 years since someone answered this question, and in the present day there is way more easiest methods to show hidden parent packages: "View menu" -> "Package presentation" -> "Hierarchical".
View menu of project explorer
Package presentation option
Hierarchical option

How do I share classes between two Android projects in Eclipse?

I have 2 Android projects in Eclipse. Now the both need to share one class. As soon as I add a Project to the buildpath of the other, the folder is added but always marked with a red cross. How can I resolve this? Thanks for any help.
You can use the feature of isLibrary project.
1)Create a new Android project.
2)Add all the classes that you want to share them between multiple projects.
3)Right click on this project and select properties.
4)From Android section in left menu mark the project as isLibrary project checkbox.
5)Right click on all the project you want to share the class with them and select properties.
6)From Android section in left menu click on the button Add and select the library project.
7)Use the class normally as if it is in your project and add its imports.
I hope it helps.
Note: The previous steps is for Eclipse
Mark project(that contains the class to be use in another) as library by right clicking the project and then properties.
You don't have to do it by means of a library project, you could use a common source folder.
If you are developing in Eclipse then the trick is to have a common source folder (common to both projects) Make this folder outside of both projects and in the build properties/source, click 'link source' and browse to the location of the common source. (You can call it any name you want) Do this in both projects and it will appear in both projects' Package Explorer and when you change it in one project, the other will get updated too.
It will have to have the same package name in both projects.

Project order Eclipse project explorer view

Is this possible in eclipse to put project in order like order by name or order which i would like to add.
I have around 30 projects in eclipse i want to see them with some order like alphabetic order. Is this possible in eclipse?
You can follow these steps to rearrange your project:
Window-> preferences -> General -> workspace -> Build order
Here you can rearrange the project build order but you can not define any rule like 'All project should come in Alphabetic order'.
For more clarification visit: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-17.htm
you can define "Working Sets" (i.e a named group of projects) that can be ordered. But I think you cannot reorder the projects within those working sets (at least I've never seen such an option).
Edit
for information about the general usage of workingsets you may want to visit one of the following URLs:
http://www.vogella.com/articles/Eclipse/article.html#tips_workingsets

How to display eclipse project type

In Eclipse IDE there are icons to display the project type, but I can't find a text description. I would expect right click -> properties to show this info but according to this all projects are of type "project" (even if they are a java project, or maven project etc.)
Does anyone know?
Thanks!
According to this, you won't find the text description in Eclipse GUI.
One way is to go to the root folder of your project, open the file named .project and check the elements in the tag <natures></natures>.
But don't worry about that, these icons are often explicit.

Categories

Resources