Multi module maven project is not showing in package structure but as folder structure in eclipse - eclipse

I have successfully imported a multi module maven project from GitHub into my eclipse and able to build it successfully.
But the problem is project is being shown in folder structure but not as package structure which is making my day tedious.
Could anybody else faced this issue? Please do suggest your ideas.

Check out if the Project view in hierarchical mode would be a better fit for your need.
See Eclipse 4.5M5:
The Project Explorer now provides the ability to view the projects in a hierarchical (a.k.a. nested) form.
For modular projects, this allows to have your Project Explorer mapping more closely the organization of your modules as they are on the file system.
This hierarchical view of projects often makes easier to navigate modular projects.
Hierarchical view of projects can be triggered from the Project Explorer view menu, under the Projects Presentation item.
Then it makes the folders that are at the same location as a project replaced by the project, and the projects that are nested under other projects will not be shown as root elements.

In the folder where you have downloaded the project from git, you will see a .project file. You need to provide buildspec and natures information in that xml file.
In my case the .project xml file looks like this -
Now, make sure that you have provided the buildspec and natures information as shown in example above.
Once you have made the changes to .project xml file -
Right Click the Project >> Refresh
Right Click the Project >> Maven >> Update Project
You will see that the project (source) folder structure is represented in desired format.

Related

Organizing non-Maven source code in Eclipse projects

I am working with some sample source code that comes with a book that I recently purchased. This sample source code does not use Maven. When I imported the sample source code into Eclipse, it created a zillion new projects, cluttering my Project Explorer. I want to organize all the source code from the book under one Master project, whose name is derived from the book. After playing around quite a bit, I came up with a working solution that is reproduced below:
Created a Maven project, choosing the book title as the Artifact Id
{thereby organizing all the child projects under the book title}
In the Maven project, created multiple directories from Eclipse,
one for each chapter of the book (New --> New Folder --> Folder name) {this ensures that Eclipse has visibility to the directories}
Closed Eclipse
Copied the source code, chapter by chapter, to each of the directories created under the Maven project
Relaunched Eclipse
Sequentially imported the projects from each directory created under the Maven project directory in Step #2 (Import --> General --> Projects from Folder or Archive)
Although I have been able to realize my goal, I am uncomfortable with the fact that I am creating the Maven project solely for the purpose of organizing multiple non-Maven projects under one parent project. I am not making any use of neat Maven features like dependency management.
Q) What is the best way to organize multiple non-Maven projects under one parent project in Eclipse?
First of all, if these projects are all test projects unrelated to other projects, you can just create a new Workspace in Eclipse.
If this is not what you want, you can define Working Sets that organise projects.
It is usually not necessary to put projects into subfolders to organise them.

Project files are not imported after importing the project in Eclipse Luna

I am new to scala as well as Eclipse. Please be smooth on my question. I looked mostly on all available resources of eclipse.
I am using Scala IDE in Eclipse. When I am importing the project into Eclipse(General->Import Existing Project...), then the project is imported, but main files in src/ as well as in test/ are not imported and they are present in project directory.
Here is the screenshot of the eclipse. Can anyone help me with this?
main/ and test/ are empty, but they contains the project file.
Even though source and class path resources may reside with the src/main/scala and src/test/scala folders under your project on the file system, Eclipse separates them off in the Package Explorer view and shows them in a separate part of the tree decorated with a little package icon.
See the first item in the tree under progfun-example.
Hopefully your source will be there. (The presence of the tree expansion toggle icon would indicate that there is something there.)

Maven in eclipse not showing all folders

I am new to Maven and have been trying to get a project working with Eclipse, hibernate,Maven and mysql. I am stuck at the very first step. I have everything configured properly i think and if i create a new Maven project in eclipse it does not show me any folder under src/main or src/test. although if i go back to that folder in the workspace it has a src/main/java
FUrthermore the src/main/resources folder is not created at the time of project creation?
Any clue what the problem maybe or how i can fix it?
Thank you!
For your first problem, when you create a new Maven project the folders that get created depend on the archetype you choose. Assuming you chose quickstart, then it does create (assuming you chose com.example as your package in the wizard and example-project as your artifactId):
And it configures the project so that /src/main/java is in the Build Path. That said, if you are viewing your project in the Package Explorer view, then the packages are shown outside of the folder structure. So, you would see the the com.example.example_project package containing App.java in the build folder /src/main/java and you would see the com.example.example_project package containing AppTest.java in the build folder /src/test/java. These would show up above the libraries which is above non-build folders which is where you see the src folder.
To answer your second question, no, /src/main/resources is not generated assuming you chose the quickstart archetype (this is governed by the quickstart archetype and does the same thing whether generated in eclipse or on the command line).
And third, to fix this (I assume you mean add the resources folder), find the src/java folder (below the libraries), right click and choose New->Folder. Name it resources. Then right click your project, choose Maven->Update Project. This will cause maven eclipse to reconfigure the project according to the Maven configuration which will result in the /src/main/resources being added to the build path. As such, it will get moved above the libraries next to /src/main/java and /src/test/java.

Eclipse buildpath automatically taking all JARs of a linked directory

This issue is a variation on the one described here: Eclipse buildpath automatically taking all JARs of a internal directory
But instead of any local folder, I'd rather have a linked folder from another project be picked up automatically in the buildpath.
Basically, I have a main project in my workspace that holds directories lib, ext-lib that contain multiple jar files each. These jar files may be upgraded/removed or new ones added every few days.
I also have many other projects in the workspace that relay on the exact same (up-to-date) jars from my main project.
My goal is that as I modify the jars in these two folders in my main project, to have them as linked folders in all other projects and have those linked projects dynamically picked up as part of the buildpath of all those projects.
Any suggestion on how to do that in eclipse would be highly appreciated.
Unfortunately, the "dynamic directory" plugins people mention can not work with "linked" folders :(
Sincerely,
Guy
I would suggest creating a USER LIBRARY in eclipse and then using that in all of your eclipse projects.
Try going into preferences Java -> Build Path -> User Libraries and creating a new user library with all your jars. Then use this everywhere you need these jars.
See this page for more details.
Also, this page explains creating a user library in a bit more detail. There is also a use-case there which seems a bit more aligned to what you had in mind:
6.2.1. Linked Library Project
A useful hybrid strategy is to configure a user library that is also available as a linked folder in your Eclipse workspace. Follow these steps:
1.
Create a simple project in your workspace. Unlike Java projects, a simple project has no Java build path configuration in its properties. Use the command File > New > Project > Simple Project.
2.
Uncheck the option to use a default project location within the workspace folder and enter the path for your \eclipse-contrib\libraries folder (see Figure 6-8).

Eclipse is not creating structure for Enterprise Application Projects

When creating a New Enterprise Application Project, instead of creating the usual tree with:
+Deployment Descriptor
+JAX-WS WebServices
+ejbModule
+JRE System Library
+JBoss v5.1
+EAR Libraries
+JavaScript Resources
+build
Eclipse is creating only a very simple structure. Like This:
+JavaScript Resources
Only the .settings folder and .project file are being created in the project's folder. No source, etc.
What's going on with this?
Thanks
It sounds more like you're listing the contents of a View rather than what's actually in your project. There isn't actually a "JavaScript Resources" folder, it's a root node under which the project's known types and globals are browsable. Have you checked the Project Explorer view (Window->Show View)?