Android的Maven的插件和库项目 [英] android-maven-plugin and library project
问题描述
这是从我的库项目的pom.xml。
我愿意MVN全新安装,一切都OK。在我的本地回购M2我apklib神器。
This is pom.xml from my library project. I do "mvn clean install" and everything is OK. In my local m2 repo I have apklib artifact.
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>actionbar</artifactId>
<groupId>com.markupartist.android</groupId>
<name>android-actionbar</name>
<packaging>apklib</packaging>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>2.2.1</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>android-maven-plugin</artifactId>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<version>3.3.0</version>
<configuration>
<sdk>
<path>
e:\Program Files\Android\android-sdk\
</path>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
这一次pom.xml的是我的主要项目,这是依赖于以上项目。
This one pom.xml is from my main project which is dependent on above project.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.main.app</groupId>
<artifactId>VirtualRecruiter</artifactId>
<version>1.0</version>
<packaging>apk</packaging>
<name>MainApp</name>
<properties>
<platform.version>2.2.1</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>actionbar</groupId>
<artifactId>com.markupartist.android</artifactId>
<version>1.0</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<path>
e:\Program Files\Android\android-sdk\
</path>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
的IntelliJ可以看到我的depedency很好,但是当我运行MVN清洁纂上的主体工程,我有:
˚F
IntelliJ can see my depedency well, but when I run "mvn clean compile" on main project, I have got: F
ailed执行项目MainApp的目标:无法解析
依赖项目
com.main.app:MainApp:apk:1.0:找不到
神器动作条:artist.android:apklib:1.0
ailed to execute goal on project MainApp: Could not resolve dependencies for project com.main.app:MainApp:apk:1.0: Could not find artifact actionbar:artist.android:apklib:1.0
当我使用'Systempath下',并使用硬codeD路径到我的神器,依赖可以通过Maven的发现,但我有编译错误和javac没有看到库项目的任何类。
When I use 'systemPath' and use hardcoded path to my artifact, dependency can be found by maven, but I have compilation error and javac don't see any class from library project.
推荐答案
在code你已经发布,你犯了一个小错误,也许这将解决您的问题。
on the code you have posted, you made a little mistake maybe it will fix your problem.
您已经倒在的groupId
和的artifactId
你的依赖,以便Maven的无法发现它。
You had inverted the groupId
and artifactId
on your dependency so Maven can't found it.
<dependency>
<groupId>actionbar</groupId>
<artifactId>com.markupartist.android</artifactId>
<version>1.0</version>
<type>apklib</type>
</dependency>
这篇关于Android的Maven的插件和库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!