Search code examples
mavenrepositorym2e

Is there any way to include all the outside .jar into maven repository without using the install:install file command


In my project, a lot of .jar files are used and they are not in the maven repository(both local and web).

Exception using install command to include them in the repository one by one, is there any approach or plugin to put them in the repository for one time.

And if there is, please tell me how to do it.


Solution

  • As Kal says in the comments, use a script. This is what we use - just modify the values in each of the set statements

    set GROUP_ID=someNamespace
    set ARTIFACT_ID=myartifact
    set VERSION=1
    set COMPONENT=%ARTIFACT_ID%-%VERSION%
    set FILEPATH=D:\my.jar
    
    call mvn install:install-file ^
     -DgroupId=%GROUP_ID% ^
     -DartifactId=%ARTIFACT_ID% ^
     -Dversion=%VERSION% ^
     -Dfile=%FILEPATH% ^
     -Dpackaging=jar ^
     -DgeneratePom=true
    
    set GROUP_ID=someNamespace2
    set ARTIFACT_ID=myartifact2
    set VERSION=1
    set COMPONENT=%ARTIFACT_ID%-%VERSION%
    set FILEPATH=D:\my2.jar
    
    call mvn install:install-file ^
     -DgroupId=%GROUP_ID% ^
     -DartifactId=%ARTIFACT_ID% ^
     -Dversion=%VERSION% ^
     -Dfile=%FILEPATH% ^
     -Dpackaging=jar ^
     -DgeneratePom=true