When I run a mvn compile I get a list of errors from the compilation that all say a package is missing that I have as a dependency in my pom.xml.
Pom.xml
`<dependency>
<groupId>com.fortysevendeg.android</groupId>
<artifactId>swipelistview</artifactId>
<version>1.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>`
Error
error: package com.fortysevendeg.swipelistview does not exist
I would really appreciate some help on this one. I have been banging my head against this for a while now.
Looks like MVN is not able to pull your package ( com.fortysevendeg.swipelistview ) from your repository. To figure out, I would check-out the package from code repository ( i.e SVN, GitHub ) to your work space. Recheck the pom.xml for exact name & do MVN install.
link: Read
Downloading from a Remote Repository
Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a SNAPSHOT, when the remote repository contains one that is newer).
By default, Maven will download from the central repository.
During MVN compile it look first in your local workspace & if doesn't find then it will pull it from repository configured to.
Related
Generally i follow below maven commands to build and run my project.
mvn clean
mvn clean verify
or
mvn clean install
mvn spring-boot:run
My doubt is in which maven life cycle, dependencies get downloaded from maven central repository to my local .m2 repository.
I went through below mentioned maven life cycle but no where i found that in this steps dependency gets downloaded.
validate
compile
test
package
verify
install
deploy
Please explain it would be really helpful.
When you create a maven project, before validate there is step 'prepare-resources' which copies resources. Also when you do maven clean it will download dependencies. Read this link for more details
https://www.tutorialspoint.com/maven/maven_build_life_cycle.htm
The other answer here of prepare-resources is incorrect. That may be confusing the downloading of Maven plugins and their dependencies, but not the project's dependencies.
They actually are downloaded during the compile lifecycle.
Here is an example of a project where the only dependency is GSON, and I just finished running the process-resources lifecycle, the one that immediately precedes compile lifecycle. The only things present in my .m2/repository directory are things required by the default Maven plugins. Note that there is no com folder, which is where GSON would have been downloaded to.
After running mvn compile, the next lifecycle, a lot more dependencies are downloaded, including GSON:
I have a .jar file, which I want to use in my current project which I am building with Maven. After some research I figured out that I need to install it locally. This I did using:
mvn install:install-file -Dfile="D:\Eclipse Workspace\TextOnlyJam\adapterLib\lwjgladapter.jar" -DgroupId=lwjgladapter -DartifactId=lwjgladapter -Dversion=1.0 -Dpackaging=jar`
I then added the dependency into my pom like so:
<dependency>
<groupId>lwjgladapter</groupId>
<artifactId>lwjgladapter</artifactId>
<version>1.0</version>
</dependency>
My project in exclipse now manages to resolve all dependencies and does not give me any compile errors. However after cleaning and updating my maven project several times, I still get the following error when running an install:
Failure to find lwjgladapter:lwjgladapter:jar:1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
I assume that maven is looking for the artifact in the wrong location, however I can not figure out what I need to change here.
(I am also not sure if I need to add the dependency into , since it does not seem to change anything when I do.)
Okay, I just figured out that it was just a stupid mistake on my end. I looked into the repository folder and found, that my jar file was named `.jar``
So yeah, a simple copy and past error. Thanks for the help so far!
I have been trying to migrate ant build project to maven project by converting this project to maven using eclipse plugin. All is good except it is not able to detect jsr94 dependencies.
Error:
[WARNING] The POM for jsr94:jsr94:jar:1.1 is missing, no dependency >information available
[WARNING] The POM for org.infinispan:infinispan-core:jar:4.2.1.FINAL is >missing, no dependency information available
What I did to correct this :
Corrected pom.xml with this entry:
<dependency>
<groupId>jsr94</groupId>
<artifactId>jsr94</artifactId>
<version>1.1</version>
</dependency>
Also, verified the jar is present at the proper folder within m2 folder at C:\Users\xxxx.m2\jsr94\jsr94\1.1.
Tried maven clean and then maven install. But the same error again.
I expect if m2 has got the expected jars at the correct folder structure, it should be able to pick up the jars. Please help with this or any leads would be appreciated.
Thank you for the lead. I solved it by deleting the jar from m2 folder and again installing it using this command:
install:install-file -Dfile=C:\Users\Desktop\jsr94-1.1.jar -DgroupId=jsr94 -DartifactId=jsr94 -Dversion=1.1 -Dpackaging=jar
Thereafter, the build is successful.
When I run
mvn compile
I get package com.ibm.icu.util does not exist. So I downloaded the ICU4J jar and installed it into the local repository. I confirmed it's in .m2/repository/com/ibm/icu/icu4j/3.4.4/icu4j-3.4.4.jar. Inside that jar file is the missing class file com/ibm/icu/util/Calendar.class. Then I added the following into the dependencies section of pom.xml:
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>3.4.4</version>
</dependency>
But when I run mvn compile again, I get the same error. What am I doing wrong?
You should avoid adding dependencies manually.
If you don't know a groupId and artifactId of the dependency you need, search for it at http://mvnrepository.com/. Usually, groupId matches the package names in the jar file.
For your case, the dependency is already there: http://mvnrepository.com/search?q=com.ibm.icu
So, go to http://mvnrepository.com/artifact/com.ibm.icu/icu4j and get the version of the dependency you need, e.g. 55.1: http://mvnrepository.com/artifact/com.ibm.icu/icu4j/55.1
Grab maven dependency xml and put it to your pom.xml file:
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>55.1</version>
</dependency>
If you didn't find your dependency try to find it in google. Sometimes the dependency may be found in some corporate public repositories, not in a central. In this case you need to add the third-party repository to repositories section of your pom.xml.
If you're unable to find your dependency in the public repository then you have three options:
A. Install jar to internal repository server (e.g. nexus)
B. Put the JAR file in your project sources and declare project maven repository :
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${basedir}/my-repo</url>
</repository>
</repositories>
Important: You should keep the maven repository layout in your local repository.
C. [Bad Practice] Use maven install plugin to install your custom jar to local repository on your machine. But it's a badIt's not recommended.
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=path-to-your-artifact-jar -DpomFile=path-to-pom
D. [Bad Practice] Use system dependency with absolute path to the JAR file, although it's a bad practice and should be avoided.
<dependency>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>X.Y.Z</version>
<scope>system</scope>
<systemPath>${user.home}/jars/my.jar</systemPath>
</dependency>
You should not be manually installing things into the maven repository directory. That directory is maintained by maven itself.
The way dependencies work is that when you run mvn compile or some other goal, it will connect to the maven central repository and download the needed dependencies and their dependencies.
If you manually install a jar file, it may not have it's dependencies. That icu artifact will likely have other things it depends on. Maven will automatically resolve these dependencies.
I would recommend using mvn clean install this will clean the target directory and rebuild everything.
If it fails to download, then you likely need to change the maven configuration. For example, if you are behind a proxy server you need to configure maven with the proxy credentials.
Also, if you manually copied anything into the .m2/repository/ directory you should delete it and let maven put it in there correctly instead.
The beauty of maven is that you don't need to worry about things like downloading jars. It just handles that for you. Let it do it's job.
If you have an internal artifactory like JFrog maybe you should check that the jar is there. Do not download manually to .m2 because it's at least strange. At most you can upload the jar in that artifactory manually.
Any maven experts out there? I inherited a huge maven project and am trying to get it to compile. Not getting very far. I go to the highest level pom.xml I can find, located in trunk directory, one level down from the main project. Then I issue command "mvn validate". Get the following error:
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/com/mycompany/neto/vsd/vsd-superpom/1.1.0/vsd-superpom-1.1.0.pom
[INFO] Unable to find resource 'com.mycompany.neto.vsd:vsd-superpom:pom:1.1.0' in repository central (http://repo1.maven.org/maven2)
I noticed a vsd-superpom folder at the same level as the main project so I'm guessing the main project needs to point to it somewhere? Looking at the pom.xml I see
<parent>
<groupId>com.mycompany.neto.vsd</groupId>
<artifactId>vsd-superpom</artifactId>
<version>1.1.0</version>
</parent>
Where do I put the vsd-superpom folder so that it will be found? I don't understand why it tries to download it. I don't see anything in pom.xml that tells it to do that.
Apache Maven has a two level strategy to resolve and distribute files, which we call artifacts. The first level is called the local repository, which is the artifact cache on your system, by default located at ${user.home}/.m2/repository. When executing Maven, it'll first look in this local cache for artifacts. If the artifact cannot be found here, Maven will access the remote repositories to find the artifact. Once found it will be stored into the local repository, so it's be available for current and future usage.
see Apache Maven Install Plugin Documentation
So if your super pom is independent of the rest of the project you can simply invoke mvn install from the super pom folder so that it will be placed into your local repository. That will solve your problem.
Usually the top-level project pom defines the project dependencies and it should be enough to invoke mvn verify | compile | ...
If the top-level pom depends on the super pom that you have to install the super pom first (or define a pom that contains the submodules super pom and rest of the project)
Common project structure what I have seen (and used) is:
foo-parent
pom.xml - parent POM for my modules with parent ../pom.xml
foo-module
pom.xml - module POM with parent ../foo-parent/pom.xml
...other modules...
pom.xml - multimodule POM without a parent
Now if I want to build foo-module I need to be in the top-level folder and run:
mvn -pl foo-module -am package
In other words you are always building the multi-module project. However you can specify that you are interested only in some submodules (-pl) and their dependencies (-am).