,所以我正在处理Facebook-android-SDK的过程中,将其包括在我们的CI过程中。
facebook/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.facebook.android</groupId>
<artifactId>facebook-android-sdk</artifactId>
<version>3.0.0-SNAPSHOT</version>
<name>facebook-android-sdk</name>
<packaging>apklib</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>ignored</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
<sdk>
<platform>16</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<ignoreMissingFile>false</ignoreMissingFile>
<file>target/generated-sources/r/com/facebook/android/R.java</file>
<outputFile>target/generated-sources/r/com/facebook/android/R.java</outputFile>
<regex>false</regex>
<token>static final int</token>
<value>static int</value>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<type>jar</type>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
因此,运行mvn clean package install
按预期构建并安装到本地存储库。
这样我就可以在我的android app pom.xml中使用它:
<!--Facebook sdk-->
<dependency>
<groupId>com.facebook.android</groupId>
<artifactId>facebook-android-sdk</artifactId>
<version>3.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
在Intellij中构建和运行的效果很大,它可以拉动依赖关系并添加到正确的位置。
问题
当我通过maven travis ci命令运行时,该命令是:
mvn install -DskipTests=true
然后:
mvn test
测试将失败,因为缺少类(即Facebook课程)。似乎在尝试通过Maven安装和测试时,它无法正确吸入Facebook Android-SDK。
so ,构建依赖关系是否存在问题,还是我需要在尝试运行mvn test
之前运行另一个神奇的Maven命令?
Facebook叉在这里可以避免:https://github.com/bizzby/facebook-android-sdk
您可以使用创建的可用Maven存储库来托管最新的Facebook Android API的Maven端口:
https://github.com/avianey/facebook-api-android-maven
正确,我的apklib pom.xml 很好!我的apk pom.xml 不正确。似乎从旧编译器版本到新版本存在一个向后兼容的问题。简而言之:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3</version>
<configuration>
<sdk>
<platform>${android.platform}</platform>
</sdk>
</configuration>
</plugin>
to:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<sdk>
<platform>${android.platform}</platform>
</sdk>
</configuration>
</plugin>
它神奇地开始工作!学习的教训,DEP/插件管理非常方便!
刚运行
mvn clean install
这样,它将运行测试,一切都很好。
顺便说一句
https://github.com/mosabua/facebook-android-sdk/tree/maven