问题描述
我当前正在使用:
mvn install:install-file -Dfile={path/to/my/legacy.jar} -DgroupId=horrible -DartifactId=legacy.jar -Dversion=1.2.3 -Dpackaging=jar
导入一些旧的遗留罐到我的仓库中.这很好用,是推荐的方法.似乎可以用POM代替我现在使用的命令行+脚本来完成.我认为这样比较干净:
to import some old legacy jars into my repo. This has worked fine and is the recommended approach. It seems as though this could be done with a POM instead of at the commandline + script that I'm using now. I think it's cleaner to have:
mvn install:install-file
,然后让我的仓库存储版本详细信息,而不是将此信息存储在非Maven脚本中(这对Maven来说很奇怪).我试图通过settings标签公开这些-D设置,但是没有用.还有其他人尝试过并使其起作用吗?
and let my repo store the version details rather than store this information in a non-maven script (which is odd for maven). I tried to expose these -D settings via the settings tag but that didn't work. Has any one else tried this and got it to work?
推荐答案
好的,回答我自己的问题:P.您可以通过定义属性来做到这一点,我最初假设groupId等会自动导出为属性,但事实并非如此.
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
和这个pom.xml.我已经用Maven 3而不是2进行了测试.
and this pom.xml. I have tested this with maven 3 and not 2.
有关多个文件,另请参见 Maven POM文件安装多个第三方商业图书馆
For multiple files also see Maven POM file for installing multiple 3rd party commercial libraries
这篇关于使用POM而不是命令行安装文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!