Eclipse "Maven repository viewer" doesn't list packages in local/global repo - eclipse

My environment is pre-setting on a costumed maven proxy as global repo. And in my Eclipse (Spring tools suite4), when I open the "maven repository" view from "Window"->"Preferences", the view shows a path to the local repo without any package listed, the situation is the same under "Global repositories". How could I view the details of a repo "maven repository" view? or is there any GUI which can make the repo browsing possible? I wanna check the highest version of some packages in the repo.

Related

How to move Eclipse project from one Github repo to another?

I am new to github. I cloned my github repo to eclipse using EGit.
Now, I have two repo in my Eclipse.
I added my Java Eclipse project to the old repo. I would like to added my Java Eclipse project to new repo. How could I move my Eclipse project from one repo to another?
From eclipse, you can right click on a project and select the Team > Disconnect menu option to disassociate the project with the old git repository. Then right click the project again and select the Team > Share Project option. From the 'Configure Git Repository' dialog, you may need to uncheck the "Use or create repository in parent folder of project" check box. You will then be able to select the location of the git repository you want to associate with the project.

Why are there different types of "Team" menus with EGit?

What dictates which type of team menu shows up for my project? Is there a way to switch between the two?
very traditional git-ish (ie. without "Synchorize Workspace" option)
eclipse team-ish (eg. with "Synchroize Workspace" option)
Update
My git repositories view shows the following:
Using the following steps I have enabled the "Team" features for my project:
delete project in Eclipse
delete project on filesystem (including .git/ repository data)
clone project into filesystem
add local repo to "Git Repositories" Eclipse view
in Eclipse, invoke an "Import Projects..." on the newly added repository, and "Import as general project"
The second menu should be in effect when you have:
Configured Upstream fetch
Configured Push to Upstream
That is when your local repo knows what to fetch from or push to your remote repo.

maven - inter workspace dependencies

i am using eclipse and maven integration.
maven install puts the resources to the local repositories. local repositories is divided into "local repository" and "workspace projects" as shown in eclipse view "Maven Repositories".
The resource is unvailable to be linked by other projects of a different workspace. is there a way having "maven install" to put shnapshots to the "top" local repository available for any project?
or do i missunterstand the concept?
Workspace projects is a just a convenience feature provided by the m2e plugin where it resolves the dependencies to projects in the current workspace if the artifact specification (group id, artifact id and version) matches that of a project in the workspace. If there are no matches, m2e just uses the jar in the .m2/repo folder as the dependency.
The benefit of this feature is that you don't have to maven build and install the dependency projects continuously, your code changes are reflected immediately in the dependent project.
However, this is just a convenience feature and you can always do a maven install in a dependency project and refresh the dependent project to get the change reflected there.
TL;DR just do a usual maven install on your dependency project and refresh any workspace. It should work.

Importing multiple maven projects from git into eclipse

