Eclipse doesn't clean or build any projects - eclipse

I'm running Eclipse Neon. Whenever I click on any of my projects and try to click clean or build it doesn't allow me to - it is greyed out. It doesn't matter if I make any changes to the code or do anything else, it never gives me the option to clean/build.

It seems you have only general projects without builders: right-click on a project and choose Properties. In the Properties for ... dialog, in Builders look if there any builder listed. Without builders, your projects are probably configured incorrectly.
Builders (executed when project files are changed, e. g. incremental Java compiler) and natures (specifie which tooling is available) are set/stored in the .project file (which are hidden in the Projects/Packages Explorer view, but shown in the Navigator view and which can be edit with a text or XML editor). For example, the .project file of the plain Java project with the name and project folder Foo has the following content:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Foo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
If available, you may try right-click on a project and choose: Configure > Configure and detect nested projects...

Related

Scala Eclipse IDE won't bring in external dependencies with Gradle

I usually use IntelliJ and SBT for my Scala projects, and am forced to use Eclipse with Gradle for a new project, both tools I'm finding to not be well suited to developing Scala.
I'm using Scala IDE 4.6.1, and sometimes when I import an existing Gradle Scala project I've cloned from a Git repo, it refuses to pull in the external dependencies listed in my build.gradle listed in the dependencies {... } block. My steps for import are:
File->Import... ->Gradle/Existing Gradle Project- > Next ->
I Select the cloned parent dir as the project root directory
Click next and insure my Local Installation Directory is set to the proper place for Gradle: (C:\Program Files (x 86)\Gradle 4.6)
Click Finish, and once everything is brought in, I right click the project folder in the project explorer, select the gradle folder, and
click "refresh gradle project"
Sometimes this works, and sometimes it doesn't. When it works, it brings in 3 folders into the project:
JRE System Library, Scala Library Container, and Referenced Libraries.
When it doesn't work, Referenced Libraries is missing, and the code red lines all the external dependencies of the project. Any ideas on how to fix?
Got the fix. So, if experiencing the above issues after following those steps:
Be sure in the project itself the .project file looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>YOUR PROJECT NAME</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.scala-ide.sdt.core.scalabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.scala-ide.sdt.core.scalanature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
Then, derived from this answer in another thread, from your command line, navigate to just under the top level of the project folder and execute gradle cleanEclipse eclipse
Now the "External Libraries and Dependencies" OR "Referenced Libraries" should be viewable as a dropdown.
Now, in Eclipse, under the gradle tasks area, it may or may not say there are no gradle projects in the workspace. Even if your projects are viewable in the lefthand projects pane, you will have to re-import them following the steps 1-4 outlined in the original question.
Wait for it to finish and that should do it.

mavenize eclipse wtp project (Dynamic web module) for openshift

Managed to publish my project in Openshift - by scp'ing the war to the correct location as detailed here. Here is the .project file:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DataCollectionServlet</name>
<comment></comment>
<projects></projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments></arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments></arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments></arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments></arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
Runs locally on glassfish and Jboss - in OpenShift I only have the jbossas gear
Now I want to properly set it up so it is build when I do a git push. Do I need to mavenize the project ? I installed the m2e plugin but "Convert to maven project" did not transfer the dependencies (there are project dependencies and custom jar ones as well as logback and co) and did not create a "maven" folder structure.
Do I have to create a particular folder structure ? Do I need to set up build hooks manually ?
Eclipse Luna, Java EE pack
OpenShift uses the pom.xml file to compile and publish your java project. You should try creating a java project on OpenShift, and git clone it locally, then read through the pom.xml file and see what components that you need for it to work. It would be worth doing that and then converting your project into that maven structure that OpenShift uses. It is important to have/leave the openshift profile at the end of the pom.xml as that is what tells your gear where to put your .war file after it is built.

Maven project not being treated as Java in Eclipse

