Home Navigation

Thursday 6 October 2016

Publish jar to file system local repository maven deploy

  • Create a local repository directory for example C:\localRepo
  • Here you have two way to publish jar in local repo, either you can create a batch script to publish all of the jars together or open command terminal and execute batch command one by one.
Command Line:
>mvn install:install-file -DgroupId=%groupId% -DartifactId=%artifactid% -Dversion=%versionId% -Dpackaging=jar -Dfile=%JarFile% -DlocalRepositoryPath=C:\localRepo 

BatchScript:
I have added eight jar files to publish, you can adjust the script according to your need.

@echo off
title repository workbrain local setup
color 1f
:: ###################################
cls
:start
echo Maven local workbrain repository setup
call mvn install:install-file -Dfile=axis.jar  -DgroupId=axis -Dversion=axis -DartifactId=axis -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=commons-discovery.jar  -DgroupId=commons-discovery -Dversion=commons-discovery -DartifactId=commons-discovery -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=commons-logging.jar  -DgroupId=commons-logging -Dversion=commons-logging -DartifactId=commons-logging -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=jaxrpc.jar  -DgroupId=jaxrpc -Dversion=jaxrpc -DartifactId=jaxrpc -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=log4j.jar  -DgroupId=log4j -Dversion=log4j -DartifactId=log4j -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=saaj.jar  -DgroupId=saaj -Dversion=saaj -DartifactId=saaj -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=soap.jar  -DgroupId=soap -Dversion=soap -DartifactId=soap -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
call mvn install:install-file -Dfile=wsdl4j.jar  -DgroupId=wsdl4j -Dversion=wsdl4j -DartifactId=wsdl4j -Dpackaging=jar -DlocalRepositoryPath=C:\localRepo
echo.
echo ######################################################
echo All done :-)
echo ######################################################
pause>null



Open pom.xml file of your project and add the below tag under repositories tag


<repository>
      <id>internal local repository</id>
       <url>file://C:\localRepo</url>
</repository>

Then you can add your dependency in the  dependency tag.

Build your project

No comments:

Post a Comment