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

user1991557 picture user1991557 · Jan 18, 2013 · Viewed 8.8k times · Source

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

Answer

user1991557 picture user1991557 · Jan 21, 2013

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