3
votes

I have made a small android library that I would like to made available on the central maven repository. I am trying to follow the steps listed here

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

Everything seems to be working fine until I get to the mvn release:perform stage. Then I get the following error.

[INFO] /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml:5: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon'). [INFO] /Volumes/AndroidDisk/persistent-cookies/target/checkout/AndroidManifest.xml:5: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name'). [ERROR] Error when generating sources. org.apache.maven.plugin.MojoExecutionException: at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:418) at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:107) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at 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) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: 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, Result = 1

So it would seem that it has problems finding the res folder. The project builds ok when I perform mvn clean install.

The 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>[email protected]:samddman/persistent-cookies.git</url>
        <connection>scm:git:[email protected]:samddman/persistent-cookies.git</connection>
        <developerConnection>scm:git:[email protected]: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>

What am I doing wrong?

2

2 Answers

1
votes

I use Maven to build a cross-platform project, my android pom.xml file has the following plugins for fetching the assets from the core project. I use mvn clean install to build the output. I've had issues with the configuration on some computers and I've had to manual copy assets to my android project folder prior to building.

Currently this configuration is working for me.

<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>
0
votes

Is your entire project checked into your SCM correctly? release:perform does a build from the SCM tag that release:prepare created, so if any files accidentally weren't checked in they'll be missing during release:perform.

You can manually inspect the target/checkout folder to see if everything is there, or even try to manually invoke mvn clean package inside target/checkout.