Maven Install plugin: parameter file is missing or invalid

后端 未结 1 400
野趣味
野趣味 2021-01-02 09:14

I have a local jar and I want to use it in my project. There are plenty ways to do it: just install manually into local repo, do it with script in parent pom, use system sco

相关标签:
1条回答
  • 2021-01-02 09:40

    The best way to deal with a separated jar is to start using a repository manager and install this jar via the UI into the repository manager. From that point you can use as a usual dependency. Makes life easier.

    If you like to install it as part of the build what you have tried that means you need to call maven like this:

    mvn package
    

    You should not mix up calling goals without life cylce like install:install-file with life-cycle parts as initialize.

    That is the reason why you got the described error message, cause the command line part needs required parameters which you didn't gave on command line.

    Combination like:

    mvn install:install-file initialize
    

    Make in Maven no sense (rarly). You have bound the maven-install-plugin to the life-clycle in your pom so you should simply call the life cylce:

    mvn initalize
    

    And you will get something like the following:

    [INFO] ------------------------------------------------------------------------
    [INFO] Building test 0.6-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install-file (default) @ test ---
    [INFO] Installing /home/mvntest/lib/jdom-1.0.jar to /home/.m2/repository/com/soebes/test/jacob/1.1/jacob-1.1.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.780s
    [INFO] Finished at: Sat Oct 25 12:19:30 CEST 2014
    [INFO] Final Memory: 6M/91M
    [INFO] ------------------------------------------------------------------------
    

    BUT: I have to say that installing an artifact like you did is bad practice. Best is to use a repository manager like Nexus, Artifactory or Archiva or if really don't like repository managers (I don't understand why, but this is a different story) you can use Stephen Connolly's non-maven-jar-maven-plugin

    Apart from all the above you should use more up-to-date versions of maven-install-plugin which current version number is 2.5.2

    0 讨论(0)
提交回复
热议问题