我的Android项目中有一个JAR,我想将它添加到最终的APK中.好的,我走了:
<dependency>
<groupId>com.loopj.android.http</groupId>
<artifactId>android-async-http</artifactId>
<version>1.3.2</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${project.basedir}/libs/android-async-http-1.3.2.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时,mvn package我收到警告:
[WARNING] Some problems were encountered while building the effective model for **apk:1.0
[WARNING] 'dependencies.dependency.systemPath' for com.loopj.android.http:android-async-http:jar should not point at files within the project directory, ${project.basedir}/libs/android-async-http-1.3.2.jar will be unresolvable by dependent projects @ line 36, column 25
Run Code Online (Sandbox Code Playgroud)
在最终的APK中没有JAR.
我该如何解决这个问题?
Gin*_*g3r 133
我不知道真正的原因,但Maven推动开发人员将所有库(自定义)安装到一些maven存储库中,因此scope:system不太受欢迎,一个简单的解决方法是使用maven-install-plugin
按照用法:
以这种方式写你的依赖
<dependency>
<groupId>com.mylib</groupId>
<artifactId>mylib-core</artifactId>
<version>0.0.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
然后,添加maven-install-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/lib/mylib-core-0.0.1.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.mylib</groupId>
<artifactId>mylib-core</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
注意phase:clean,要将自定义库安装到存储库中,必须先运行mvn clean然后再运行mvn install
bma*_*ies 11
系统范围仅用于处理"系统"文件; 文件坐在一些固定的位置.文件/usr/lib,或${java.home}(例如tools.jar).它不是为了支持.jar项目中的杂项文件而设计的.
作者故意拒绝使路径扩展工作正确,以阻止你.因此,在短期内您可以使用install:install-file安装到本地仓库,然后有一天使用repo管理器进行共享.
小智 9
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
尝试这个。
| 归档时间: |
|
| 查看次数: |
98450 次 |
| 最近记录: |