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

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"

Related

How to create maven project as dependent jar to other projects without dependencies

I have a java project called "A" it has some custom annotations implemented in spring aop way and it is packaged as jar using maven jar plug-in, which contains only classes specific to project of A without any dependencies.now i have installed it in local maven repository using install command (mvn install:instlal-file) and used it as dependency in another maven project called "B".
I can able to get those annotations in project "B" but i cannot get dependencies automatically from pom file in dependent jar(project "A").due to which building project "B" is failing.
Q1: should we put all dependencies which we are using for project "A" in project "B" pom as well?
Q2: or it could get automatically downloaded from dependent jar pom file?
Note: am not interested in fat jar? but its working fine if we mention all dependencies in project "B". is there any way to get all dependencies when we build project "B" automatically?
Please help me in this.
I guess your error was to use mvn install:install-file. If you do not add the POM as parameter, an (almost) empty POM is created for you.
The right way:
Go to project A and run mvn clean install.
Then use A in B, and enjoy full transitive dependency resolution.
So, to summarize, the answer for Q1 is "no", and the answer for Q2 is "yes, use mvn clean install instead of mvn install:install-file.

Maven default evaluation of the pom xml file

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

How to update maven package after commit/pull-request

I am using a package https://github.com/dhatim/fastexcel, resently there was a commit in their repo, but the version had not been changed in Readme(description) of package in git hub, how can I update the package using maven?
I tried to run mvn release:update-versions, but I get this error
Then I run mvn release:update-versions -X
This is my pom.xml
The git repo is not equal the maven lib. You download maven libraries from the offical maven repository. The maintainer of the library needs to upload his artifact to the central repository when he builds a new release after that you can use this.
To see which version is usable you can use a maven search website like https://search.maven.org.
The dependency org.dhatim:fastexcel has a version 0.9.4 (same as the github release).
So it seems the developer already uploaded it but did not correct his Readme in the repository. So you can just use 0.9.4 in your pom.xml.
So always check the maven search site and if something is missing you can always add an issue to github to ask the developer uploading it.
There are also this more or less recommended possibilites to get library as a workaround:
Checkout and build the project by your self and add the jar file to:
something like nexus as own repository hosting (a organization normally has a maven proxy which could be used)
add it to the pom.xml as system scope dependency where the jar must be located on your system
use mvn install on the fastexcel project and change the version in your pom.xml to 0-SNAPSHOT

Cannot get the latest version of maven plugin

I am new to maven, I have write my own maven plugin with the pom file
<groupId>com.xxx.api</groupId>
<artifactId>xxx-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
then, in my IDE (intellij) I used clean install to install my maven plugin
and in the main project, my maven plugin works fine.
However, when I modify my maven plugin by adding parameter to my mojo and "mvn clean install" ,
(the groupId,artifactId,version keep the same) it supposed to be the latest version.
However, in the main project, when I try to use the latest maven plugin, I always get the old version
i.e I cannot configure the parameter that I just add to my maven plugin (because it is not exist!)
I have try to delete the maven plugin in my .m2 repo, before I install the latest version of my maven plugin, it still not work.
Any solution that I can get the latest version of my maven plugin by keeping the same
(groupId, artifactId,version)?
thanks,
Zach
Check how the using project is configured. I guess it has its own lib/classes folder. I would suspect that your project has a copy of the older version of the plugin in its lib folder. If so, that is where it is getting the old version. Clean it out from there, i.e. you need to clean the using project.

where to place customer jar in maven project structure

I have a dependency application jar from other maven applications,and currently added it to my application path,
I want to know how this application related jar can be automatically moved my local repository folders.
I think it should be placed in somewhere in maven project folder structure so that when maven build the module it automatically moves to the repository.
Dependent project:
If built with maven, you would issue a mvn install, when building it.
If not built with maven, install it locally using mvn install:install-file
http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html

Resources