How can I make sure a project that is shown in my workspace is actually part of the workspace. Below, I will explain what happened so that you know why I'm asking this question.
I had checked out a project into my workspace, and then had configured it as a Maven project by selecting Configure->Convert to Maven Project; in most cases, when I do this, the project becomes part of the workspace. But in this case it hadn't. But I spent a few hours before realizing that I need to import the project in order for the workspace to recognize it as workspace project. So, I want to avoid this situation and be able to look at a flag or file or something that tells me if a project that is shown in the Eclipse window is actually a workspace project.
Thanks
I'm adding the following to make the problem more clear:
This is what I do; I have a workspace with a few projects (all Java/Maven project); everything works. Then I checkout another project from svn into the workspace; so, the folder of the new project is within the same workspace. I expected that as soon as I check out the new project into the workspace, and convert the new project into a Maven project, then the new project be recognized by Eclipse as one of the projects in the workspace. But that is not the case; I actually have to import it.
The project folder is there, and I can see it in the Project explorer. Nothing happens to it, but it is not used by the workspace. For example, if I add breakpoints to the Java files which are in the new project, they are not used. At this point, I use File->Import menu to import the project from the same folder that is already in the workspace, and bang, it starts working, and my breakpoints work.
Is my procedure for checking out a project from SVN into the workspace wrong? I want to fix my procedure to make sure this will never happen. Do you think that even though the new project is a subfolder of workspace, I should still need to import the project into the workspace?
I just noted another fact; this particular project that I'm importing is a Maven multi-module; could it be that the parent project is actually part of the workspace, but the modules inside it are not; therefore, just because it is a Maven multi-module, I need to import the sub-modules.
There are four ways to create a project in Eclipse:
create
Create in a default location (workspace folder on a filesystem)
Create in user-specified location (anywhere)
import
Project is referenced from workspace, untouched otherwise, location on a filesystem is unchanged
Project is copied into default location
You probably want to know if a project is located in workspace folder on filesystem. To do this, you can open project's properties and find location in resource node:
"... in order for the workspace to recognize it as a workspace project..." doesn't make any sense to me. I'm not exactly an eclipse expert, but a workspace is the set of directories in which you are working at one time in eclipse. There can be more than one workspace for eclipse on a given machine.
If you checked it out and it appeared in eclipse, then it was "in the workspace" afaik. Now, Maven tasks create and change files, and those changes do not automatically show up in the workspace -- you have to refresh the project, which essentially syncs the filespace with the workspace.
If that doesn't cover your case, then detail what you mean by "not in the workspace".
Related
I just checked out some projects from svn to my pc, and I tried to import the projects into my workspace.
But I failed to import some of them, and eclipse didn't recognize those projects(didn't show up in the import window).
And then I turn to google and found a solution -"add .projects and .classpath file to project folder" works.
However, what make me really confusing is that I foundthe projects I successfully imported into workspace without manually adding the files for them also don't contain .projects and .classpath. Eclipse just create the files for them automatically after import, so it seems that the fail of importing projects(or recognizing projects during import) is not just simply because of the lack of .projects and .classpath.
Does anyone know what cause the difference?
How does eclipse exactly recognize a project as importable project?
*eclipse version info here
Eclipse or any other IDE doesn't required .classpath or .project files. These files will be auto created during the project import. IDE can capable to pull the artifacts from maven central repo automatically by using build descriptor file such as pom.xml or build.graddle.
The files .classpath and .project will store the paths from local machine, if we carry them to another system, the artificats and other dependencies may not be present in the same directory, so it will start complaining build errors. Thats why while committing to GIT always there is .gitignore, so that local configuration will not carry to others while contributing.
I have set up an eclipse workspace. Inside this workspace i have a dynamic web app cloned from repository. My working directory looks like following.
I am seeing a different hierarchy in Eclipse project explorer. My project explorer looks like following.
Ideally it should show src, WebContent, build.xml etc. inside java resources but it shows entire project folder inside java resources.
Troubleshooting I tried:
1. Delete existing project from project explorer and import the project again.
2. Pull the changes in local copy and refresh the project from project explorer.
3. Change the working directory and import a new project.
None of this seemed to resolve the problem.
Appreciate if someone could help me with the root cause and a solution to this.
I am using Maven projects in my Eclipse workspace.
But, somehow Eclipse is referring the old .class files while running the program.
Hence, I have to re-build the complete project everytime I make any change to any java program.
I have tried executing maven commands like eclipse:clean & eclipse:eclipse.
But, they did not help.
My eclipse is also set to project - build automatically.
Is there a way I can tell Eclipse to refer to the current built .class files and not the previously built maven .class files.
Note: I am using Eclipse Mars
Thanks in advance.
I am afraid. There is no way to doing it automatically. Even if you find a way to do so. There isn't any guarantee that eclipse will build with new war.
Either you go for manual mvn clean install or use intellij idea it is very much statble. No build issue. Every time on your single save it will build new war file.
Posting answer to my question:
Sometimes the .project file of Eclipse gets corrupted. Easy solution is :
Delete the project from Eclipse.
Close Eclipse.
Go to your project's folder and delete ".settings, .project, .classpath, bin"
Open Eclipse again, and import your project once again.
This way it always works.
I have two maven projects in eclipse, a jar and a war. The war has a dependency on the jar, which is resolved through workspace resolution.
The problem is that the jar has generated classes, which are added to the jar through build-helper-maven-plugin. But these classes aren't being properly resolved in the war project. For example: It auto-completes the class but keeps saying it can't be found. More importantly, when running glassfish through eclipse, I get a class not found for these classes.
If I disable workspace resolution everything works fine, but I hope to use workspace resolution. Any ideas?
EDIT:
Folder structure. The maven workspace resolved persistence project in the lower image is in the Maven Dependencies folder, essentially your seeing the top and bottom of the folder.
IDK if I am correct, but you are talking about Eclipse problems - it does not "see" generated classes right?
To fix it, you have to add generated sources directory to the eclipse's build path and it should fix your problem.
Right click on project that has generated classes->buildPath->conf
buildpath
In source tab - click add folder
Select the directory where build helper generates java files.
Generated classes will apear as additional source folder in Eclipse's project hierarchy and voila, Eclipse can autocomplete and resolve generated classes now on the same conditionstha any it would on any other class written by you in the same project by hand.
When I do File -> Import, General (from the pop-up window)->Existing Projects into Workspace, I can browse to where all my projects are and import them so my Eclipse workspace folder with its .metadata is in a separate location from my source directory.
The problem is, if I add a new project or even add a new file within an existent project, the new files get made in my Eclipse workspace folder, not over where the other code lives.
How do I tell Eclipse to put new code in the source directory, not in the workspace directory? When importing, I did not check the checkboxes "Copy projects into workspace" or "Add project to working sets" (Add project to working sets requires the selection of working sets, which I don't know about).
It depends on the kind of project you are creating. For example, a "Project" type project that just contains dumb files lets you uncheck the "Use default location" option and will actually be created in whatever directory you give it.
Java projects, on the other hand force you to create them in the workspace.
For project types that eclipse will only create in the workspace you can use the following workaround.
Create the project in your workspace.
Delete the project from eclipse without deleting the files on disk.
Use your OS tools to move the project folder where you want it.
Back in eclipse: File -> Import -> Existing Projects into Workspace
Browse to folder containing your relocated project.
Make sure to uncheck the "Copy projects into workspace" option