I've got a git repository with two Maven projects "foo" and "bar". The structure of the cloned repo is as follows:
myrepo
.git
foo
pom.xml
bar
pom.xml
What I want
Two projects "foo" and "bar" in my workspace with maven nature and working Team menu.
I'm running Eclipse 3.7 with m2e 1.0.0.
I tried the following:
Import -> Check out maven projects from SCM
This clones the repo into a new folder in my workspace folder and imports the two projects, but without connection to git (Team menu is mostly empty).
Import -> Projects from Git
With this option I can only import the entire repo as a single general project (with working Team menu). If I then use "Import -> Existing maven projects", the projects foo and bar are imported but without working Team menu.
Is it possible at all to import multiple projects from a git repo with working Team menus?
As far as I know and are able to perform on my setup (Eclipse 3.7, Egit 1.0.0, m2e 1.0, m2e-egit 0.13), it is not possible in a single step.
The cleanest procedure that I know of is the following:
Clone your Git repository (preferably from Eclipse, otherwise you also need to add the repository to the Git Repositories view);
Import -> Check out existing Maven projects from the root folder of your cloned repo;
Select all the resulting Eclipse projects, and choose Team -> Share project;
Now select Git and check Use or create Repository in parent folder of project.
Long-winded? Sure. But cloning beforehand gives you control over the folder name you check out to, in contrast to Check out Maven projects from SCM which on my machine produces a "maven_{unix_timestamp}" like folder name.
I agree wholeheartedly with you that a quicker procedure should be available.
Here are the steps I used (using eclipse helios, egit and maven plugins)
From git repo perspective, clone your repo (I'm pulling in
git://git.springsource.org/spring-security/spring-security.git for
example)
Use "Import -> Projects from Git" to import as single
general project.
On this project use "Import -> Existing Maven
project" to import separate subprojects.
On each new project, go to "Team -> Share Project ->
Git".
If desired, remove the original project imported in step 2 above. Just remove from workspace, don't remove disk contents.
Create Clone of your Git repository. This can be done by choosing option of clone in'Git Repo Perspective' in eclipse. It will create a local repository in your system. I used bitbucket (GIT) to host my code. It will create a repository with the same name as you have given while creating the repository at your host. At this point of time an empty repository will be created since I have not put anything at host as of now.
Now copy your multimodule Maven project to the local repository which is created in step 1.
Go to eclipse, now click on import --> Projects from GIT -->Existing local Repository -->select your local repository --> import existing projects and we are done.
You will see '?' on your modules. Now select all the projects --> Team -->share projects-->Add index. You will see '+' sign. Now commit and push your changes.
In my case, I have not created the repository at host before hand. I created it through eclipse by pushing the code from my local to host. Vice versa can be done by cloning. If your code is already present at the host, cloning will fetch the code and save it in your local repository and similar steps can be executed to import project into eclipse workspace.

Importing a Maven project into Eclipse from Git