I'm working on a project that has lots of different Maven projects. I've been doing a bunch of JUnit testing on these projects, and usually this goes well. I open up Eclipse, right click in package explorer->Import... Existing Maven Projects and I'm able to import the project fine. I can build, drill down to src/test/java... Right click on the file and do a Run As JUnit test. Every now and then though, I can't get this to work. If I right click to do a Run As, all I get is AspectJ/Java application. There's no JUnit tests.
I noticed that the icon next to the project folder only has an M and a folder icon, whereas with projects that do work, there's a folder, M, AND a AJ. I've also noticed that it doesn't seem to sort the files into their packages like normal Java projects. It seems like it's not treating the project as an AspectJ project. How do I get Eclipse to recognize this Maven project as a Java project?
Several of the existing answers should work, but those suggesting to add a Java facet will only work if your project already is of (or you want to convert it to) a faceted nature, and the one suggesting you change your pom.xml will only work if you then re-import your project as a maven project.
If you'd like to "fix" your existing project, i.e. add a Java nature without converting it to faceted form and without deleting and re-importing, just edit your .project file (externally, or with the Navigator view in eclipse, as it won't show up in your package explorer) and add the java builder and java nature to the existing maven builder/nature:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>yourprojectname</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<!-- add this build command -->
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<!-- this would've already been there -->
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<!-- add this nature -->
<nature>org.eclipse.jdt.core.javanature</nature>
<!-- this would've already been there -->
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Note the different capitalisation (javabuilder but maven2Builder, javanature but maven2Nature).
As soon as you save, it should re-build automatically. You may have to manually add any source folders (Project properties -> Java Build Path -> Source tab -> Add Folder....
Right-click on Project -> Properties -> Project Facets, then choose all facets that apply for your case (e.g. java).
mvn eclipse:eclipse will create necessary .project files which will add java nature & other properties to the project
I was facing the same problem and the steps below solved it in my case:
1- Open the pom.xml of the problematic project.
2 -In the overview tab, check the Artifact/Packaging settings.
3- If it is set to "pom" change it to "jar".
4- Save your changes and then delete the project from eclipse only and re-import it.
Hope that helps!
It depends on the Eclipse project facet properties (if you are using Java EE), I suggest you right click on project properties and see which facet is defined for your project.
I faced the same problem(after importing pom.xml to eclipse,the project is not treated as a java one,and there is only "maven project builder" in project builders property,but no "java builder") in eclipse luna.
Re-importing maven project after deleting ".settings" folder and ".project" file did not work.
Re-importing after a workspace switch worked for me.
I talked to a co-worker and I was able to "fix" the problem. I did a delete from Eclipse (not from disk) and immediately re-did the Maven import and now it magically works.
It seems like if there was an error with the pom.xml, particularly if the parent version was wrong, that the maven project doesn't get imported/created properly. Once I fixed the problems in the POM, the project would build fine without any problems but it was still only a Maven project. Once I removed it and re-imported it, THEN it treated it as a Maven/AspectJ project.
Check the pom.xml file for projects that don't get the AspectJ nature (AJ on the project). Are they missing the AspectJ-Maven plugin? They should have a section like:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<complianceLevel>1.6</complianceLevel>
</configuration>
</plugin>
Also take a look at his question: Maven/AJDT project in Eclipse
There are two ways this can be achieved.
1) By Changing the project nature.
Right-click on Project -> Properties -> Project Natures, then choose all natures that apply for your case (e.g. java).
(OR)
2) By updating the .project file and add all the natures that are required for the project. This .project file is located at the root folder of the project. If the file does not exist for any reason, create a new file, and add the sections for each nature that is required e.g., as follows.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>yourprojectName</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
I know that this question was a long time ago...
I just resolved the issue by these 2 steps below.
run cmd "mvn eclipse:eclipse" in the root directory of the project
right-click on the project in eclipse then select "import as project"
My five cents...
In my case I was 'losing' always the 'Java' nature of the project because the pom file was set to 'package as ear'. There was no error or warning message though, which would be nice to have. As soon as I changed the package to 'jar' I could set the nature of the project to Java and it is persisted.
I also tried all the approaches described in this thread. Modifying only .project is not enough because the maven libraries will not be used for building the project and the project build will fail. mvn eclipse:eclipse will create a long and useless .classpath without actually using m2e.
The easiest way is to create a new java project, convert it to the Maven project and open the .project and .classpath for this new project. Then make similar changes for the imported Maven project.
The important changes for the .project file have been described but in order to use the Maven dependencies in Eclipse something like this should be in the .classpath file
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Using facets is not an option in this case because with facets Eclipse doesn't use m2e and the maven dependencies. Again the dependencies with facets have to be managed manually.
I tried all this with Eclipse 4.6.2 Neon.
I had the same problem. In my case it was some defect in eclipse workspace. I recreated it (deleted .metadata directory) and that fixed the issue.
If you have tried Amos M. Carpenter's solutions on the .project and didn't work, go to Project -> Properties -> Project Nature and Add... Java, Apply and Close button.
Nothing above helped me. After hours of trying (shortly before crying) I imported the projects not by "Import from existing maven projects" but instead with "Projects from Git".
Everything is fine now. The Java Projects are Java Projects again!
Right click the project and click on the Properties --> Select Maven --> (In active maven profiles) give "pom.xml", Apply and close. enter image description here
Go to u r project folder and delete .settings
and rebuild the maven application
then try with running project
Good Luck

projects in workspace not showing up under project -> clean

