我已经创建了一个小型的android库,我想在中央maven存储库上提供它。我正在尝试按照此处列出的步骤进行操作
https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
在我进入mvn版本之前,一切似乎都正常工作:执行阶段。然后我收到以下错误。
[INFO] /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml:5: 错误:错误:找不到与给定名称匹配的资源(在'icon'处 值'@ drawable / icon')。 [INFO] /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml:5: 错误:错误:找不到与给定名称匹配的资源(at 'label'的值为'@ string / app_name')。 [ERROR]生成源时出错。 org.apache.maven.plugin.MojoExecutionException: 在com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:418) 在com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:107) 在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 在org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 在org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在java.lang.reflect.Method.invoke(Method.java:597) 在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 引起:com.jayway.maven.plugins.android.ExecutionException:ANDROID-040-001:无法执行:Command = / bin / sh -c cd / Volumes / AndroidDisk / persistent-cookies / target / checkout&& / Users / sam / Development / android-sdk-macosx / platform-tools / aapt package -m -J / Volumes / AndroidDisk / persistent-cookies / target / checkout / target / generated-sources / r -M /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml --auto-add-overlay -I /Users/sam/Development/android-sdk-macosx/platforms/android-17/android.jar, 结果= 1
所以看起来它在找到res文件夹时遇到了问题。当我执行mvn clean install时,项目构建正常。
POM ......
<?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.github.samddman</groupId>
<artifactId>persistentcookiestore</artifactId>
<version>1.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>
<name>persistentcookies</name>
<description>A cookie store which persists cookies across app restarts</description>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<url>https://github.com/samddman/persistent-cookies</url>
<licenses>
<license>
<name>GNU General Public License, version 2 (GPL-2.0)</name>
<url>http://opensource.org/licenses/gpl-2.0.php</url>
</license>
</licenses>
<scm>
<url>git@github.com:samddman/persistent-cookies.git</url>
<connection>scm:git:git@github.com:samddman/persistent-cookies.git</connection>
<developerConnection>scm:git:git@github.com:samddman/persistent-cookies.git</developerConnection>
</scm>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.2.2_r2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<sdk>
<platform>17</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin> -->
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.2</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>
<platform>17</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/res</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/templates/res</directory>
<targetPath>${project.basedir}/res</targetPath>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</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>
我做错了什么?
答案 0 :(得分:1)
我使用Maven构建跨平台项目,我的android pom.xml文件具有以下插件,用于从核心项目中获取资源。我使用mvn clean install
来构建输出。我在某些计算机上遇到了配置问题,我不得不在构建之前手动将资产复制到我的android项目文件夹。
目前这种配置对我有用。
<plugins>
<plugin>
<groupId>com.pyx4j</groupId>
<artifactId>maven-junction-plugin</artifactId>
<version>1.0.3</version>
<!-- generate a symlink to our assets directory in the proper location -->
<configuration>
<links>
<link>
<src>${basedir}/../assets/src/main/resources/assets</src>
<dst>${basedir}/assets</dst>
</link>
</links>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.maven.version}</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<sdk>
<platform>16</platform>
<path>C:\sdks\android-sdks</path>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<jvmArguments>
<jvmArgument>-Xmx1024m</jvmArgument>
</jvmArguments>
<dex>
<jvmArguments>
<jvmArgument>-Xmx1024m</jvmArgument>
</jvmArguments>
</dex>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
答案 1 :(得分:0)
您的整个项目是否正确检入了您的SCM? release:perform从发布的SCM标签进行构建:prepare created,所以如果任何文件意外未被检入,它们将在发布期间丢失:执行。
您可以手动检查目标/结帐文件夹以查看是否存在所有内容,甚至尝试在目标/结帐中手动调用mvn clean包。