I am new to maven.
I want to reuse a maven module which is part of a maven git project in another maven git project.
I know how to create a maven module in a maven project but no idea about the best way to copy a maven module from project-1 to project-2(through command line or any ide)
Clone the git repository of project-1, and install it (mvn install). From project-2, declare a dependency on project-1. Whenever you need to update project-1, pull from the upstream and re-install.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Joined: Aug 08, 2013
Can you tell me a way to clean copy without adding dependency on project-1. As the main focus is to copy the structure and few class files and need not keep this copied module up to date with the module in project-1
If I'm understanding you correctly, you want to use code from an existing maven sub-module in your new project?
Then why don't you just clone the repository, and simply copy the required classes and paste them into the src folder of your own project?
Note that you may not be allowed to do everything I described here. Pay attention to project-1's license.
All of this should only really be useful if you plan to change the original code to fit your own needs. If you just need to interact with the classes, a dependency really is the best option. Maybe you can tell us more of your plans?
Joined: Aug 08, 2013
Yeah started with copying exsiting project and I started reusing some classes which I can and removed the rest.
But now I realise adding dependency of the packages I need to reuse is a reliable solution.
I have browsed through for steps to creating jar of a package and then adding this as dependency in pom of a project.
Could you please help me with the steps to the above
If you're not planning on changing the code in the package, I would advise to put a dependency directly on the third party maven project. There's really not much point in creating your own maven project using a subset of the available code.
If you are hell-bent on using a local subset, then create a new maven project, and simply move the packages that you need to your project's src/main/java folder. Then install and place a dependency on that project. You don't need to create jars yourself.
Joined: Jun 11, 2013
I have added the project as dependency in pom but as we are using spring , many beans in the existing project are not getting identified in the local project in runtime.
So in spring context.xml , I have tried adding the base package of the existing project in context:component-scan base-package= newprojectpackagepath,exisitingprojectpath
But I get many errors related to 'Injection of autowired dependencies failed'
Is it okay to add another repo(which is added as maven dependency) package path in springcontext of a project?