Maven default evaluation of the pom xml file - maven

We do not have project design in parent and module way.We have project A and project B . Project A has dependency of project B . we passing the version of the dependency jar by command prompt in eclipse, Its compiling and install properly. but its pom shows always error.and error is like
Missing artifact
com.testdependency:testdependency:jar:org.apache.maven.model.Build#5ae16e48
Passed the build parameter by command line like -Dbuild. Is there any way resolve this ?

pom.xml would need the dependencies present in your local .m2 repository. If you don't install the dependencies to your local repository, pom.xml can't find them. So, run a build on your dependency project with goals selected as clean install, which should insall the artifact to your local repository. Then in your eclipse, right click on the main project and execute Maven -> Update Project. This should resolve your issue.
Refer to this link for the details on the repositories

Related

How to build maven project With existing jar in local maven repository

I have issue with Project Building in Maven. I have updated some code in one of the dependency jars which is available in Maven Repository .I need to build my project with the jar i have modified.How to do that .Kindly Help me.
1. Install mvn project
Make sure to install your changed code into your repository.
Run following maven command for your updated library project.
mvn install
2. Check dependency
Check if the version of your library project match with the dependency entry in your main project pom.
E. g. if you install version "1.1" make sure the dependency entry is also "1.1"

IntelliJ uses snapshots with timestamps instead of -SNAPSHOT to build artifact

I have a project with snapshot dependencies. For simplification let's say that there is an project A which depends on library B-0.1-SNAPSHOT.
A depends on B
B resides within Nexus repository as a snapshot. I can see that it is stored with timestamp so the actual name in Nexus is something like: B-0.1-20141126.171716-67.jar
After executing:
mvn clean install -U
on project A, dependency B is downloaded from Nexus to my local repository. There I can find two jars of library B:
B-0.1-SNAPSHOT.jar
B-0.1-20141126.171716-67.jar
So far so good.
After maven build is complete I can see that B-0.1-SNAPSHOT.jar was taken to build A artifact (.war file)
I also have project A imported to IntelliJ as a maven project. There I run it on Tomcat. Project is build by IntelliJ and B-0.1-20141126.171716-67.jar is added to .war file.
At the end I have .war with both B-0.1-SNAPSHOT.jar and B-0.1-20141126.171716-67.jar within WEB-INF/lib directory.
For me is seems like a bug in IntelliJ because B-0.1-SNAPSHOT.jar should be taken from local maven repository... not the timespamped version. Is there any way to force IntelliJ to act propeply?
Maven version is 3.2.3, IntelliJ 14.0.1 (but the same behavior was on 13).
I was faced to the same problem today, and I found how to disable this feature.
F4 on your module, and go to artifacts then select the name of your artifact webapp:exploded and check the show contents radio at the bottom of the frame.
Go to WEB-INF/lib and search for your dependecy B-0.1-SNAPSHOT.jar and expand the line you will see a compile output folder in it, just remove it, then repackage and run, you will now only have the B-0.1-SNAPSHOT.jar and the one with the timestamp should be gone.
The downside of this is that you will have to make sure to mvn install your B module before running the A module within IntelliJ, because IntelliJ won't package your dependency and bundle it with the code you've just edited but not installed in your local maven repository.

IntelliJ - How to link modules for maven goal

I have successfully imported a parent pom with child modules into IntelliJ. The child modules have dependencies between themselves and IntelliJ has correctly set up the classpaths so that changes to module A are reflected in module B. However these dependencies are not maintained when I execute a maven goal in IntelliJ (compile, jetty:run etc). Here is my structure:
client_libs
-- servlet-filter
-- filter-example
filter-example depends on servlet-filter. However when I run maven compile on filter-example I get:
The POM for com.cloudseal.client:servlet-filter:jar:1.0-SNAPSHOT is missing, no dependency information available
I can work around this by manually installing servlet-filter into my local repo before I execute a maven goal but obviously this is not ideal. How can I get IntelliJ to maintain the relationships between the modules when I execute a maven goal?
You shall be able to just run mvn package but from place/path where your parent pom is.
If this's not working for you, please post your pom.xml files.

tycho plugin + maven-dependency-plugin: copy dependencies from local projects instead repositories

Main Goal: deploy a project as jar and eclipse-plugin
current state: project builds fine as jar package
Now i want to create a second project which wraps the jar project as eclipse plugin
use tycho-maven-plugin to create eclipse-plugin
add the jar of the original project (with copy-dependency)
add an Activator
export packages from jar
create correct MANIFEST.MF
i tried to copy the jar with copy-dependencies bound to create-resources. This works as long the jar is found in repository, but the local project gets ignored.
This results in a build failure since the jar is not found.
Is it possible to tell copy-dependencies to take the jar from the target directory of the project? Or should i use some other method than using tycho?
Edit:
I solved my problem with 4 projects:
normal project (nothing special here)
the wrapper project using tycho maven and copy-dependencies.
bound copy dependencies to some goal before compile (e.g. generate-resources). Excluded all artefactid which were set as dependency in the MANIFEST.MF.
a prepare project, which calls the normal project and installs it into the repo. This is needed because the tycho-maven-plugin is bound to validate and it is not possible to call the exec plugin beforehand (at least not easy).
a multi module project which calls the prepare project before the wrapper project.
Build your local project (which artifact was missed) with "mvm install". It will be deployed in your local repository ($USER_HOME$/.m2/repositories). After this dependency should be resolved.
Alternatively you can "mvn deploy" if you have local company maven repository like Artifactory or Nexus.

Maven beginner question, get m2eclipse to download jar and add to build path?

From what I have read, after adding the relevant maven repositories, maven should automatically download the necessary jars to satisfy dependencies in the pom.xml file.
However, no jars ever get downloaded for me after I add dependencies in eclipse. Am I missing some glaringly obvious step?
I'd recommend to start from creating your project with m2eclipse. See more details in this article.
Basically, you need to make sure the following:
your Eclipse project has a valid pom.xml and all dependencies are available (you should see errors on Maven console, in the Problems or Markers view or when opening pom.xml in m2eclipse's POM editor)
Maven support is enabled for this project (you can use Maven / Enable Dependency Management from popup menu on that project)
project configuration is in sync with pom.xml (you can use Maven / Update Project Configuration from the project popup menu)
you can also use Maven / Update Dependencies to refresh your dependencies (e.g. when you got them in your Local Maven repo from the command line)
Dependencies jars aren't in your project but in your local maven repository.
These jars will be automatically used when you compile you project with maven (or m2eclipse).
If you don't have the needed jar yet, maven will download it for you.

Resources