Change gradle project directory, cannot use eclipse - eclipse

I have a gradle project I had imported into eclipse (it is the libgdx sample project "The Plane that couldn't fly good" here), and it runs fine.
Now I exited eclipse, moved the project directory elsewere, re-launched eclipse, and it complains it can not find the project files (fine, I moved them in other directory).
So I am trying to open the project from the new directory but I am unable to find a file to feed eclipse with (such as a .sln file for visual studio); I tried to re-import the project, but eclipse complains:
trunk.theplanethatcouldntflygood-android existing workspace project
theplanethatcouldntflygood-android has the same name
So I am wondering if I am trying an impossible use case (NEVER change a gradle project directory) or I am missing something?

Delete the old project in Eclipse first and then import it again.

Related

How to fix "Missing Gradle project configuration file" issue in Buildship?

As an Eclipse user, I always liked the Gradle IDE. However, this plugin is now deprecated in favor of the new Buildship plugin.
After setting up a fresh Eclipse IDE with Buildship installed, I'm faced with the following error in all my Gradle projects:
missing gradle project configuration file: .settings/org.eclipse.buildship.core.prefs
There are several pages on google that deal with this issue, but all of them seem pretty outdated. There is also an entry in the bugtracker of the plugin which is set to "CLOSED FIXED". Well, apparently, it's not fixed.
Am I doing something wrong? Any ideas how to tackle this issue?
I've figured it out myself. The issue with the "missing gradle project configuration file" arises from the way the gradle project(s) are imported into Eclipse.
When importing a gradle project via the regular File -> Import -> General -> Existing Project into Workspace command, then it will not work and produce the aforementioned error.
However, if you import the very same project via File -> Import -> Gradle -> Existing Gradle Project, then you get a different import wizard, and with this wizard, it works like a charm.
I still think it's a bug because the choice of the import wizard should not matter. Still, choosing the proper wizard is a viable workaround.
Another option is to:
Move to your projects path (where gradle or gradlew is found)
Unix: sh gradlew cleaneclipse
Win: gradlew cleaneclipse
Requires the apply plugin: 'eclipse' in your build.gradle
Refresh your Project in eclipse.
After that for Unix: sh gradlew eclipse Win: gradlew eclipse
Now the gradle nature will be missing in your eclipse-project. Open the context menu of your project -> configure -> add gradle nature
Now everything should be fine again.
I seriously searched for the solution, but only found workarounds. Alan47's solution created the file for me, but couldn't create the project properly in my case. So I just copied the file created and imported the project again in the default way:
File -> Import -> General -> Existing Project into Workspace
and pasted the file again at the directory
./.settings
The name of the file:
org.eclipse.buildship.core.prefs
The content of the file is only:
connection.project.dir=
eclipse.preferences.version=1
The easiest solution, using just the mouse
As is told here by oehme (Stefan Oehme - core dev):
https://github.com/eclipse/buildship/issues/504
"Buildship can't recreate that file as it cannot know what your root project was (Gradle supports arbitrary project layouts). You should either check the settings file in or not check in any Eclipse files at all. Checking in .project while leaving out .settings is not supported."
Or here (Stefan Oehme - core dev):
https://discuss.gradle.org/t/do-i-need-to-check-in-settings-org-eclipse-buildship-core-prefs-file/22457/2:
"This would happen if you have a checked in .project file with the buildship nature, but no checked in settings file. The choice is between checking in both or checking in neither and using the Gradle import wizard."
The easiest solution, using just the mouse is the following:
Right click on the project then click Properties
In the properties window go to the Project Natures and remove the Gradle Nature then click Apply and Close button
Open again the same window and add Gradle Nature back, then click Apply and Close button
Right Click on the project > Gradle > Refresh Gradle project
After each step: 1,2,3,4 let eclipse do its update job, do not push it quickly.
Other solution is to have the file saved somewhere and paste it again in the project or create from scratch manually, then do: Right Click on the project > Gradle > Refresh Gradle project.
Useful details:
File name: org.eclipse.buildship.core.prefs
File usual encoding: ISO_8859_1
File path: ./setting/org.eclipse.buildship.core.prefs
File content, one line: connection.project.dir = eclipse.preferences.version=1
maybe you can use this method. by making the file back
I accidentally deleted or lost the file in my flutter project.
then I make a new method
enter the ./android folder in your flutter project.
copy to your terminal for mac:
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
then to your ./android/app folder in your flutter project.
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=..
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
Step 1
Right-click on your project name in IDE > Properties > Project Natures > Choose Gradle Project Nature on the right pane > Remove > Apply and Close
Step 2
Right-click on your project name in IDE > Configure > Add Gradle Nature
Result
Give it a few seconds for Gradle to synchronize with the IDE, and
.settings file will be automatically generated in the project root.
Delete error
Delete the error in Problems view.