How can I get the effect of choosing to import from both Maven and Git and have Eclipse properly generate my project?
To get my project into Eclipse I can choose File->import->maven and then I get all the Maven projects imported and can build fine, or I can choose File->import->git and make a new project that ignores the pom.xml and does not generate the project properly.
It seems I can do one or the other but not combine both so I get a correctly generated project.
Eclipse Indigo + M2Eclipse 1.0 makes it very easy.
If you don't already have the Git connector for M2Eclipse install it. M2Eclipse will help you along by prompting you on the Import menu.
Select the "Import..." context menu from the Package Explorer view
Select "Check out Maven projects from SCM" option under the Maven category
On the window that is presented choose the link "Find more SCM connectors in the m2e Marketplace
Find connector for Git...install...restart
Note that in the search box you may have to enter "EGit" instead of "Git" to find the right connector.
With that done, simply go to the EGit repository, bring up the context menu for the Working directory and select "Import Maven projects...".
Done!
I would perform a git clone via the command line (outside Eclipse) then use File -> Import... -> Existing Maven Projects.
Your projects will be understood as using Git and Maven. It's the fastest and most reliable way to import IMO.
Step 1 : Setting Up Eclipse
First of all you'll need to have a few Eclipse plug-ins installed. So use eclipse IDE software install feature in the help dropdown menu → Install new software, and add link to Available Software Site, then install it.
GIT plugin (EGIT)- http://download.eclipse.org/egit/updates
Eclipse Maven plugin (M2Eclipse) - http://download.eclipse.org/technology/m2e/releases
Maven SCM Handler for EGit (m2e-egit)
Install from the M2E Marketplace (Settings → Maven → Discovery → Open Catalog and search for " m2e-egit")
Step 2 : Clone the repository
Clone(download) your Maven Projects from Git
Check out non-eclipse Maven Projects from Git (File → Import.. → Maven → Check out Maven Projects from SCM)
Now add your git repository link to SCM URI field.Then click next & finish.
As of this (updated) writing, a working setup is the following:
Eclipse 3.8 (Eclipse Indigo update site)
EGit 1.3.0 (Eclipse Indigo update site)
m2e 1.0.200 (Eclipse Indigo update site)
m2e-egit 0.14.0 (m2e marketplace when adding a connector)
Tested on Ubuntu Raring.
You can certainly "Import" -> "Maven" -> "Check out Maven Projects from SCM", and this is the quickest way. However, such direct import currently does not give you control over the cloned repository folder name. You may be better off working from the "Git Repository" View and perform either a "Clone from a Git Repository and add the clone to this view", followed by an "Import Maven Projects" from such clone; the longest way would be to do your manual cloning and then "Add an existing local Git Repository to this view", followed again by an "Import Maven Projects". Either case you have full control on the cloned folder.
A final comment on a side issue that made me cry in frustration. As far as I know, if the cloned repository lies on the root of your Eclipse workspace, and your Maven project file hierarchy has a POM on its root, then importing such root project will rename the cloned folder (with the template you chose, defaults to [artifactId]). Without changing your project structure and without keeping files outside your workspace, you can easily work around this issue by cloning on a subsubfolder of the workspace folder.
I have been testing this out for my project.
Eclispe Indigo
"Help > Install New Software" Enable/Install official Git plug-ins at "Eclipse Git Plugin .." and install the lot.
Enable the Maven/EGit connector with these instructions How do you get git integration working with m2eclipse?
Switch to the Git Repository perspective. Right click paste the project git url. The defaults should all work. You may want to change the install folder it guesses.
Expand the cloned repository and right click on "Working Tree" and pick "Import Maven Projects...".
Switch to the Java perspective. Right click on the project and choose "Team > Share Project". Select "Git" and be sure to tick the box "Use or create repository in parent folder of project".
Here's my workaround, this is a solution to these issues:
You can't install m2e-egit (I get an error in Juno)
Converting a general project (connected to your Git repository) to a Maven project isn't working for you (The Import Maven Projects step seems essential)
Importing Maven Projects from your repository on the filesystem isn't showing the project connected to Git.
Setup your Git repository in the Git Repository Exploring perspective.
Switch to the Java perspective, Import > Existing Maven Projects
Browse to your Git checkout in the filesystem, select the directory containing the pom.xml file. Finish the import;
you'll notice these projects aren't connected to Git. :-(
Delete these projects, but DO NOT DELETE FROM FILESYSTEM.
We don't want our clone deleted; this task also leaves the .project file behind so that we can import in the next step.
Go back to the Git Repository Exploring perspective.
Right-click your repository, Import Projects...
Select Import existing projects
In the explorer below, browse to and select the directory containing the pom.xml (and .project file) , then click next.
Continue through the wizard.
Import without installing any additional connectors for Mylyn:
Open Git Repositories view (Window->Show view->Git Repositories)
Press Clone a Git Repository button and proceed with all steps
In newly created repository expand Working Directory, right click on folder with your project and select Import Projects. Then either choose Import existing projects, or select Import as general project. If needed after importing right click on your project and select Configure->Convert to Maven Project (and Maven->Update Project).
You should note that putting generated metadata under version control (let it be git or any other scm), is not a very good idea if there are more than one developer working on the codebase. Two developers may have a totally different project or classpath setup. Just as a heads up in case you intends to share the code at some time...
I have a maven project with three submodules that is managed in git. I set them up in eclipse as follows:
I registered the git repository with eclipse using EGit
I imported the projects as existing Maven Projects
For each project, I went Team | Share Project.
Direct answer: Go to Files>>Import>>Git>>Project From Git (you should have GIT installed on Eclips)
I would prefer to import projects into Eclipse as maven projects rather than git project. Doing this will still allow the project contents to be recognized as git contents. You can continue to perform git operations from Eclipse. As you have mentioned the reverse is not true.
The nature of a project in Eclipse is not based on the SCM which holds the project, but on the type of project - whether war or jar, etc. - which is automagically determined when the project is imported as maven project.
I would be hesitant to check-in to SCM IDE-specific metadata. Doing so assumes a lot of things - all developers are using the same IDE or version of the IDE, perhaps same version of JDK/JRE, that they continue to use the same version throughout the project lifecycle and so on.
Can't you import it as a git project and then (if you have the m2eclipse installed) right click on the project in the Package Explorer > Maven > Enable Dependency Management?
After checking out my branch in Egit, I switched to the Java View, then used File-->Import, Git-->Projects from Git, then selected the top level maven directory. This was with Eclipse Kepler.
Instead of constantly generating project metadata via import->maven command, you can generate your project metadata once and the place it in your git repository along with the rest of your source code. After than, using import->git command will import a proper maven-enabled project, assuming you have maven tools installed.
Make sure to place into the source control system all files in project dir that start with '.' such as .classpath and .project along with the entire contents of the .settings directory.