Install File Using POM instead of commandline

前端 未结 1 1973
盖世英雄少女心
盖世英雄少女心 2020-12-24 02:36

I\'m currently using:

mvn install:install-file -Dfile={path/to/my/legacy.jar} -DgroupId=horrible -DartifactId=legacy.jar -Dversion=1.2.3 -Dpackaging=jar


        
相关标签:
1条回答
  • 2020-12-24 02:46

    Okay, answering my own question :P. You can do this by defining properties, I originally assumed the groupId etc were auto exported as properties but they are not.

    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.whatever</groupId>
      <artifactId>Stuff</artifactId>
      <version>1.2.3</version>
    
      <description>
      Description of why this horrible jar exists.
      </description>
    
      <properties> 
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <packaging>${project.packaging}</packaging>
        <file>mylegacy.jar</file>
      </properties>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <executions>
              <execution>
                <phase>install</phase>
                <goals>
                  <goal>install-file</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    
    </project>
    

    You can now install files using:

    mvn install
    

    and this pom.xml. I have tested this with maven 3 and not 2.

    For multiple files also see Maven POM file for installing multiple 3rd party commercial libraries

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