Sometimes when launching eclipse my projects in my workspace do not show up in project -> clean. How can i fix this problem?
Things i have tried:
Closing projects and re-opening
deleting projects and re-importing
closing and re-launching eclipse
restarting computer
refreshing workspace and repeating any of those steps
Sometimes number 2 will work and sometimes it will not. This is a really annoying problem any assistance is greatly appreciated!
I have defined custom ant builds for all the projects. I unselected all the other builders besides my custom builder. Some projects are are showing up and some are not.
A project only shows up in the Clean dialog, if it has some kind of builder registered. You can check this by opening the project properties, and look for the Builders tab. If there are no builders, then it should not be visible.
If that is the problem, then you should try to identify at what point does your .project file in the project folder changed; that might give a hint about the culprit.
Closing eclipse and re-opening eclipse a few times solves the problem. It also seems that turning build automatically on and then closing eclipse and re-opening seems to help.
Eclipse... =)
Added the below lines between in <buildSpec> tag in .project file of the project and showed up in the clean. I am using eclipse Juno.
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
You must have the core builder in your .project file and the I believe the project nature setup or Eclipse will not show the project in the list of projects for the clean option from the file menu. That is the Project - clean that opens the clean dialog.
The project natures are used by Eclipse so that it knows what kind of project it is dealing with. I ran into the concept of project natures when I was trying to get a simple PERL project to run in Eclipse.
Here is an example that I used for Eclipse LUNA.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>my-war</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.common.project.facet.core</nature>
<nature>org.eclipse.wst.common.moduleCore.ModuleCoreNature</nature>
</natures>
</projectDescription>
I also found that for an angularjs project we were using Maven with, all that was needed was this under the buildSpec and natures for eclipse to see it as a project that could be cleaned:
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>

Import existing project

I created a Django project with just a text editor and the command line, now I have installed Aptana Studio but I cannot import that project. I can create a new django project, pydev is correctly installed and it works.
In Aptana, I tried Import Projects, but it doesnt recognize my project's root directory "No projects are found to import".
before replacing settings, models, views, etc,.. with the contents of my project (what I dont like), I want to ask:
Is there a better way to import the project??
You can find a more complete answer Here.
It's a bit dirty but you can do the following. Create two files in your project directory called .project and .pydevproject.
.project should contain:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>YOUR_PROJECT_NAME</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
and .pydevproject should contain:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>\PATH\TO\THE\PROJECT</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>\PATH\TO\EXTERNAL\SOURCES\IF\USED</path>
</pydev_pathproperty>
</pydev_project>
when you've got those two files in your project dir you can use Import>Existing Projects into Workspace
This question is answered on the PyDev FAQ page. "How do I import existing projects/sources into PyDev?"
The easiest way seems to go through the File > New > PyDev Project wizard in Eclipse and select as the directory the directory with your sources.
Vanja's answer solved my problem... :-)
How do I import existing projects/sources into PyDev?
If the project was already in Eclipse (i.e.: has the .project and .pydevproject files), use File > Import > Existing Projects into Workspace.
Now, if the project never had the .project nor .pydevproject files, there are 2 choices:
Option 1:
Just go through the File > New > PyDev Project wizard and select as the directory the directory with your sources.
Option 2:
Create the .project and .pydevproject files from the template below and use File > Import > Existing Projects into Workspace to import it. Note that this option is more a reference for people that want to automate creating multiple projects at once.
.project contents (must replace the MyProject with the project name)
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyProject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
.pydevproject contents (must replace the path (/MyProject/src) with the actual folders to be in the PYTHONPATH)
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/MyProject/src</path>
</pydev_pathproperty>
</pydev_project>
How do I import existing projects/sources for a Django project into PyDev?
Follow the same steps in the FAQ above to import a PyDev project, then right click the project > PyDev > Set as Django project and add 2 String substitution variables (on right click project > properties > PyDev PYTHONPATH)
DJANGO_MANAGE_LOCATION, which is the relative path to manage.py. i.e.: src/my_project/manage.py
DJANGO_SETTINGS_MODULE, which is the name of the settings module. i.e.: my_project.settings
Note that if the .pydevproject file was created, those values could already be added to it in the entry org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION:
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>src/my_project/manage.py</value>
<key>DJANGO_SETTINGS_MODULE</key>
<value>my_project.settings</value>
</pydev_variables_property>
If you are using the subclipse (svn) or egit (git) plugins, you may try to create a new project and checkout your code via the git/subclipse wizard. Might be less trouble than trying to import it.
For example, if using svn:
"File > New > Project..."
Select "Checkout Projects from SVN "
Choose or define your svn repository
On the last page of the "checkout from SVN dialog", select the radio "Open with New Project Wizard" Then follow the wizard steps there to create a project as whatever type you like (django perhaps).