could not read setting.xml file for maven - java

I had downloaded my maven plugin from eclipse market place and now i
need to set setting.xml file in window-preference-maven-user settings
block,but i am unable to find setting.xml file, i had also looked in
.m2 directory but their is only repository directory is their. so
please tell where should i look to get setting.xml. please also tell
me what is the term proxy in setting.xml file, i am new to maven so i
don't know much about this. Thanks in advance..

Download the maven installation from here. Extract the zip and there will be settings.xml.
Proxy are used so that maven use that information to download artifacts in corporate environments.

There are two locations where a settings.xml file may live:
The Maven install: ${maven.home}/conf/settings.xml
A user’s install: ${user.home}/.m2/settings.xml
See, this for detail overview.
Also , maven use maven use proxy setting to download artifacts in corporate environment. Like if you are running maven behind firewall in corporate,
Maven need to be configured with proxy settings, See here for detail.

Related

How to let maven project work locally by intelij-idea?

We have a maven project works fine in a internet enabled environment, now we need make it work in a local environment by IntelliJ IDEA Community Edition .
we have try following actions:
in setting->build->maven:
check the box "work offline"
download all needed jars into a local folder
in settings.xml set local Repository, such as
C:\FCA\Repository
4.build the project, it seems that some packages can be find in pom.xml(no error message in pom.xml), but can't be find in java code , and build failed. You can refer to attached picture for details
How can we get it done locally? thanks a lot!
Under "Settings -> Build, Execution, Deployment -> Maven" you can find options:
Maven home directory
User settings file
Local repository
There you have to provide path to your local maven installation (by default IntelliJ has it's own Maven provided). It should automatically read your settings.xml file and set local repository. If not please also provide those two and it will work fine with your local libs.
First of all, run mvn dependency:go-offline. Then you can build in offline mode as long as you don't change any of the dependencies.
If you do this to work inside a company with several developers, think about setting up a Nexus/Artifactory for you company.

POM file Uploaded by Artifactory Jenkins plugin won't resolve in Maven builds

I am building a jar in Jenkins and uploading it to an Artifactory repository. I've verified the jar, the pom, and the hash files are present in the repository. When I try to build a project on my machine that has a dependency on the jar, it downloads the jar correctly but then I get a POM file is missing message and the maven build fails. I don't see any rhyme or reason why this should fail, I've done an Artifactory trace on the jar and the pom in Chrome and Firefox and the response says that it found the files. So I don't understand what could bve causing the issue? We were running Artifactory 5.2.1 and upgraded over the weekend to 5.5.1, but it hasn't changed anything. What should I be looking at?
Thanks.
EDIT: This question is about to be moot. Discussions are in progress about setting up a generic maven repository and avoiding the use of Artifactory altogether, since it won't do what is needed.
First, make sure your groupId and artifactId are correct. I've lost a lot of time thinking it's a maven problem when it's really just that I reversed a couple letters in a long groupId.
Next, have you tried 'forcing' maven to bypass its local cache? Try running mvn -U <your tasks>
If that doesn't work, try deleting the ~/.m2/repository/path/to/the/artifact/with/the/missing/pom and use mvn -U again
OK, problem solved. Turned out to be a Maven problem, not an Artifactory problem. Our maven settings contain a proxy setting so we can pull down jar from Maven Central - problem was, our company url was incorrectly configured in the nonProxyHosts tag, was set to domain.org, instead of *.domain.org, so it was trying to retrieve the maven artifact through the proxy instead of going directly to the Artifactory server. My apologies to the Artifactory devs for blaming the problem on Artifactory.

Eclipse plugin: how to read the "settings.xml" file path which is configured in M2Eclipse plugin

Now I'm developing a new Eclipse plugin, in this plugin I need to get the settings.xml file which is configured in m2Eclipse plugin and update it. I want to know whether the m2eclipse plugin has provided the related extension point so that I can use directly.
I've researched its user guide and the website, I cannot find any useful information for resolving my problem.
P.s: I'm not saying how to configure the settings.xml in maven plugin but developing a new plugin to read the settings.xml in m2eclipse.
You can have access to the user settings.xml path via
MavenPlugin.getMavenConfiguration().getUserSettingsFile()
And the global settings via
MavenPlugin.getMavenConfiguration().getGlobalSettingsFile()

How to configure maven without internet access

While converting dynamic web project into maven project I'm getting this error:
"CoreException: Could not calculate build plan:
Plugin org.apache.maven.plugins:maven-compiler-plugin"
I can't access the internet to download any jars and plugins while converting because I'm on a restricted network with no internet access. Is there is any way to make a Maven project with no internet access?
I'm using:
Eclipse kepler
Maven 3.0.4
JDK 1.6
You can manually download or some how find required artifacts.(jars) Then copy them into your local maven repository.
Now you can use
mvn clean install -o // off-line build
to build your project without internet.
About half year ago, when I worked as an intern in a company, we also encountered with virtually the same problem as you ------ we were in the restricted network, and our computers couldn't access the internet, but we still needed to use maven to update the project dependencies. Here is our solution:
Find a server that can access the internet, and also you can access
the server in your restricted network.
Establish a sonatype nexus server on the server you found above.
The sonatype nexus serer is just a private repository in your environment. You can upload your own packages into the repository, and also the nexus server can download required packages from the central maven repository.
The last thing you need to do is to change the repository address in your pom.xml to the nexus server address
Hopefully, this can help you. And if you have any questions, please feel free to ask me again.
mvn clean -o install
Running in Offline Mode
If you ever need to use Maven without having access to a network, you should use the following option to prevent any attempt to check for updates to plugins or dependencies over a network:
-o, --offline
When running with the offline option enabled, Maven will not attempt to connect to a remote repository to retrieve artifacts.
refer here and here for more options
I think without internet you can not download it, initially you need an internet connection because maven need bunch of dependency and it all depend on your project. if you download them manually one by one there is some chance that you could miss some dependency and error will resolve one by one it will take more time and research to search dependency over internet and fix them one by one.
so I prefer instead of downloading manually go for internet connection it will download all the dependency automatically.
if you have restricted access download it at home and replace that folder with your work area folder
Maven is a dependency management system which downloads the required dependencies from the internet or a mirror of the central maven repository. Incase you do not have both - connection to internet (Central Maven Repository) or a local mirror (Nexus is the most used replicator of the central maven repository in a Enterprise setting) - then maven is bound to get the dependencies off your local hard disk from the .m2 folder under your logged in user directory.
Hence, in order for maven to work, manually register all dependencies which you have listed in the pom(s) as described in the maven guide :
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
You can try copying your .m2 folder to the machine without internet... and then running maven offline.

Maven repository location is not updated in eclipse

I have a Maven project. I have converted it to eclipse project using the command.
mvn eclipse:eclipse
I imported this project to eclipse. I am getting missing library error.
I have updated the maven repository details in Maven setting of eclipse.
My current maven repository is E:\myfolder\repository
I have edited this my settings.xml too.
<localRepository>E:\myfolder\repository</localRepository>
I have added a class-path variable MAVEN_REPO.
MAVEN_REPO = E:\myfolder\repository
The actual address of the jar in repository is M2_REPO/javax/ccpp/ccpp/1.0/ccpp-1.0.jar.
But the eclipse is not able to locate the jar in the repository.
It is taking default repository address.
Still I am getting missing library error and it is pointing to default maven repository address rather than my new repository address.
Project 'Testproj' is missing required library: '\\user dir\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.jar'
Can some one tell how to overcome this error.
Thanks in Advance.
In eclipse, go to Preferences > Maven > Installations
Make sure that the Global Settings file is pointing to the right config and it is pointing to the right local repository.
This is what worked for me:
In Eclipse,
Windows->Preferences->Maven->User Settings
Even if the settings.xml was updated as expected it was still pointing to default directory. So i did 'Restore Defaults' then 'Apply'
And then i again changed the Global Settings and User Settings to point to correct settings.xml. Do Reindex for local repository. Click OK and bang!
Projects compiled perfectly!
Are you sure you did all the configurations and only then executed mvn eclipse:eclipse? Also is this mvn pointing to the same maven installation which you have configured? Before open the project in eclipse just check the generated .classpath file and see if it points to wrong location repo.
Although I would suggest this -
Eclipse has excellent maven plugin. You do not need to do mvn eclipse:eclipse.
Simply import project in eclipse as maven project. Before import ensure the maven plugin is configured to use the same settings.xml which you have configured for command line maven.

Categories

Resources