[英]Installing local jar file to maven repo without using command line
我有一個Maven項目,我剛剛向其中添加了一些功能,因此必須添加本地jar依賴項。 我已經將此jar文件添加到Github上項目的lib文件夾中,並且我想創建它,以便從Github下載項目的任何人都可以將該jar安裝到其m2目錄中,而不必使用maven install:install-file命令通過命令行。 POM文件已經具有依賴性,但是在使用mvn install構建快照時,我需要一種以編程方式安裝jar文件的方法。
有什么想法嗎?
選項0:
將jar文件部署到公共或comany范圍的Maven存儲庫。 如果產生此jar的項目也是git(hub)項目,請考慮使用Jitpack之類的服務
選項1:
丑陋,但可以工作。
<dependency>
<groupId>com.bar</groupId>
<artifactId>foo</artifactId>
<version>42</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/foo-42.jar</systemPath>
</dependency>
選項2:
更加丑陋,但可能效果更好。
<build>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-foo</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<groupId>com.bar</groupId>
<artifactId>foo</artifactId>
<version>42</version>
<file>${project.basedir}/lib/foo-42.jar</file>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.