Where can I obtain the maven-source-plugin? - eclipse

I checked out an open-source project from SourceForge's SVN source control using the Eclipse Maven plugin. After it checks out, I get this error in the pom.xml file:
Error resolving version for plugin
'org.apache.maven.plugins:maven-source-plugin' from the repositories
[local (C:\Documents and Settings\thomas.owens\.m2\repository),
central (http://repo1.maven.org/maven2)]: Plugin not found in any
plugin repository
I'm fairly new to Maven, but I followed the installation instructions for Apache Maven and the Eclipse plugin. It seems weird that this plugin would not be found in the central plugin repository for Maven or my local repository, when I can clearly see a directory located at C:\Documents and Settings\thomas.owens\.m2\repository\org\apache\maven\plugins\maven-source-plugin that contains a single resolver-status.properties file.
Any thoughts as to why this plugin might not be found and where I can find it?

The problem that I was encountering was not an issue with the maven-source-plugin, but incorrect proxy settings that was preventing the connection to the repositories. The answers to this question on the use of Maven with a proxy helped me to find the mistake and correct it.

That plugin is in the central repository.
Perhaps you just need to run with -U to update:
mvn -U clean install
Or in Eclipse: right-click on the project, select Maven-> Update Dependencies, (perhaps) Maven-> Update Project Configuration

Check if you are able to see Maven in Eclipse, Window > Preferences.
If so, select Maven and go to installations and check if the folder, in where maven was installed, is properly set. Then, set your setting.xml file, it should be in /(maven installation folder)/conf/
Then, right click in your project go to Maven > Update Maven Dependencies.
Did it help?

Which project?
Perhaps there is a bug in their pom.
Or perhaps they require a 'standardized' develop environment with specific environment variables set, or a specific setting in user.home/.m2/settings.xml

Related

How do I get my Eclipse-Maven project to automatically update its classpath when I change a dependency in my pom.xml file?

I’m using Eclipse Mars with Maven (v 3.3). When I update a dependency in my pom (change the version), my Eclipse-Maven project doesn’t pick it up, even when I right click my project, and select “Maven” -> “Update Project.” I know this because I do not see compilation errors in the Eclipse Java editor that I see when I build the project on the command line using
mvn clean install
When I remove the project from the workspace and re-import it, then things get back to normal. However this is a cumbersome process. How do I get my Maven-Eclipse project to automatically detect changes in my pom and update the project libraries appropriately?
And yes, in the “Project” menu, “Build Automatically” is checked.
When you import the project into Eclipse, use Eclipse's own built-in Maven support (aka, m2e). I recommend against using mvn eclipse:eclipse as it doesn't give the best results (as you're seeing). Maven is a build and dependency management tool, not an IDE; expecting it to manage IDE-specific stuff is silly, in my opinion (I realize the Maven team thinks differently, that Maven should be responsible for managing your IDE, but that's nonsense).
So if you have the project available on your system, delete any Eclipse-specific files (typically just .classpath, .project, and folder .settings), they were generated by mvn eclipse:eclipse and you don't want them interfering with the "proper" import process described here. Then inside Eclipse, use File > Import > Maven > Existing Maven Projects to import the project. That should result in better integration between Eclipse and maven, including automatically updating the Eclipse build path when the pom is changed.
As a quick check, after doing the import that way, you should see a group called Maven Dependencies in the Libraries tab of the project's Build Path (in Properties dialog). Like this:
If you want the Eclipse project configuration to be automatically updated every time the pom is changed, there's a (experimental) setting for that under Preferences > Maven. Be aware that doing so might not be desirable, though - as mentioned in this feature request, it's a somewhat lengthy process that touches a bunch of stuff in the Eclipse Project; doing that automatically on every pom.xml change could end up being more trouble than it's worth.
Three Mandatory checks you should do for automatic update in your classpath
Your Repository is not in-sync with your Eclipse IDE, Please check the below settings in your IDE.
Right Click your any POM.xml from your IDE and check for the Maven profile which should be auto-activated. Also offline and Force update check box shouldn't be enabled. Please refer the below image.
Always check for your user settings which should reflect your local maven settings.xml, as shown in the below figure.
After performing all these checks, refresh your Eclipse Work-space to get these changes reflected.
Eclipse should be updating your classpath. If it's not, that implies something is going wrong.
It's hard to say what the problem could be exactly without knowing more about your project's pom.xml. More information might be necessary to solve the issue, but I'll just make a stab in the dark:
Open the .project file in your project's root folder and check the ordering of builders and natures there. It might be possible that some other nature on the project is also causing maven2Nature to fail. Move maven nature up and see if that helps any.
Alternatively you might be thinking that Eclipse does not update your dependencies because it does not add some some error indicators in the project that should be there with new dependencies. If that's the case try cleaning the current project (project>clean...). Maven in Eclipse does not necessarily trigger a full rebuild when dependencies are updated.
If none of this works, closing/opening the project might solve the issue quicker than re-importing.
What you wrote, should work. Did you check this:
does "pure" mvn install from terminal see your changes in POM?
maybe some Maybe plugin is buggy, cached some dependencies in target, and mvn clean install is needed
you can run Eclipse in a new workspace, and import your project there, sometimes it helps in case of such strange problems
instead of importing Maven project to Eclipse via m2eclipse, you can try to create Eclipse files via the old mvn eclipse:eclipse and see what happens then
does it work well when you try to import your Maven project to other IDE, the free IntelliJ Community Edition for example?
As a last resort, you can delete your current Eclipse installation and install a new version. When you add several plugins, they might interfere with one another and create weird behavior. After you do that, do not import your Maven project into your workspace, but rather create a new one and copy and paste the files that you had.

Maven dependency issue in eclipse

I have multiple related projects open in a workspace in eclipse. One of the projects has a maven dependency on the output jar from another project. In this project, any references to the classes in the dependency always show up as red (unidentified) and I get no code completion or javadoc showing up for them. If I manually add the jar to the classpath, then I no longer have this problem. The thing is, I don't want to have to manually add the jar every time our revision changes, that's what Maven is for. Any ideas on how I can resolve this? it seems like a bug to me, but I'm not sure...
The correct way to do this is the following:
Make sure that m2e or m2eclipse (depending on your version of Eclipse) is installed: http://www.eclipse.org/m2e/
Use the dependencies section in the POM file exclusively, don't fiddle with the Eclipse project references. Right-click the project, then select Maven > Update Project Configuration to reset the project to the Maven default settings. This way, m2e has ownership of the dependencies.
If you don't have that option, you might need to enable the project for Maven usage. Right-click the project, then Maven > Enable Workspace Resolution or Maven > Enable Dependency Management.
Make sure all referenced projects are open in Eclipse and have the Maven nature enabled.
Check the Maven settings for each project, make sure that groupId, artifactId and version match with the projects you have open in Eclipse. So if the project you depend on has version 1.0.0-SNAPSHOT in Eclipse, make sure that the depending project's POM file references version 1.0.0-SNAPSHOT in the dependencies section.
Enable Workspace Resolution for each of the projects. Right-click the project, then Maven > Enable Workspace Resolution.
Finally, if the projects are still not resolved, right-click the project again, then Maven > Update Dependencies
This should solve your problem.
I had the same issue and resolved the problem by right-clicking on the project and selecting Maven -> Disable Workspace Resolution from the context menu. I had already tried updating the project from the POM file as described above.
In order to fix this typically you can copy the Eclipse .classpath file from a working project since there isn’t anything project specific here assuming you’re structured as a standard Maven project. This will tell Eclipse to allow Maven to manage the dependencies and build. There seems to be no easy way to do this from the Eclipse UI.

Why does Eclipse take so long to update Maven dependencies?

I have a Maven project in my Eclipse workspace. When I start Eclipse, it takes a very long time to update Maven dependencies. It actually seems like it will never finish and while it is doing this update, I can't do anything in Eclipse.
Can anybody help me?
If this happens on eclipse start, it is maybe not the dependecy update of your project but the Maven repository index update (as khmarbaise mentioned in his comment).
You can disable this here: Preferences → Maven → Download repository index updates on startup
A fresh index offers you an up to date list of dependencies, e.g. in the Add Dependency dialog. But I found it will do if the index is updated manually (as needed) in the Maven Repositories View.
Update: Since Eclipse Luna the index update is now disabled by default (see Bug404417).
First check all of your dependencies including plugins and children in the dependency tree,
try to replace snapshot versions with release versions,
as snapshot versions will always look for a later update, whereas
release versions are deemed to be stable and updates are not expected for the same version number.
Secondly, assuming that you are working on a LAN, I would suggest that you install a local maven repository manager such as Nexus, and then redirect your artifact requests by setting
<mirrorOf>*</mirrorOf> in your ${user.home}/.m2/settings.xml
This will enable your downloads to be resolved quickly against a local mirror, rather than continually checking against repositories on the internet.
Even i was facing updating maven dependencies on eclipse startup and eclipse hangup.
I found that my workspace directory do not have required permission(full permission). After i set those permission my issue got resolved.
Have you set Eclipse to use the local copy of Maven, rather than the built-in one? I've found that to be quicker. Also, make sure Eclipse is pointing to the local copy of your config file.
If it still takes a long time after trying all the other options, create a new workspace and move your projects to the new workspace.
If you use a proxy for connect, check in your settings.xml (D:\apache-maven-3.3.3\conf) if you have set correctly the user/password.
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>XXXX</username>
<password>XXXX</password>
<host>XXXX</host>
<port>8080</port>
<nonProxyHosts>XXXX</nonProxyHosts>
</proxy>
</proxies>
I have faced the same issue but I was using the sts. I tried to replace the snapshot versions with release versions and even also I changed the embedded maven of sts to my system installed but did not found any luck. I have updated my sts to the latest and boom it is no longer taking an infinite time to download
You have to put Maven offline then close eclipse, reopen eclipse and put maven online again.
To put maven offline : go to Preferences → Maven and check Offline

Eclipse m2eclipse getting dependencies from local repository

I have dependencies installed local on my machine (~/.m2/repository/blah/blah/blah) and m2eclipse is not recognizing them as there - I think m2eclipse is using its own maven instance. Is there any way to force m2eclipse to use the local maven installation in osx?
I had the same problem, and this is what worked for me. Using Eclipse Indigo:
Windows->Show View->Other
In the pop-up:
Maven->Maven Repositories
Once the view is displayed, right click on the appropriate repo, and select "Rebuild Index"
Wait a few seconds and done!
I have dependencies installed local on my machine (~/.m2/repository/blah/blah/blah) and m2eclipse is not recognizing them as there.
Do they have good metadata? How did you install them? Because m2eclipse definitely uses your local repository for dependency resolution.
I think m2eclipse is using its own maven instance. Is there any way to force m2eclipse to use the local maven installation in osx?
Yes, m2eclipse uses its own version of Maven by default and you can add an external installation via Window > Preferences > Maven > Installations but this won't change anything to the local repository used by one or the other that you can configure via Window > Preferences > Maven > User Settings as shown below:
alt text http://www.imagebanana.com/img/w5y2vevt/screenshot_008.png
This send us back to the questions above: how did you "install" the problematic dependencies?
You can change the used Maven instance in Windows->Preferences->Maven->Installations. But I'm not sure whether this will help as a comment below that setting says that dependency resolution will still be done with the internal Maven installation.
If I were you, I would try to add that local repository to the list of known repositories. Use Window->Show View->Maven repositories (this is sadly not visible in the preferences).
Check that the jar was installed properly. Maven does not give an error when you provide an incorrect path to the jar when installing to local repository. The jgravatar.jar was not in my ~ directory when I ran the command below.
mvn install:install-file -Dfile=~/jgravatar.jar -DgroupId=jgravatar -DartifactId=jgravatar -Dversion=06292012 -Dpackaging=jar
[INFO] Installing /Users/steve/~/jgravatar.jar to /Users/steve/.m2/repository/jgravatar/jgravatar/06292012/jgravatar-06292012.jar
[INFO] Installing /var/folders/gz/gjyqtkzj3ys8lpmh_38qvmn00000gq/T/mvninstall2662938607942511865.pom to /Users/steve/.m2/repository/jgravatar/jgravatar/06292012/jgravatar-06292012.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I was getting the exact same issue. I added the JARs to the local repository via the install-file command. I verified they were installed. I rebuilt the index. I went to the directory and inspected the JAR file using 7Zip, but I could not get it to appear in the Maven Dependencies inside of my eclipse project.
For me the solution was pretty silly. When I added the dependency into the pom.xml using the dependencies editor, Maven threw in a packaging stanza into the XML. So the XML entry looked like:
<dependency>
<groupId>slf4j</groupId>
<artifactId>jdk14</artifactId>
<version>1.5.8</version>
<type>JAR</type>
</dependency>
When I removed the last stanza "JAR" and made the entry:
<dependency>
<groupId>slf4j</groupId>
<artifactId>jdk14</artifactId>
<version>1.5.8</version>
</dependency>
it all worked fine.

m2eclipse not finding maven dependencies, artifacts not found

I'm using m2eclipse as my maven 2 plugin for eclipse. I'm brand new to maven, so my mistake might be simple, although searching has not yielded any solutions for me. I can run maven from the command line and it build successfully. However if I import as an existing maven project, or use mvn eclipse:eclipse and then import I get the artifacts not found in my POM file resulting in no maven dependencies being loaded at all.
What's odd is that I have 2 projects, both children to a parent pom packaged project. One child loads all my maven dependencies while the other cannot find any and says my pom file is missing artifacts. Again, I can install and package them all just fine from the command line.
I even tried loading my projects into netbeans which worked flawlessly, however I am required to use eclipse.
Any ideas on how to fix this?
Update
Directory structure, pom files layout:
--main
--pom.xml (is a pom package that is the parent to two other projects)
--ProjectA
--pom.xml
--ProjectB
--pom.xml
Main is the parent project of both ProjectA and ProjectB. ProjectB has ProjectA as a dependency. Apprently m2eclipse is not happy about that depedency. As soon as I remove the dependency of ProjectA from ProjectB's pom file all the maven dependencies are found by eclipse.
- com.company.myproj:app:6.6.0:jar Missing: ---------- 1) com.company.myproj:main:pom:${myproj.version} ---------- 1 required artifact is missing. for artifact: com.company.myproj:main:pom:$
{myproj.version} from the specified remote repositories: apache-incubating (http://people.apache.org/repo/m2-incubating-repository/, releases=true, snapshots=true), central (http://
repo1.maven.org/maven2, releases=true, snapshots=false)
However, I still need ProjectB to have that dependency for ProjectA. The error message seems to be m2eclipse looking for ProjectA in a remote repo. Project A should only be in .m2 directory, but I'm not sure how to tell m2eclipse to look there.
I think this may be just a m2eclipse specific issue because using mvn from the command line works fine and like I said previously, netbeans loads the projects and dependencies just fine.
I had this issue for dependencies that were created in other projects. Downloaded thirdparty dependencies showed up fine in the build path, but not a library that I had created.
SOLUTION: In the project that is not building correctly, right-click on the project and choose Properties, and then Maven. Uncheck the box labeled "Resolve dependencies from Workspace projects", hit Apply, and then OK. Right-click again on your project and do a Maven->Update Snapshots (or Update Dependencies) and your errors should go away when your project rebuilds (automatically if you have auto-build enabled).
It sounds like your m2eclipse install is using the embedded Maven, which has its own repository (located under user home) and settings.
If you open up the Maven preferences (Window->Preferences->Maven->Installations, you can add your Maven installation by selecting Add... then browsing to the M2_HOME directory.
(source: sonatype.com)
For more details see the m2eclipse book
For me maven was downloading the dependency but was unable to add it to the classpath. I saw my .classpath of the project,it didnt have any maven-related entry. When I added
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
the issue got resolved for me.
One of the reason I found was why it doesn't find a jar from repository might be because the .pom file for that particular jar might be missing or corrupt. Just correct it and try to load from local repository.
Okay I fixed this thing. Had to first convert the projects to Maven Projects, then remove them from the Eclipse workspace, and then re-import them.
I had problems with using m2eclipse (i.e. it did not appear to be installed at all) but I develop a project using IAM - maven plugin for eclipse supported by Eclipse Foundation (or hosted or something like that).
I had sometimes problems as sometimes some strange error appeared for project (it couldn't move something) but simple command (run from eclipse as task or from console) + refresh (F5) solved all problems:
mvn clean
However please note that I created project in eclipse. However I modified pom.xml by hand.
This could be a problem if you are using a custom 'Settings.xml', with a different <localRepository> configured in it.
Eclipse will be using the default installation of MAVEN, and will be using the default location for the User to look for the local Maven repository, which on Linux systems would be '/home/${USER}/.m2/'
Eclipse can be easily configured to use the customized 'Settings.xml', by doing the following:
Goto -> Window -> Preferences -> Select 'Maven' -> Select 'User Settings'
Under 'User Settings', select the custom 'Settings.xml' file, for 'User Settings' by clicking 'Browse' and selecting the customized 'Settings.xml'.
Click on 'Update Settings', if the 'Local Repository' Textbox does not show the custom location from the file above, just key in the location and click 'Reindex'.
Click 'OK'
After this, you could proceed to select your project from the 'Project Explorer', right click, Select 'Maven' > 'Update Project'. Make sure that your project is selected (ticked) in the Window, and click 'OK'.
This should help to resolve the issue, if using custom 'Settings.xml' for Maven.
Hope it helps.