Hello!
My question is related to eclipse and maven integration, maven repositories and global index update from central mirror.
The quiz is:
Let's supose that I don't have specified any special mirror, nor
{maveninstallationfolder}\conf\settings.xml
neither
{user-home}.m2\settings.xml
So then, why or how eclipse 'maven repositories' tab decides to fetch central at
repo.maven.apache.org/maven2
or
repo1.maven.org/maven2
?
Which settings.xml is reloading eclipse when I click on 'reload settings' button?
I ask this because I have two different eclipse installations ('indigo' at work, 'juno' at home).
At home when I click on 'update index' it works ok. It updates it from central mirror repo.maven.apache.org
At work, doing the same operation it always fails trying to update it from repo1.maven.org (I don't know neither I care if because of firewall or proxy issues)
I would like to know how to change it and force it to fetch it from one or another.
I attach a picture to clarify
thanks in advance
If you have a preferred central repo or if you are using a company maven proxy (like nexus or artifactory) you can set it in the user settings.xml. You may have to create this file. This is normally in ~/.m2 on linux or c:\Users\YourUser\.m2 on Win7 or c:\Documents and Settings\YourUser\.m2 on WinXP (IIRC). Note that this is the same place as your local repostitory base folder.
When I create a new settings.xml on a machine that doesn't have one, I go to the maven2 documentations web pages, find the sample settings.xml that is there and copy it to a new file I create.
There is a global settings.xml in $M2_HOME\conf but it usually isn't changed from the default. It does document all the sections you can add to your settings.xml since both have the same sections. (If you are using the embedded version of maven in something like MyEclipse or the maven eclipse plugin, I don't know where they put it.)
For another question, if you need to configure Maven to use a corporate proxy to get out of the company network to maven central, you can put that information in your user settings.xml file--the same one you create to set the URL to use.
You may have different versions of Maven running on the two machines. That would explain the different names for central. But the two names both point to the same place.
Related
I've created a maven project in eclipse without specifying the settings.xml and it works just fine. Why do we need settings.xml? To create a cache of downloaded dependency jars or something?
You can overwrite and define some maven settings relevant to your build environment. This especially includes proxy mirrors, default repositories, refresh settings and credentials for servers. Typically you should be able to use maven without any settings (as least if you have an unrestricted internet connection and dont want to use private servers).
Details: https://maven.apache.org/settings.html
Some settings (repositories) can also be specified inside the POM. The reason why this is specified in a external settings file is two-fold. On the one hand they might be specific to your machine/network or you want to keep it secret (passwords).
And on the other hand they also might affect plugins or functions running with no pom or before the pom is resolved.
Generally speaking settings.xml contain unshared stuff which you do not want to check-in or publish.
Using Eclipse Java EE IDE for Web Developers. Version: Kepler Service Release 2
Build id: 20140224-0627.
When I select File -> new -> Maven Project -> Use Default Workspace Location. I get the following Dialog. Local Default Catalog is empty:
I click Configure button, and then click on Maven Architecture Catalogs. The page says:
Location of catalog files
The Archetype Plugin knows by default about its internal catalog. It
also knows about the local and remote catalogs.
local represents the ~/.m2/archetype-catalog.xml catalog file.
remote represents the
http://repo.maven.apache.org/maven2/archetype-catalog.xml catalog
file.
The Archetype Plugin can also read catalogs from filesystem/HTTP by
providing the path/URL of a catalog file or of a directory containing
an archetype-catalog.xml file.
If Execute the following on the command line (I have everyhing under tools directory, Eclipse, Maven, WildFly, etc.)
C:\Tools>dir archetype-catalog.xml /s
It doesn't find any file.
So default local catalog doen't exist! Why is that?
I have downloaded http://repo.maven.apache.org/maven2/archetype-catalog.xml, but I don't know where to put it to become the default local catalog, because I don't know what ~/.m2/archetype-catalog.xml file path is. I tried with C:\Tools\eclipse\.m2\archetype-catalog.xml and several other locations without luck. Sorry, I'm new to Java eco-system and Eclipse IDE.
I have the latest M2Eclipse found here: http://download.eclipse.org/technology/m2e/releases
EDIT: I figured out what ~ means on ~/.m2/archetype-catalog.xml. I have put archetype-catalog.xml into c:\users\my.user.name\.m2\ and voilà default local catalog is now full of archetypes. But still. Why it didn't exist in the first place? This is very annoying.
The archetype catalogs used by eclipse can be found in Window -> Preferences, then in the section Maven -> Archetypes. If no catalog is listed there, you can add the official maven remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml
No need to configure local archetypes unless you have created your own archetype. In this case, when you install it on your machine, the maven will create the archetype-catalog.xml file on the ~/.m2/repository path. In another case, to retrieve any artifact the only things that you need to do is configure the remote catalog, for example, to configure Spring Catalog, you need the following
If you see the following screen, you can observe that I don't have anything in my Default Local Catalog similar to you while in All Catalogs, I have the archetypes from other repositories.
Finally is important to know the difference between archetypes and dependencies. The archetypes let us create a project from it, the others are the libraries to own the project.
For some reasons, my computer has 3 Eclipse IDE instances on it, Indigo, Juno and Kepler.
Indigo is used in real developing, Juno is for program execising, Kepler is being used in another project. Each of them contains a maven project.
But, there is only 1 maven in my computer, and 3 eclipse instances are now sharing it.
And these are errors keep coming which associate with maven, sometimes I need to clear some directories in maven or modify some maven config files. That makes me worry about whether one change would affect other maven project in other eclipses.
So I decide to isolate different eclipse, give each eclipse its own maven and tomcat and so on.
Could that be possible? if it so, how should config the system path and other relevant configuration??
Thanks a lot!!!
Could that be possible?
Yes its completely possible.
how should config the system path and other relevant configuration?
Goto Window -> Preference -> Maven -> Installations -> Add and add a new installation of maven and you can switch between any installation of maven within the eclipse
And these are errors keep coming which associate with maven, sometimes I need to clear some directories in maven or modify some maven config files. That makes me worry about whether one change would affect other maven project in other eclipses
Firstly this shouldn't happen unless and until you have different settings and profiles set-up in your settings.xml. So, prior to configuring multiple mavens, first debug why the maven settings get distubred in the other projects.
EDIT
If you are working with different maven settings ( and by settings I mean different repositories setup for each project and different server configurations that you want to keep isolated with other projects ) make use of Maven Profiles . Although, the real purpose of profiles is building for different environments ( like for dev/test/production ) you can use these profiles for building your different projects.
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
I am not sure if there's an answer for this already -- couldn't find one for this (hopefully common) setup:
I recently converted one of my ColdFusion projects to deploy via ANT.
I have a local ant script that instructs a remote server to check out the code, and run the application's specific build file, remotely on the server.
I have a few endpoints:
Live - production (on the production server)
Staging - on the production server, different datasource, etc.
dev - on the local box.
What I have run into it seems is a simple and common problem. I now need ANT to create any build, even locally. Fine, created a local endpoint and it configures for my box.
Issue? How do I get it to show up as a project (automatically if possible) in Eclipse/ColdFusion builder. What I envision is instead of checking out a branch via the subversion plugin in CFBuilder/Eclipse, I now use ANT to do that for me.
Since I use ColdFusion Builder (Eclipse + Adobe's plugin), I have all of eclipse's tools and plugins available to solve the problem of : how can I best call ANT from within Eclipse/ColdFusion Builder, to setup the local build as a project that I can develop and work on?
I think when I check the code back in from the local box, I'd have to be sure not to check in any files with local config paths, etc.
I hope this is a detailed and clear enough explanation, if not, please ask.
Thanks in advance!
You won't be able to have it "automatically" show up in CFBuilder, but you can make it pretty easy.
Eclipse requires the ".project" file, which is a simple xml file that by default generally just contains the project name.
Once you check out your project from SVN, Do file -- new -- ColdFusion project and point it to the directory where you've checked out your code. This will create the .project in there. From there, you can commit that file to SVN.
Subsequent developers who check out the project from SVN can then do File -- Import -- Existing Project into workspace, and point it to their checked out location. Since it'll have the .project file in there (from when you committed it), that project will show up when they search for projects in that import wizard.
Now, that's how you'd do it if you already used ANT to check out the code. However, if you wanted a potentially even easier way, then you can just install either the Subversive or Subclipse plugin into CFBuilder, and then do
file -- new -- checkout project from svn
point to your svn url
select the directory you want to check out
choose a location where you want the code to live
click through to completion