How to update a jar that used on another project - maven

I have two project.First project's name is studentApp, second one is coursesApp. I have imported two project on eclipse.First project(studentApp) uses courseApp jar as maven dependency.
I implemented a feature on studentApp project but this feature uses coursesApp project's service classes. Therefore, I had to change service classes on coursesApp project. Right now , my student project does not see service classes because jar is 1.0.I used mvn clean install commond on second project and created a new jar 1.0.1.
Now, I changed my pom.xml on first project to change version.I made 1.0.1 I used
mvn clean installbut there is no jar.How can I do now? I think jar is on company repo.Do i have to add a new jar to company repo everytime to make changes?

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.

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

IntelliJ Maven is correctly generating maven local repository but not adding the dependencies

Hi I am trying to port a mid sized Maven project to IntelliJ Idea 12 (from Eclipse).
There are around 30 different modules in the project.
I am running an MVN install on each module via IntelliJ lifecycle management.
The jars are being correctly generated, and deposited into my local repository directory. It is also correctly picking up the third party libraries.
However IntelliJ is sometimes requiring me to then add the generated jars to my classpath as a dependency. (It is not enough to simply say "Add Maven Dependency", I have to physically add the generated jar as a library.)
In other cases it works correctly. Not sure why it is not consistent.
Have you tried updating the local Maven repository in IntelliJ IDEA? You can do so by opening Preferences->Maven->Repositories, than select your local repository and click on 'Update'.

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.

Building all dependencies in Maven

I have a Ear, war and 2 jar projects in my eclipse.
I want to automatically build 2 jars, war and ear project, when i run the pom inside ear project.
I remember doing this in maven in the past. But i forgot since i lost touch working with Maven for few years now.
Someone please remind me of that..
I used dependency compile, but it is not building jar, when i build the ear directly.
Should i first run pom in jar? does it not build that jar automatically when i build ear?
Create a multi module build that will build it all for you in the reactor. Read more about it e.g. http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html#pom-relationships-sect-multi-vs-inherit
I guess you should define tha .jar and .war projects as dependencies of your .ear project. It is also advisable to have a parent pom, where all the projects are defined as modules, including the .ear project.
In this book you can find a well explained step-by-step setup of a maven multimodule project (with downloadable code).
There is also a great working example of an enterprise multimodule project in the JBoss quickstart examples.

Resources