Home > Blockchain >  How to get folders, resources and pom file from a maven project to another maven project?
How to get folders, resources and pom file from a maven project to another maven project?

Time:10-25

I am trying my luck in eclipse to achieve something that I am able to successfully achieve using Visual Studio(.net project). I have a core-framework maven project with additional files and folders apart from the normal folders that maven provides. I exported it as jar file and added it as an external library to another maven project. Is there a way that when I add it as a library to the second project, the second project gets all the folders, files from the first maven project overwriting the pom file in the second maven project too? Inshort I want to make sure whoever takes the framework jar as reference follows the same folder structure as framework with required files such as config file, pom.xml file to avoid errors on missing path/files. I read about dependency management but even for that I have to define all the dependencies in child pom file which I want to avoid. Any help would be appreciated, I didn't find much info around the query.

CodePudding user response:

  1. Copying JAR files to lib folders is old-school. Such you also set aside Maven's sophisticated dependency (and transitive dependency) resolution. The clean Maven way is to put your core-framework JAR to a Maven repo (remote or local at the users machine) and let the users of it declare it as dependency in their projects.

  2. What do you exactly mean by "additional files and folders apart from the normal folders that maven provides"? What is there more than code and resources?

  3. To make your users' life easier concerning dependencies you could a) use a BOM (Bill Of Material) dependency or b) use inheritance (i.e. <parent> ← child relationship).

CodePudding user response:

Adding a dependency will not change your project in any way. You cannot add folders from a dependency to the project.

You can write a Maven archetype that is a kind of project template. Then people can use it to create new projects where the files are at the right places.

  • Related