使用maven給jar包生成對應的pom文件

參考:

https://blog.csdn.net/qq_31289187/article/details/81117478

 

1. 背景

公司不允許使用外網進行安卓開發,所以在內網裏無法連接google和jcenter的庫,也無法使用阿里雲的國內鏡像。所以只能使用本地文件,進行項目的構建,但是在項目構建的過程中,會報如下錯誤。

Could not find androidx.databinding:databinding-compiler:4.0.1.

Search in the following locations:

   -file:/D:/Library/Androidsdk/SDK/extras/android/m2repository/androidx/databinding/databinding-compiler/4.0.1/databinding-compiler-4.0.1.pom

該錯誤的意思就是在我本地的倉庫中,沒有找到databinding-compiler-4.0.1.pom這個文件。

因此我們需要找到databinding-compiler-4.0.1.pom文件,並粘貼在對應的文件夾下。

2. 如何根據jar生成對應的Pom文件

2.1 命令

這裏,我就根據出現的錯誤,生成對應的databinding-compiler-4.0.1.pom文件。具體命令如下:

mvn install:install-file -DgroupId=androidx.databinding -DartifactId=databinding-compiler -Dversion=4.0.1 
-Dfile=D:/testGenPom/databinding-compiler-4.0.1.jar -Dpackaging=jar -DgeneratePom=true

命令執行的結果如下: 

2.2 參數解釋

DgroupId:是項目組織唯一的標識符,即groupId,如果是自己的jar包,可以隨便起名;如果是第三方庫,可以去maven repository查到該jar包的信息;
DartifactId:項目的唯一的標識符,即artifactId,與DgroupId的解釋一樣;
Dversion:項目版本;
Dfile:jar包路徑(絕對路徑),在本地存儲的jar包的地址;
DgeneratePom:是否生成pom文件,ture:生成,false:不生成;



2.3 生成的pom文件

然後去命令執行結果的所顯示的文件夾下找到databinding-compiler-4.0.1.pom文件,也就是上圖畫紅線的部分。

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>androidx.databinding</groupId>
  <artifactId>databinding-compiler</artifactId>
  <version>4.0.1</version>
  <description>POM was created from install:install-file</description>
</project>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章