Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install maven archetype project jar with *.pom file to local repo

i`m kinda new to maven and want to know how to install an archetype jar to my local repo

i got a directory com.foo with the following files:

maven_metadata_local.xml
[1.00.00-SNAPSHOT] 

which containes these files

_maven.repository
   foo-archetype-1.00.00-SNAPSHOT.jar
   foo-archetype-1.00.00-SNAPSHOT.pom
   maven_metadata_local.xml

from what i read i understand that there is a way to build a template project using this archetype but first i need to install it to my local repo how can i do this?

thanks

like image 275
user1991557 Avatar asked Jan 18 '13 19:01

user1991557


People also ask

Is mvn install command is used to install jar file in local repository?

In this case you can perform mvn initialize and jar will be installed in local maven repo. Now this jar is available during any maven step on this machine (do not forget to include this dependency as any other maven dependency in pom with <dependency></dependency> tag).


2 Answers

i managed to do that:

what i did is opened the maven_metadata_local.xml to get the groupId, artifactId, and version

run this command from that directory

mvn install:install-file                            
-Dfile=foo-archetype-1.00.00-SNAPSHOT.jar     \
-DgroupId=com.foo                             \
-DartifactId=foo-archetype                    \
-Dversion=1.00.00-SNAPSHOT                    \
-Dpackaging=jar                               \
-DgeneratePom=true

once compleated (BUILD SUCCESS) i got the build in my local repository go to a folder from which i want to create a project run this command

mvn archetype:generate                \
-DarchetypeGroupId=com.foo            \
-DarchetypeArtifactId=foo-archetype   \
-DarchetypeVersion=1.00.00-SNAPSHOT   \
-DgroupId=com.mycom                   \
-DartifactId=myApp                    \
-Dversion=myversion-SNAPSHOT

in eclipse i imported an existing maven project, right click on the project->maven->update and i got the full build ready to work

like image 127
user1991557 Avatar answered Oct 23 '22 10:10

user1991557


Adding an archetype to your local repository is no different than adding any other dependency. You can simply run a mvn install command on it.

like image 30
gregwhitaker Avatar answered Oct 23 '22 11:10

gregwhitaker