I installed maven plugin for eclipse and was able to use it only in eclipse. I want to be able to run maven commands from terminal so installed maven as explained in the below link:
http://www.mkyong.com/maven/how-to-install-maven-in-ubuntu/
My questions are
I could not find settings.xml in this path /home/raki/.m2/ -- What should I do for this?
Does the maven installed in the above step affects the maven installed in eclipse? These two mavens work independently or how is that?
settings.xml is not required (and thus not autocreated in ~/.m2 folder) unless you want to change the default settings.
Standalone maven and the maven in eclipse will use the same local repository (~/.m2 folder). This means if some artifacts/dependencies are downloaded by standalone maven, it will not be again downloaded by maven in eclipse.
Based on the version of Eclipse that you use, you may have different maven version in eclipse compared to the standalone. It should not matter in most cases.
Installation of Maven doesn't create the settings.xml file. You have to create it on your own. Just put it in your .m2 directory where you expected it, see http://maven.apache.org/settings.html for reference. The m2eclipse plugin will use the same settings file as the command line.
The settings.xml file is not created by itself, you need to manually create it. Here is a sample:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
As per the maven's documentation, there are two possible settings.xml locations
One is the global maven's repo (Your initial download and subsequent unzipped files from apache maven) $M2_HOME/conf/settings.xml
And the second is the user created one (Your local copy) ${user.home}/.m2/settings.xml
The local copy takes precedence over the global copy in terms of settings information. But it is said that they both get merged during "runtime". If you need to have your local copy of the settings.xml, simply copy from the global copy and paste in your .m2 folder and adjust the details as needed
I also underwent the same issue as Maven doesn't create the settings.xml file under .m2 folder. What I did was the following and it works smoothly without any issues.
Go to the location where you maven was unzipped.
Direct to following path,
\apache-maven-3.0.4\conf\ and copy the settings.xml file and paste it inside your .m2 folder.
Now create a maven project.
You can verify where your Setting.xml is by pressing shortcut Ctrl+3, you will see Quick Access on top right side of Eclipse, then search setting.xml in searchbox. If you got setting.xml it will show up in search. Click that, and it will open the window showing directory path wherever it is stored. Your Maven Global Settings should be as such:
Global Setting
C:\maven\apache-maven-3.5.0\conf\settings.xml
User Setting
%userprofile%\\.m2\setting.xml
You can use global setting usually and leave the second option user setting untouched. Store your setting.xml in Global Setting
By Installing Maven you can not expect the settings.xml in your .m2 folder(If may be hidden folder, to unhide just press Ctrl+h). You need to place the file explicitly at that location.
After placing the file maven plugin for eclipse will start using that file too.
Related
I'm using m2e in eclipse v2020-12. I created a settings.xml file in D:\.m2repo with <localRepository>D:/.m2repo/repository</localRepository>. In eclipse preferences, under Maven, Global Settings, I browsed to that file then clicked Update Settings. After closing eclipse, I moved m2e's repo from the default folder C:\Users\<user>\.m2 to D:\ (it's 30GB and I needed space on C).
Some parts of eclipse recognize the change. Maven user settings shows the new local repo folder and Java classpath variables under build path settings shows MT_REPO (non modifiable) - D:\.m2repo\repository.
However, m2e is still (stubbornly) creating some files in the default folder on C. The most relevant info I could find was a hint of another global settings file in the error message of this 2017 unanswered SO question:
[DEBUG] Reading global settings from EMBEDDED\conf\settings.xml
EDIT:
Found maven doc here saying that user settings are "dominant" over global settings. So, I tried the above with the same settings file under Maven, User Settings... same result.
Like you said: unanswered!
I got it under control (empty/no writes to ~/.m2/repository) after:
Using (in m2e) a "standalone" maven installation. (It's global config location is definitely ${maven.home}/conf/settings.xml) [1]*
(Leaving global config untouched,) Having consistent ~/.m2/settings.xml pointing to <localRepository>D:/...</localRepository>.
"Restoring Defaults" or providing consistent m2e "user (& global) settings".
And to be safe: Re-start your workspace! and even safer: the jvm! ;)
*: m2e's embedded maven has more bugs & limitations... (to prove)
I'm trying to have the projects within my workspace to reference each other directly, instead of the jar files from the maven repo. That used to work perfectly fine when having all the projects in the same folder (eclipse workspace) and using mvn install and mvn eclipse:eclipse. However, now it's not working and I believe it's due to the fact that the projects are not located in the workspace folder, but in my local GIT repo, from where I import them into Eclipse. I assume that I need to set some variable somewhere, but couldn't find anything on this on the interwebs. I've also tried using the eclipse maven plugin, but I got into other problems that completely broke my setup. Using -Declipse.useProjectReferences=true doesn't help either. I'm grateful for any hint!
I suddenly began having this problem after a reboot (??).
What worked for me was:
on my project's context menu, open "Properties"
Java Build Path tab: add the projects which need to be referenced
Order and Export tab: move these projects to the top of the list
There's a setting on each Project to control this behavior. Right-click to open the project Properties, then select the Maven section; there you'll find the option Resolve dependencies from Workspace projects.
I manually copy needed jar files into my project lib folder. Then, I try to add them to build path via "configure build path option". If i choose "add jar", then the lib folder does not show up in the "to choose from" list. So, I am forced to use "add external jars" option instead. But, that option does not make the jars a part of the project even though they lie in the lib folder. After I restart eclipse 2-3 times, the jars are magically integrated into my project.
Why is eclipse behaving this way ? Why can't I do this easily ?
Please help me.
By default, Eclipse dose not detect file change which come from outside, like copy a jar file in lib folder manually.
So after you copied jar files, you have to refresh the project by pressing F5 while selecting your lib folder. I believe that's why eclipse cannot found your jar files.
If you want to solve this problem once for all, you can active "Refresh using native hooks or polling" via
Window -> Preference -> General -> Workspace
However, this might slow down Eclipse if you have a big project with many many files.
UPDATE
As Bananeweizen mentioned, instead of doing all the copied from outside of Eclipse, you can also copied those file into Eclipse, Package Explorer View for example. This way Eclipse will detect and refresh folder automatically.
The way I was taught to add external jars to an eclipse project is to drag the jar file from explorer into the lib folder in eclipse and then on the dialogue eclipse responds with is choose the copy to option and eclipse imports the jar file and copies it to the lib location at the same time.
I guess this is a Eclipse question.
I have a mercurial repository with a source folder (src/main/java/) and some source code. The repository also contains a build.xml. After cloning the project into Eclipse using the Mercurial plugin I'm unable to configure a launch configuration for my project. Eclipse is unable to identify the newly cloned project as a project when setting up the launch configuration. What am I missing?
TIA
What kind of launch configuration are you using?
an External Tools Configuration (in which case you defnie and Ant Build with a direct link to your build.xml)
or a "Run Configuration", meaning your repository must include a .eclipse and a .classpath for eclipse to list your project as one being able to Run.
As discussed before in Which eclipse files belong under Version Control, those two files can be versioned, provided they only use relative path.
Do you have a .project file?
If you do, you should be able to use File->Import->General->Existing Projects into Workspace.
If you don't, try File->New->Project and there are various different options to create a project from existing source.
I have a rather large project which contains a number of third-party dependencies which are linked via svn:externals. These include tomcat and blazeDS, which are packaged by our installer via ant. The problem is that these projects contain dozens of sample JSP pages, and eclipse chokes on them when trying to build the project, producing hundreds of errors.
Our project setup is something like this:
src/
main/
test/
third-party/
blazeDS/
tomcat/
etc.
Now, in eclipse, my project's build path is set to only include subfolders in src/main and src/test. Yet, for some reason, it still tries to build everything beneath third-party. I have clicked on third-party and selected "remove from build path", but this had no effect. I even tried adding the third-party folder to the build path, and then excluding "", "/*", and "**/*.jsp", but again, to no effect.
What is going on here?
Edit: Thanks for the suggestions, though unfortunately, they don't seem to fix the issue. I don't have the CheckStyle plugin installed (I'm using Eclipse 3.4.1 with the only custom plugins being subclipse and flex builder), and I tried disabling all extra builders except for Java, but the errors are still being thrown.
I usually have this kind of issue with CheckStyle plugin, where you need to specify in its properties (right-click on project -> Properties -> CheckStyle):
"Exclude from check Files non located in a source directory"
Otherwise it does analyze (and reports warning/errors on) files which are not candidate to be compiled in the first place.
Couple of other suggestions:
try restarting your eclipse with the -clean option (eclipse software version of 'did you reboot it ?' ;) ). Beware it can reset your workspace perspectives, so you may want to try that with a copy of your workspace instead.
try deleting your project (your workspace reference of your project, not its actual content), and reimporting it (beware of your custom launchers, they may get removed in the process).
check if you do not have any linked directory within src or test, which would point to thirdparty(/**): that would explain the unwanted compilation.
It could be that your eclipse project is configured to have extra Builders. You can check that in the project's properties (right-click on project -> Properties -> Builders).
In my case it was because there was a reference to the file (which I had excluded from the build path) in another file which was in the build path. I wanted to exclude SegModel.hpp from the build path, but in another file, I had specified template short K::KEstimate<SegModel>(SegModel& m, short stepCode);