Set a timeout to maven downloading resources? - maven

I don't want maven to download from any repository...is there a way to set download time out from all the repository?
The offline tag set to "true" in settings.xml is helpless in this case.

Invoking mvn with the -o flag will stop Maven downloading dependencies from remote repositories.
e.g.:
mvn -o install

Related

Running Jenkins Job using only the local repository

I have a Spring boot project on my local machine and I am using personal dependencies in the project. When I run mvn clean package on the windows terminal it works but when I use mvn clean package in the Jenkins Job it does try to download dependencies in the remote repository. My question is how to force Jenkins to use my local repository without looking the remote one.
You should able to use maven option mvn -o or mvn -llr.
But that assumes ~/ is the same user Jenkins agent ia running on.
Your better bet is to use mvn install:install-file to install the jars locally.
You can set up your job to do a curl.or wget step to retrieve the files from "somewhere", then have your pom call a pom which installs the jars locally from workapce to repo, then does your build.
That makes your job portable and still pulls the rest of OSS jars from Central, without needed an intermediary remote.

maven dependency error when i start to install mvn -nsu

Failed to execute goal on project netconf-exercise-impl: Could not resolve dependencies for project org.sdnhub.odl.tutorial.netconf-exercise:netconf-exercise-impl:bundle:1.0.0-SNAPSHOT: The following artifacts could not be resolved: openexi:nagasena:jar:0000.0002.0053.0, openexi:nagasena-rta:jar:0000.0002.0053.0: Failure to find openexi:nagasena:jar:0000.0002.0053.0 in http://nexus.opendaylight.org/content/repositories/opendaylight.release/ was cached in the local repository, resolution will not be reattempted until the update interval of opendaylight-release has elapsed or updates are forced -> [Help 1]
Yeap, had the exact same error, but copying the settings.xml from the official ODL wiki did it for me.
Just used this command from the wiki's instructions:
wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
Same issue here. I am actively searching for an alternative jar location for nagasena and nagasena-rta so we can just update the repository list.
According to the OpenDaylight Wiki. You need to
Edit your ~/.m2/settings.xml
OpenDaylight maintains its own repositories outside of Maven Central, which means maven cannot resolve OpenDaylight artifacts by default. Since OpenDaylight is organized as multiple inter-dependent projects, building a particular project usually means pulling in some artifacts. In order to make this work, your maven installation needs to know the location of OpenDaylight repositories and has to taught to use them.
This is achieved by making sure ~/.m2/settings.xml looks something like the copy kept in odlparent. You can do that quickly with the following command"
cp -n ~/.m2/settings.xml{,.orig} ; \
wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
after this you can then re-run mvn -nsu
“mvn clean install -nsu”
As pointed out by ShamanPrime and user2719303, you must configure your env with a custom ~/.m2/settings.xml file.
Full instructions are here: https://wiki.opendaylight.org/view/GettingStarted:Development_Environment_Setup

Change Maven settings at build time

I would like to deploy my Maven build to an Artifactory repo. This repo requires authentication, but I would prefer not modifying my settings.xml file. Is there a way to provide the credentials at build time? I know that you can set properties in the POM with the -D switch:
mvn clean package -Dmy.prop=blah
Is there a way to do something similar to provide the contents of a <server> block in the settings.xml file?
You can use the Maven Artifactory plugin, which accepts credentials in pom file and use the -D as intended.
And, of course, you'll get the full build-info support :)
You can prepare separate settings.xml file for build purpose and use this by -s options.
Eg.
mvn -s build_settings.xml clean deploy

What is maven clean repo building?

I am new to maven and I heard the term "maven clean repo" building ? What is the meaning of this ? How it different from the normal maven building process ? Also I want to know about the maven repository and how it changes when we build the software
I'm not sure if there is an exact term called "maven clean repo building" - but it is probably referring to doing a clean build by clearing out your entire LOCAL maven repository to ensure you have only the correct dependencies for your project.
All dependencies you need get downloaded into the repository which is at ${user.home}/.m2/repository by default. You can see this grows as the build runs and dependencies get downloaded into this folder.
The link
http://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html explains one way of purging this.
You can change the maven repo being used for the build by providing the following argument to the build command
mvn clean install -Dmaven.repo.local=/tmp/sampleRepo
If relevant artifacts are not available in the pointed maven repo, it will download them from relevant repositories (maven central or repositories which are provided in the pom.xml file).
Hint;) Using a directory in /tmp/ will be more good as /tmp/ get automatically cleared in OS restart.

