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.
Related
I'm trying to install neo4j on an offline Ubuntu machine. Therefore I tried to build it from the source using :
mvn clean install -o
But I got following error :
Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its
dependencies could not be resolved: Cannot access central
(https://repo.maven.apache.org/maven2) in offline mode and the artifact
org.apache.maven.plugins:maven-clean-plugin:jar:2.5 has not been
downloaded from it before.
So I downloaded the corresponding jar file manually from https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/ on another machine and then transferred it on the Ubuntu one. But now it's unclear what I have to do with that file...
Maven needs Internet access or a Nexus/Artifactory with Internet access (many companies run their own Nexus/Artifactory which mirrors MavenCentral).
While it is theoretically possible to download the relevant jars and install them one by one in the local repository ( install:install-file), you will probably spend days installing dozens of artifacts (maybe hundreds).
We are using our git server for project management. How do I download maven project dependency from my git server?
For project checkout/pull and push we are using tortoise git
Clarification:
We are using another project as a submodule in our project. That project available on our local git server. So, when the new update is available I have to download and copy in m2 repository manual. Instead of a manual process, I want to download from my local git server.
Storing jar artifacts in git is a bad idea. Git is not meant for binary files. Use a maven repository server like Nexus or Artifactory instead.
EDIT: I admit that this answer lacks background and explanation. So I added a little.
Most sources I know do not recommend to put (large) binaries into git repositories because checking out the git repository means checking out all old versions of the binaries and that might be a lot of stuff.
There are specialised solutions (Maven repositories like Nexus/Artifactory) for the task at hand which can be directly used by Maven without giving URLs to separate artifacts (the URL of the repository suffices to find all artifacts in it).
AFAIK GitHub and GitLab offer services to provide Java artifacts as Maven repositories. So if you use on of these services, you probably have cheap other option.
I am trying to download JAR named mygroup-myid-myversion-jar-with-dependencies.jar from maven repository and tried commands
mvn -q org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=MYURL -Dartifact=mygroups:myid:myversion:jar-with-dependencies
mvn -q org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=MYURL -Dartifact=mygroups:myid:myversion-jar-with-dependencies
And both failed with error of being unable to find artifact.
Is this addendum called "classifier"?
How to donload JAR with classifier?
Use -Dclassifier=<classifier> or -Dclassifiers=<classifiers> if you have more to download.
This worked for me:
mvn com.googlecode.maven-download-plugin:download-maven-plugin:artifact -DgroupId=org.jolokia -DartifactId=jolokia-jvm -Dversion=1.6.0 -Dclassifier=agent
This one happened to me. I have a remote repository on one of the internet sites and our internal nexus are not getting those dependencies remotely from this host. We have a security setup that only nexus server can connect from outside world and our dev machines have no access to those kinds of remote repository hosts.
All of the artifacts are fine and can be downloaded via proxy repository but some are not, specially like this artifact with dependency classifier below.
<dependency>
<groupId>com.asset</groupId>
<artifactId>integration-adapter</artifactId>
<version>1.28.76</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
Here are the steps that works for our development teams.
1.) As I'm admin I can remote download those problematic artifacts.
2.) From a secured host, make this file available.
3.) Follow this link from Nexus https://support.sonatype.com/hc/en-us/articles/213465818-How-can-I-programmatically-upload-an-artifact-into-Nexus-2-
4.) This is how I build/deploy to an internal repo so clients can download during their own specific builds for their projects.
mvn deploy:deploy-file -DgroupId=com.asset -DartifactId=integration-adapter -Dversion=1.28.76 -Dclassifier=jar-with-dependencies -DgeneratePom=true -Dpackaging=jar -DrepositoryId=nexus -Durl="http://your-nexus-host:8081/nexus/content/repositories/repo-releases/" -Dfile=integration-adapter-1.28.76-jar-with-dependencies.jar -DupdateReleaseInfo=true
Doing above way creates pom files and meta data in our corporate nexus so maven clients can download those artifacts.
5.) At your .pom file please add these dependencies below:
Looks like in this remote repository (the external host) these files were uploaded directly that is why there are missing maven pom files and we as consumers/clients cannot build it as normal with other working artifacts they have.
Note : So if your are publishing artifacts to the outside world and make your artifacts downloadable make sure you know and read on step 3 above.
I have a Java-based GitHub project, fitnessjiffy-spring (I'm currently focused on the "bootstrap" branch). It depends on a library built from another GitHib project, fitnessjiff-etl. I am trying to configure both of these to be built by Travis CI.
Unfortunately, Travis is not as sophisticated as Jenkins or Hudson in dealing with Maven-based Java projects. Jenkins can easily handle dependencies between projects, but the same concept doesn't seem to exist with Travis. If one project depends on another, then that other project must already be built previously... and its artifact uploaded to some Maven repo where the first project can download it later.
My "fitnessjiffy-etl" library is building and deploying just fine. I'm using Bintray for Maven repository hosting, and you can clearly see my artifacts over plain HTTP at:
http://dl.bintray.com/steve-perkins/maven/
In my "fitnessjiffy-spring" project, I am adding this Maven repo location directly in the pom.xml, so that Travis will be able to find that artifact dependency. Here is the state of my POM at the time of this writing. Note the <repositories> element at the bottom of the file.
When I build this project locally, it works just fine. I can see it downloading the Maven artifact from "http://dl.bintray.com/...". However, when I try to build on Travis CI it fails every time. I can see in the console log that Travis is still trying to download the artifact from Maven Central rather than my specified repo.
Does this make sense to anyone else? Why does Maven utilize a custom repository location in a POM file when building locally, but ignores this configuration when running on a Travis CI build?
From digging into this further, I discovered that Travis uses its own proxy for Maven Central, and has configured Maven to force ALL dependency requests through their proxy. In other words, it does not seem possible at this time to use additional Maven repos specified in the POM file of a project built on Travis.
In my case, I ended up refactoring such that project would not need the outside JAR dependency. I also switched to Drone.io, so I could manage my settings on the build server rather than having to carry a YAML file in my repository (which always struck me as a bit daft).
However, even on Drone it's still a major hassle to manage dependencies between multiple projects (extremely common with Java development). For Java, I just don't think there's currently an adequate substitute for Jenkins or Hudson, maybe running on a cheap Digital Ocean droplet or some other VPS provider instance.
In your install phase add a $HOME/.m2/settings.xml define your custom repository.
cache:
directories:
- "$HOME/.m2"
install:
- curl -o $HOME/.m2/settings.xml
https://raw.githubusercontent.com/trajano/trajano/master/src/site/resources/settings.xml
- mvn dependency:go-offline
script:
- mvn clean install site
I am on Netbeans and don't know Maven much. Whenever I import, open some Maven project, it starts donwloading something from some central repository, sometimes huge. It downloads things in .m2\repository.cache\m2e. I have limited bandwidth and don't want this. How to stop this?
I have set Options>Java>Maven>Dependency Download Strategy to never. Also tried mvn -o install and mvn -o for offline. Not solved.
The Maven way is to get you what the project says it needs, but you have not already downloaded to your local repository.
The huge file is the list of what is actually available in Maven Central, and for some reason unknown to me it is downloaded on a regular basis. If you do it once, it should be kept for future sessions.
Maven will download all the dependency only once to the local repository and not again and again.
Weather you have limited or unlimited bandwidth you have to download it to execute your project.
Maven has a very modular architecture. That means the the thing you get when you download the Maven distribution is in reality small core functionality.
The rest is downloaded from a Maven artifact repository, like Maven Central (which is the default repo).
Note that this applies not only for dependencies (the library your project uses), but also your plugins (i.e. the stuff that compiles, packages, and otherwise builds the projects). Hence the large number of downloads.
Like the other answers said, if you don't delete your local repository it should eventually contain all the artifacts (dependencies and plugins) you need without re-downloading. The only exception are SNAPHSOT dependencies which can get re-downloaded periodically, depending what's in your POM and settings.
Ultimately, you have two possibilities:
If you have access to a higher-bandwith connection somewhere, you can build the projects while using it, and your local repo will still store the needed artifacts.
If you have several computers/configurations behind a local network, you can set up a Maven repository manager, like Nexus or Artifactory, and use it as a local mirror. Note that those still need to download the artifacts at first as well.
But there isn't much else you can do. "Maven downloading the Internet" is, unfortunately in your case, by design.