3

我制作了一个小型 android 库,我想在中央 maven 存储库中提供它。我正在尝试按照此处列出的步骤

https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide

在我进入 mvn release:perform 阶段之前,一切似乎都运行良好。然后我收到以下错误。

[信息] /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml:5:错误:错误:找不到与给定名称匹配的资源(在“图标”处,值为“@drawable/icon”)。[INFO] /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml:5:错误:错误:找不到与给定名称匹配的资源(在“标签”处,值为“@string/app_name”)。[错误] 生成源时出错。org.apache.maven.plugin.MojoExecutionException: 在 com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute( GenerateSourcesMojo.java:107) 在 org.apache.maven.plugin.DefaultBuildPluginManager。

所以它似乎在找到 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>

我究竟做错了什么?

4

2 回答 2

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>
于 2013-05-07T18:34:34.927 回答
0

您的整个项目是否正确签入您的 SCM?release:perform 从 release:prepare 创建的 SCM 标签进行构建,因此如果任何文件意外未检入,它们将在 release:perform 期间丢失。

您可以手动检查 target/checkout 文件夹以查看是否所有内容都在那里,甚至可以尝试在 target/checkout 中手动调用 mvn clean package。

于 2013-05-09T06:37:12.523 回答