Maven without Internet connection

I'm new to maven project.
I'm changing an ant project to maven project.
To install the 3rd party jar's in maven local repository, I used install command.
Its trying to download the resource jar.pom.
I don't have download access in my organization so the build failed for installtion.
After request i got the resouce jar and clean jar in my desktop(also i can get other necessary jar).
How to make maven to use these jar for the process and how to install the jar in local repository without internet acess.
I downloaded the jar and placed in local repository but it couldn't point the path and use those jars.
please let me know what steps i have follow to run maven install and other commands to build the project without internet access.
where should i placed the jar which i have downloaded by external way.
Please guide me for building and deploying the project.
Thanks in advance.
http://maven.40175.n5.nabble.com/Maven-installation-and-using-in-project-without-Internet-conncetion-tp4564443p4564443.html.
http://www.coderanch.com/t/544641/Jobs-Offered/careers/Maven-installation-project-without-Internet#2471141
I've posted same question in these link
You need an internet connection. Maven isn't initially self-sufficient. It needs to download a bunch of plugins along with their dependencies and the dependencies of your own project. And this really depends on what sort of settings you have for your projects. One set up will require one set of dependencies, another - a whole different one. You can't download artifacts from the Maven Central manually and then install them locally one by one. Simply put, that sounds stupid.
I understand that you're coming from the Ant world where Ant has everything it needs on the local file system. However, Maven relies on the fact that it will have a central repository (either Maven Central, or your own repository - Nexus, Artifactory, etc.) from which to download the plugins and dependencies it needs. There is no point in you migrating to Maven, unless you'll be allowed access to the Central Maven Repository.
Yes, indeed, you can run Maven offline and you can have Maven produce a local repository for you to use when you are in offline mode. However, what you're trying to do is against Maven's principles.
If your company won't allow access to Maven Central, just stick to Ant. Your effort will be a waste of your company's and, ultimately, your own time.
In fact the maven strenght is mainly in the internet accessible repositories and automatic dependency management. But it's possible to use this tool to build your project if you have all dependencies required for your project in your local repository. Then you may use -o option for offline mode and maven will not try to download updated artefact versions.
To get the artifacts into you local repository you have several options:
1) connect to the internet once and mvn build the project (this will download all required dependencies)
2) install dependencies as jar to the local repository manualy (using appropriate mvn command)
I think the questioner is looking for -o or --offline option for mvn. This is a command line option and can be provided while executing.
I think you can setup your repo correctly and execute the mvn goals once when you are connected to internet and use the -o option for later executions .
Hope this helps.
~Abhay
You can configure maven to run in offline mode. Add this entry to your settings.xml
<offline>true</offline>
See here for further information:
http://maven.apache.org/settings.html
Before you can use offline mode, you have to install all necessary third party jars to your local maven repository.
mvn install:install-file
-Dfile=filename.jar
-DgroupId=com.stackoverflow
-DartifactId=artifact
-Dversion=1.0.0
-Dpackaging=jar
-DcreateChecksum=true
-DgeneratePom=true
It's much easier to get those jars in your local repository using an internet connection and online mode.
It's possible to install these resource jars in your local maven repo using install-file. This will make the available to the build. You'll have to do this for each individually, but once that's done you won't have to do anything special.
To be clear, maven puts everything in your local repository, both the jar you're building with this project and the various library jars. Because your system cannot be connected to the internet to maven can populate the local repo with your libraries, you'll have to use this manual approach.
Edit: You should be able to run install-file anywhere. When you do, you'll need to provide the groupId, artifactId, version, and packaging using the command line options. If you already have a POM file for the library, you can provide that instead via -DpomFile=your-pom.xml.
This question has some useful info: How to manually install an artifact in Maven 2?

Resources