这是我的库项目中的pom.xml。 我做“mvn clean install”,一切都很好。在我当地的m2回购中,我有apklib神器。
<?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来自我的主项目,它取决于上面的项目。
<?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可以很好地看到我的依赖,但是当我在主项目上运行“mvn clean compile”时,我得到了: ˚F
ailed在项目MainApp上执行目标:无法解决 项目的依赖项 com.main.app:MainApp:apk:1.0:找不到 artifact actionbar:artist.android:apklib:1.0
当我使用'systemPath'并使用硬编码路径到我的工件时,maven可以找到依赖关系,但是我有编译错误,javac没有看到库项目中的任何类。
答案 0 :(得分:1)
关于您发布的代码,您犯了一个小错误,也许它会解决您的问题。
您已将groupId
和artifactId
置于依赖关系上,因此Maven无法找到它。
<dependency>
<groupId>actionbar</groupId>
<artifactId>com.markupartist.android</artifactId>
<version>1.0</version>
<type>apklib</type>
</dependency>