How to add a jar, source and Javadoc to the local Maven repository?

前端 未结 3 776
你的背包
你的背包 2021-01-30 08:52

I\'m wanting to add the latest version of JGoodies Forms (1.5.0) as a dependency, but I can\'t find anything newer than 1.0.5 in the main repository, so if I understand correctl

相关标签:
3条回答
  • 2021-01-30 09:23

    Update: Even though this is the accepted answer, please check the answer of Emmanuel Bourg below - his answer is probably what you would like to do, especially if you're having a snapshot version.


    You can use the maven deploy plugin for that. It has a goal for deploying a single file to any repository. For the jar itself:

    mvn deploy:deploy-file \
        -DgroupId=com.yourname.jgoodies \
        -DartifactId=jgoodies-forms \
        -Dversion=1.50 \
        -Dfile=/path/to/jgoodies-1.50.jar \
        -Dpackaging=jar \
        -Durl=file://path/to/your/local/repository 
    

    For the sources:

    mvn deploy:deploy-file \
        -DgroupId=com.yourname.jgoodies \
        -DartifactId=jgoodies-forms \
        -Dversion=1.50 \
        -Dfile=/path/to/jgoodies-sources.jar \
        -Dpackaging=jar \
        -Durl=file://path/to/your/local/repository \
        -Dclassifier=sources
    

    For the javadoc:

    mvn deploy:deploy-file \
        -DgroupId=com.yourname.jgoodies \
        -DartifactId=jgoodies-forms \
        -Dversion=1.50 \
        -Dfile=/path/to/jgoodies-javadoc.jar \
        -Dpackaging=jar \
        -Durl=file://path/to/your/local/repository \
        -Dclassifier=javadoc
    

    Note that this will generate a standard POM, so you won't have the dependencies of JGoodies (if any) pulled automatically but have to specify them manually in your project.

    0 讨论(0)
  • 2021-01-30 09:32

    Install the jar you have downloaded using this mini guide :

    http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

    You should install jgoodies-form-1.5.0.jar by typing:

    mvn install:install-file -Dfile=<path-to-file>/jgoodies-form-1.5.0.jar \ 
    -DgroupId=jgoodies -DartifactId=forms -Dversion=1.5.0 -Dpackaging=jar
    

    don't forget to do the same with jgoodies-commons.

    For you to be able to access the source code and the contextual javadoc you can either

    • uncompress the jgoodies form zip and make eclipse points to the src folder

    • generates a jgoodies-form-1.5.0-src.jar by putting the src directory in it and install it in your local repo the same way you did for the jar

    0 讨论(0)
  • 2021-01-30 09:37

    Here is the syntax to deploy the binary, the sources and the javadoc with a single command:

    mvn deploy:deploy-file \
        -DgroupId=com.jgoodies \
        -DartifactId=jgoodies-forms \
        -Dversion=1.6.0 \
        -Dfile=jgoodies-forms-1.6.0.jar \
        -Dsources=jgoodies-forms-1.6.0-sources.jar \
        -Djavadoc=jgoodies-forms-1.6.0-javadoc.jar \
        -Durl=file://path/to/your/local/repository
    
    0 讨论(0)
提交回复
热议问题