简体   繁体   中英

how maven-install-plugin work with pom configure to install some jars one time

when I install one jar,the pom like

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-install-plugin</artifactId>
   <version>2.4</version>
   <configuration>
      <groupId>org.oracle</groupId>
      <artifactId>oraclejdbc</artifactId>
      <version>14</version>
      <packaging>jar</packaging>
      <file>${basedir}/libs/ojdbc14.jar</file>
   </configuration>
   <executions>
      <execution>
         <id>install-jar-lib</id>
         <goals>
            <goal>install-file</goal>
         </goals>
         <phase>validate</phase>
      </execution>
   </executions>
</plugin>

then

 mvn install:install-file

it works,but I want install some jars not only one,so I edit the pom like

        <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>install-artifacts.1</id>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <phase>clean</phase>
                        <configuration>
                            <groupId>org.oracle</groupId>
                            <artifactId>oraclejdbc</artifactId>
                            <packaging>jar</packaging>
                            <version>14</version>
                            <file>${basedir}/libs/ojdbc14.jar</file>
                        </configuration>
                    </execution>
                    <execution>
                        <id>install-artifacts.2</id>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/libs/sqljdbc4.jar</file>
                            <groupId>com.microsoft.sqlserver</groupId>
                            <packaging>jar</packaging>
                            <artifactId>sqljdbc</artifactId>
                            <version>1.0</version>
                        </configuration>
                    </execution>
              </executions>
     </plugin>

then

mvn install:install-file

But,the console show

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

what should I do? thanks!

On executing from command line the goal requires the parameter file which could be provided as:

mvn install:install-file -Dfile=.../libs/ojdbc14.jar

Or using the same configuration as specified in your pom.xml you can simply execute

mvn install

Also, note the artifactId in one of your execution doesn't seem valid

<file>${basedir}/libs/sqljdbc4.jar</file>
<groupId>com.microsoft.sqlserver</groupId>
<packaging>jar</packaging>
<artifactId>sqljdbc</artifactId> <!--this might be sqljdbc4-->

and when you don't have POM for 3rd party artifacts, you can follow generic pom generation and make use of

mvn install:install-file  -Dfile=path-to-your-artifact-jar \
                          -DgroupId=your.groupId \
                          -DartifactId=your-artifactId \
                          -Dversion=version \
                          -Dpackaging=jar \
                          -DgeneratePom=true

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