Automatically update a maven project under eclipse, after a svn-checkout - eclipse

After checking out a maven project from a svn-repository, eclipse shows dependency-errors.
To solve the problem,
I have to right-click on the project-folder,
then I have to click Maven --> Update Project
After doing that, the dependendicies of the pom-file are downloaded and the specific classpathes are set.
The problem: I have to do this everytime after a checkout of a maven-project.
My question: Why should I have to update manually the maven-project? Why didnĀ“t do this the maven-builder automatically? Is there any way to engage eclipse or the maven-builder to do this automatically?

If you have Subversive (installable via the Marketplace), you can checkout and set up the project in one step from Eclipse. In the dialog File -> Import try the entry Maven -> Check out Maven Projects from SVN.
Unfortunately, maven project configurations tend to get stale when you're changing stuff in the POM. Another tip from me is use the keyboard shortcut for "Update Project" (Alt-F5 on Mac & Windows) which should select the project you're currently in and has the option to update all projects at once.

Related

Automatically generate .factorypath on project import when using Maven project in Eclipse IDE

The .factorypath file is a generated file, which eclipse requires for annotation-processing. The m2eclipse plugin does generate this file when using "Update Maven Project" (Alt+F5) and checking "Update project configuration from pom.xml".
However, I don't want to check this file into version control. But if not, and someone from the team does a fresh checkout, and imports the project in eclipse, the .factorypath does not get generated until the "Update Maven Project" is performed manually. I don't want this manual step when a project gets imported, this has to happen automatically. Is there an option, that a project has to be updated upon import?
Since this is an IDE related question, and you seem to be using Eclipse IDE:
Menu Window > Preferences > Maven > Automatically update Maven projects configuration .
This will make it for you on project import so you would not need that manual step anymore.
Assuming your real issue is
I don't want to check this file into version control.
Though you have not specified which version control you are using but if you are a GIT or SVN user, you need to add files/directories pattern in GIT ignore file or SVN ignore properties.
Read more on GIT Ignore or SVN Ignore.

Subclipse checking out as folder not Java project

I'm trying to import a Java project from my teams subversion repository. So I go through the import GUI for subversion, select my repository and the project, then choose to check it out as a project into the workspace.
However, the project now appears in my workspace simply as a folder:
Trying to add a new class tells me "source folder is not a java project". Is there something I am missing? Thanks.
Check out as a project only does what you want if you have checked-in the Eclipse .project, .classpath files etc. In that scenario those files get checked out and configure the Eclipse project. Otherwise you are just getting an Eclipse "Simple Project" which does not have the Java tools configured.
I assume you do not have those Eclipse files in your repository, so you want to use the other option that lets you run the Eclipse Create Project wizard as part of the checkout. This lets you choose the project type and setup some of the configuration. You can skip most of the configuration since you can also do that after the checkout finishes if you prefer.
See: Subclipse Checkout Documentation

Eclipse Maven Projects False Error

I have a parent Maven project that consists of several other projects. When i am building the project in command line everything is fine.
Then i open my Eclipse and the workspace is full of errors (which are actually false positives).
In order for me to get rid of this errors i have to do a "Run As... -> Maven install" and then a "Maven -> Update project..." on every project from within eclipse.
Is there any way or any plugin that can actually refresh the workspace and update the maven dependencies on each project, so that i can avoid this tedious operation?
Does anyone else face the same problem when using Eclipse as an IDE for his/her maven projects?
UPDATE
It seems (as in most of the cases with eclipse) that the problem was with the M2E plugin. Somehow the plugin was picking some settings in the .metadata folder in my workspace. I deleted the contents of the folder, restarted eclipse, re imported everythings and now it seems to behave as expected.
Hopefully, in newer version Eclipse will support Maven in a proper manner.
It could be that some of the files are just out of date. When I get this I do a refresh of the affected projects and then clean the workspace (Project -> Clean...) cleaning all projects.
If the refresh and clean don't do the trick, then I'd suspect that your maven settings in Eclipse point to a different set of repositories than does the command line maven's settings.xml. Go into the maven property page in Eclipse preferences and confirm that you're using the same settings.xml (re-select just to be sure).

How to checkout maven project from svn repository

I am new to Maven and Eclipse, I need to check out an existing Maven project from a SVN repository. I have installed the M2E plugin and the subversion plugin and they seem to be working properly. Here are the Installation Details -->
When I right click in the project explorer and select Import -> SVN -> Project from SVN, then select the repository location and click finish, I am prompted with 4 possibilities
What is the procedure for checking out a Maven Project from this point on, or am I on the right track here?
Thanks for your help in advance!
tl;dr : Check out this video. The portion between 1:04 and 1:50 should answer your question (To skip to the interesting part, click on the youtube player and press 4).
You already have the SVN connector for m2e installed. Thus it should be possible to Import Existing Maven Project from the SVN repository.
From the options you have listed in the above snapshot, you should be able to proceed after selecting the First or the Fourth option i.e. :
(according to Mauno V's suggestion below) To convert this imported project into a Maven project Right Click on it and do a Configure -> Convert to a Maven Project like so :
If you have Pom project as a root branch, after project checkout completed, you may do it with import project as 'Existing Maven Project' and set the project as root project, and finish!
you should be able to see your module define as project in eclipse project explore, and eclipse will recognized as module project.
do right-click on Pom project, Maven -> Update Project or Alt+f5 to refresh and see the content project.

Searching for dependencies returns nothing

I've just installed Eclipse Juno with m2e installed.
Then, I've created a new Maven project and decided I want log4j, so I opened the pom.xml, clicked on the Dependency tab, clicked on the Add... button and typed in log4j.
Zero results. The only thing that it finds is junit (that was automatically added to the project with the quickstart archetype, it seems). Note that I can add the log4j dependency manually and it will work just fine, but I find the search feature really convenient!
I'm a kind of a Maven beginner, though I got m2e working no problem in Indigo. So I'm thinking I might have forgot to set something?
All you have to do is update or rebuild your workspace maven repository index.
Open your "Maven Repositories" view. Open Global Repositories and right-click on central. Enable full index and rebuild.
Initially the process will take several minutes. After that your search will start working.
You can automate this process by turning Download repository index updates on startup on in your workspace preferences under Maven
in case rebuilding your workspace maven repository index didn't work, try reinstalling m2e. I updated mine via marketplace and it started working again. I'm not sure what was the issue but I suspect some URLs got changed recently.
Just go to Window -> Preferences -> Maven
and check the option Download repository index updates on startup and click Apply. That's all.