简体   繁体   中英

Maven Install plugin: parameter file is missing or invalid

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 scope, use local repo declaration.

I decided to use Maven Install plugin to install jar into the repo. Here is a configuration:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
            <execution>
                <phase>initialize</phase>
                <goals>
                    <goal>install-file</goal>
                </goals>
                <configuration>
                    <groupId>jacob</groupId>
                    <artifactId>jacob</artifactId>
                    <version>1.0</version>
                    <packaging>jar</packaging>
                    <file>${basedir}\lib\jacob.jar</file>
                </configuration>
            </execution>
        </executions>
    </plugin>

I tried to run it in many ways: mvn initialize install:install-file mvn initialize mvn install:install-file

But all the time I have an exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project MYPROJECTNAME: The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file are missing or invalid ->

I just want to find out why it doesn't work? Looks like I am messed with phases and goals..

Finally I went another way: I placed it into my parent POM, but why it works with parent and doesn't work with child?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM