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)
Related
I have a maven multi module project which has 5 modules. Some of my modules depend on one or more other modules, I am successfully able build the project and in eclipse also I am not getting any errors. However there is one problem which is bothering me, when i ctrl + click in my code and the class is defined on some other project eclipse does not open the file in the editor. I know i can attach the source code using maven but still i wont be able to make changes to that file.
Is there any way to be able to link projects in eclipse through maven?
Is there any way to be able to link projects in eclipse through maven?
That behaviour is the default. To check if for some reason that default is not in effect for your project, right click your project (the project you want to jump from) and go to "Maven". If there is an option "Disable Workspace Resolution" the workspace resolution is switched on, meaning you can theoretically jump from that project.
If you still cannot jump, then the project you want to jump to is not in your workspace. Take into account that for eclipse to identfy one project as dependency of another, everything including version must match.
Also check what rest_day said. You must have the projects importet as maven projects, but running eclipse:eclipse is not required anymore with current (up to ca 2 year old) eclipse.
Did you import the projects as Maven projects?
Also, could you go to the root of the project and run mvn eclipse:eclipse
eclipse:eclipse
Full name:
org.apache.maven.plugins:maven-eclipse-plugin:2.10:eclipse
Description:
Generates the following eclipse configuration files:
.project and .classpath files
.setting/org.eclipse.jdt.core.prefs with project specific compiler settings various configuration files for WTP (Web Tools Project), if the parameter wtpversion is set to a valid version (WTP configuration is not generated by default)
If this goal is run on
a multiproject root, dependencies between modules will be configured
as direct project dependencies in Eclipse (unless useProjectReferences
is set to false).
Instead of Ctrl+Click, click on the identifier and press F3. If you now see a red text reading "Current text selection cannot be opened in an editor", you've been hit by this bug.
See this question for a solution: How do I get rid of "Current text selection cannot be opened in an editor" in Eclipse?
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.
Eclipse Helios: 40+ project working set, using maven (mvn-eclipse plugin) to generate eclipse project files.
'Resource is out of sync with the file system: ...' Appears after doing, among other things, a text search.
After a bit of googling found Prefs > Workspace > Refresh Automatically which is widely reported to be malfunctional, and has the same symptom for me. The source files are source controlled, so therefore have lock attributes on them, was curious if this may come into play with this.
Second part is regarding my build directory; eclipse knows proj_root/target is the build directory, but I would like to exclude resource sync'ing in that folder.
I basically never want to see that dialog, and don't want to have to take action to remedy it (ie manually refreshing).
I had the same problem with m2eclipse.
Marking target folder as Derived resource worked for me (right-click -> Properties -> Resource -> Derived).
I use Eclipse for different projects, each with its own workspace. They need quite a different set of plugins (SVN vs hg vs git, AppEngine vs Tomcat vs OSGi, and so on), and I have all those plugins installed and active all the time, which clutters the workspace quite a bit. I'd like to selectively disable plugins for each workspace.
Eclipse (3.6/3.7) has a UI for disabling some plugins. It's under Window->Preferences->General->Startup and Shutdown->Plugins activated on startup. However not all plugins are listed here.
To disable other plugins:
It's possible to have separate configuration (osgi.configuration.area) directories:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html%23osgiconfigurationarea
Simply copy eclipse_dir/configuration to a new location.
Make launchers for each of your workspace and add parameters to your workspace specific launcher, for example:
-data workspace_location -configuration new_location_for_configuration_dir .
You can disable osgi bundles (not same as plugins) by removing it's line from configuration_directory/org.eclipse.equinox.simpleconfigurator/bundles.info file.
The config.ini file in the custom configuration directory must contain this line:
osgi.configuration.cascaded=false
Another solution would be to define a perspective for each workspace, and customize that perspective.
In each one, you can deactivate menu and commands of plugin you do not want, even though those plugins remains loaded.
That help removing some of the "GUI cluttering" caused by the various plugin.
When you switch workspace, you will restore the perspective you were using with the new workspace.
Eclipse has a notion of local and global configuration that might help you. When you start Eclipse with the -local {localDir} argument, Eclipse uses a writable local configuration in {localDir} and treats the (global) install configuration as read-only. Thus, you can install common features in the global configuration (when not using the -local flag), and install local features into the local configuration. In your case, to get per-workspace configurations, you can adopt the convention that the local configuration is inside or beside your workspace directory (though if inside, not managed as an eclipse resource or project), and then always launch pointing at that directory (e.g., eclipse -data {workspaceDir} -local {workspaceDir}/localConfig).
I solved that problem by having two separate eclipse "installations". It isn't the most beautiful solution, but does the job.
Here it is suggested to use General -> Capabilities, but that doesn't seem to exist in 3.5
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);