In eclipse Mars, I could always clone a git repository and then import it as a maven project. But this time, the pom.xml is greyed out. On the next screen only the pom of another project is showing and I can't proceed.
Are you sure you have not already imported the project into the workspace? Maybe you just don't see it. One reason can be that you are using working sets and the project is not in the group you'd expect it to be in?
If the project is already imported into your workspace, and you are trying to import another copy of the same project that resides in a different folder, you can try adding some string for Name Template under Advanced and the importing.
Related
I have been desperately trying to import a multimodule maven project from GIT into my (freshly installed) STS 3.9.4.
During the last hours I tried lots of solutions that were posted on stack overflow, but none of them worked for me.
These are the steps I did:
git cloned the repo from the command line (intentionally, because it didn't work either when I used the GIT integration of STS)
imported the project via File / Import / Maven / Existing Maven Projects
After the project was imported, it looks like this:
(please ignore the red icon at the top left, the problems persists even when this icon is not there)
I can Run As / Maven Install any pom.xml, but when I try to edit java sourcecode Eclipse tells me The resource is not on the build path of a Java project.
To fix this I tried:
convert to faceted form
added Java nature
Configure Build Path / Set as source folder
add buildcommand org.eclipse.jdt.core.javabuilder to .project
Being able to build is fine, but editing sourcecode without support for Organize Imports, Format Source, and so on is a real pain.
From your screenshot I assume the modules are nested within the directory of the reactor pom(=parent pom) and you have imported all of them as projects (reactor and modules).
Don't add a java builder to the "reactor" project.
Make sure not to open the java files from the projects corresponding to the reactor pom, but from src folder within the corresponding module projects.
The solution to this problem was somehow hidden, but in the end I have to say the reason was clear.
After I checked with a different multimodule project (https://github.com/Activiti/Activiti.git), I was sure that my STS and other components don't suffer from a generic problem. So the cause must be located in the project itself.
The multimodule project was setup correctly on the pom.xml level. But the topmost pom.xml was modified: most of the modules had been commented out:
The developer who introduced that change didn't experience any problems because he kept his already existing workspace. And the problem only occurs when a new workspace gets created and maven scans the pom files.
I have a maven project, and i'm surprised that .project and .externalToolsBuilder are under svn.
Someone explain to me that its because we need to create a builder automaticaly when developer's import project under eclipse.
Does it possible to add in pom.xml all that i need to create this builder when project is imported into eclipse wihout need to commit .project file?
Because i want to have a clean directory without .project/.classpath etc... before import my project and i don't want this file under svn
thanks a lot.
The answer to your question is clearly "yes". It is possible to set up Eclipse from a pom.xml file and have Eclipse generate the files it needs from there.
Yes, you can generate the .project file, but not the files in the .externalToolBuilders folder. And if you have custom builders those should be added with <additionalBuildcommands>. See eclipse maven plugin.
So, the .project file shouldn't sit in svn, .externalToolBuilders. You can generate those too, as you can see in the eclipse maven plugin, but the content still has to be somewhere (your pom, a server etc).
I am trying to import a maven project (import->existing maven project) into eclipse and it is showing up in eclipse using the generic java project structure as opposed to the maven one. I have tried several versions of the m2e connection and all have the same problem. So for example instead of the following folders/packages/files I have:
src/
main.java.my.package.name
myfile.java
test.java.my.package.name
testfile.java
etc.
instead of the maven project structure
src/main/java
my.package.name
myfile.java
etc.
Any assistance appreciated, thanks!
For the sake of completeness:
This happens sometimes due to a race condition in eclipse.
As you already found out: if it happens, it happens only once, on initial import. So your way was almost correct:
Remove all source paths
do not add them manually
instead, right-click on the project and select "Maven -> Update project" and accept the default settings. Now the source paths will be set correctly
Woops, right after posting I was able to get it to work.
I had to go to project -> build path -> Source and remove the src/ folder and add the src/main/java, src/main/resources, etc. folders and it all works now.
Thanks for looking y'all!
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.
I have this simple question how to import whole project source into Ecplise so I can browse it easily? Specifically, I have downloaded Maven source code http://maven.apache.org/download.html and I just want to view it same as other projects in my Eclipse.
I've tried to import it with use of two possible options (as archive and as a project) without luck.
Thank you in advance!
Maven itself is a Mavenized multi-module project, Generally there are two ways to import a Mavenized project into a IDE like eclipse:
Pre-requirment:
Suppose you have installed Maven 3 and setup environment variable
properly.
if you use Eclipse, you also need add M2_REPO to you
Build Path -- Classpath Variable, check out here for how to
setup. this tells Eclipse where to find jar dependencies stored in
local maven repository.
Option 1 -- Import as Java Project:
Open a command prompt and go to the extracted source folder, run mvn eclipse:eclipse
and waiting for it finish, make sure it doesn't popup any message start with [ERROR], this
will download all required jar dependencies from internet to you
local maven repository and create .project and .classpath for Eclipse
to use when doing import.
In eclipse, go to File -- Import -- General -- Existing Project into
Workspace, select the extracted source folder as root directory. This
will import a group of projects into Eclipse as bunch of regular java
projects (i.e. project icon inside Package Explorer watermarked with a
capital J).
Option 2 -- Import as Maven Project:
Alternatively, if yo got m2e plugin installed in Eclipse, you can
directly import the extracted project folder, go to File -- Import --
Maven -- Existing Maven Projects, select the extracted source folder
as Root Directory. This will import a group of projects into Eclipse
as bunch of Maven projects (project icon inside Package Explorer
watermarked with a Capital M).
Hope this helps.
The maven repository versions are not uploaded in the exact format they are on disc (from where the the mvn deploy goal is run. I can think of 3 options assuming I understand your question correctly:
You can find the open source project if it exists and get all the
source and project from there.
On an existing project, you go the dependencies, right click on one
and select browse source. Not the same as having the show project
here you can build and run however.
You can download the sources from the maven repo and then
reconstruct the project. I'm not not sure how feasible this
actually is and I have never tried it. I would probably find other
ways before trying this.