Not finding libgdx projects to import them

I bought a new computer and installed Eclipse on it. After the ADT plugin finished downloading I tried to import my projects (composed of 4 sub-projects), but Eclipse doesn't see them!
I just click "import/general/import existing projects into workspace", select the folder containing the sub projects, hit the open button but Eclipse says "No projects found to import".
I'm using Eclipse Kepler and the projects files are directly taken from Eclipse Juno.
Eclipse need .project file to import the projects into workspace. what you can do is create a new project and copy the source and libraries into that project
Alternative method can be that create a new project and copy the .project file from that project to your project but make sure you edit the .project file and change the name of that project according to your project. read this for more information on .project file
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html
I will suggest you to use the First method .
Make sure that you've tried to:
Refresh everything
Searched for Nested Items
Go to (In the libg-gdx setup) Advanced >> Check Eclipse
And if that doesn't work, add a .project file into the folder manually

Eclipse: "declared package does not match the expected package", but buildpath does define the declared package

In a maven project called my-project, eclipse keeps telling me
The declared package "com.myself" does not match the expected package "main.java.com.myself"
although I verified that in the project's build path, I have an entry:
my-project/src/main/java
Included: **/*.java
Excluded: (None)
Native library location: (None)
Ignore optional compile problems: No
What could be the problem then?
What is the easiest way to fix the problem?
I suspect that something is wrong with the eclipse settings files, because after importing the project to the workspace and converting it to a maven project, I had to change the folder structure manually in to get the conventional folder structure of a maven web project. But it could be that during those changes, something was not understood properly by eclipse.
Also, maven is able to build my project (from within eclipse, as well as from the command line).
I'm just getting those compilation error from eclipse.
P.S. I've already tried project > clean, but it did not help.
Set my-project/src/main/java as the source folder (Project -> Properties -> Java Build Path -> Project -> Add Folder). Remove the old source folder.
Restart eclipse if necessary.
Simply put, Eclipse thinks that your project begins at my-project/src. Therefore, it expects all packages to descend from there, starting with main.java.
Looks like the project is still not in maven nature...
Follow the steps:
Right Click on the project folder -> Maven -> Update Project...
OR, open the command prompt, go to the root project directory, and type the following command:
mvn eclipse:clean eclipse:eclipse
I copied the project folder to some place outside of my eclipse workspace.
Then I deleted the project from the eclipse project explorer and the workspace.
Now I created a new java project with the same name, and imported the original project that I saved at (1).
Tah dah! no compilation errors.

Importing maven sourceproject into eclipse

I have imported my maven project in eclipse using Import Maven project. It got import in eclipse project explorer, but all the source folder are opening as files and folders, its not opening as java source folder. Since its opening as files and folder, it doesnot have compilation unit, found very difficult to code using it.
What do I need to do inorder to make the source folder as java source folder so that I can code easily?
Select the project and from the context menu choose Maven -> Update Project Configuration (This menu item gets reworded across various maven releases so look for something similar). You may also need to choose Update Dependencies.
In the shell/command line, execute mvn eclipse:eclipse

How to convert IntelliJ project to Eclipse?

I have one IntelliJ project and I want to open it in Eclipse, so what should I do?
There is an export to eclipse option in Intellij Under file menu.
This option will generate you the necessary .project and .classpath files that will be used by eclipse. Personally, I would remove any IDE dependencies using some dependency management systems like Maven or Apache IVY. ( Is system the right term?)
I had the same issue and (I don't have Intellij) but doc_180's comment pointed me in the right direction. Here is a simple solution. In Eclipse create a new blank Android project. Copy the .project and .classpath files and the .settings folder to the Intellij folder. Edit the .project file and change the name of the project.
You should now be able to Import the project in Eclipse by right clicking and selecting "Import->Existing Project into Workspace".
I see this is an old question, but thought I should add this answer for others Googling it like me ;)
Without access to IntelliJ to export and convert the project, try the following.
In STS or Eclipse create an empty project first, then, select File -> Import and choose General -> File System. In the resulting dialog box, select the root folder of the IntelliJ project as source and the empty project as the destination.
For unit tests, add the test folder as a source folder to the build path (right-click on the folder, select Build Path -> Use as Source Folder).
The projects I import this way run without any further modifications, including the tests.
Eclipse and Intellij create different project structure each other (Output path, Source Code etc...). You can export the current project to Eclipse environment.
File -> Export -> Project to Eclipse