1
I'm new to Android maven integration in to sonar dashboard. My aim is thru Android JUnit to get the code coverage using Emma and integrate that into sonar dashboard.

我在这样做时遇到了困难,并且遇到了以下异常。使用以下命令运行开发项目时

mvn clean install -Pemma

Please find the maven details below,



Apache Maven 3.0.4 (r1232337; 2012-01-17 14:14:56+0530)
Maven home: G:\Projects\apache-maven-3.0.4-bin\apache-maven-3.0.4\bin\..
Java version: 1.6.0, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows vista", version: "6.1", arch: "x86", family: "windows"

http://maven.apache.org/maven-v4_0_0.xsd">4.0.0

<parent>
    <groupId>andersen.project</groupId>
    <artifactId>Hello-parent</artifactId>
    <version>1.0</version>
</parent>

<groupId>andersen.project</groupId>
<artifactId>MyProject</artifactId>
<packaging>apk</packaging>
<version>1.0</version>

<name>MyProject- Application</name>

<dependencies>

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.0</version>
        <scope>system</scope>

        <systemPath>E:\android_sdk\add-ons\addon-google_apis-google_inc_-14\libs\maps.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>android</groupId>
        <artifactId>android</artifactId>
        <systemPath>E:\android_sdk\platforms\android-14\android.jar</systemPath>
        <version>4.0</version>
        <scope>system</scope>
    </dependency>

    <dependency>
        <groupId>deps</groupId>
        <artifactId>dep1</artifactId>
        <version>0.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/libs/acra-4.2.3.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>deps</groupId>
        <artifactId>dep2</artifactId>
        <version>0.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/libs/GoogleAdMobAdsSdk-6.1.0.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>deps</groupId>
        <artifactId>dep3</artifactId>
        <version>0.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/libs/GSAndroidSDK.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>deps</groupId>
        <artifactId>dep4</artifactId>
        <version>0.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/libs/GSAndroidSDK_src.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>deps</groupId>
        <artifactId>dep5</artifactId>
        <version>0.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/libs/MMBrandedSDK.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>deps</groupId>
        <artifactId>dep6</artifactId>
        <version>0.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/bin/classes.dex</systemPath>
    </dependency>
<dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
      <exclusions>
          <exclusion>
              <groupId>xml-apis</groupId>
              <artifactId>xml-apis</artifactId>
          </exclusion>
      </exclusions>
  </dependency>
</dependencies> 



<profiles>
    <profile>
        <id>emma</id>
        <build>

            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.4.1</version>
                    <configuration>                      <!-- emma start -->
                        <emma>
                            <enable>true</enable>
                            <classFolders>${project.basedir}/target/classes/</classFolders>
                            <outputMetaFile>${project.basedir}/target/emma/coverage.em</outputMetaFile>
                        </emma>                        <!-- emma stop -->
                        <dex>
                            <noLocals>true</noLocals> <!-- must be set for emma -->
                        </dex>

                    </configuration>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<properties>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.emma.reportPath>target/emma/</sonar.emma.reportPath>
    <sonar.surefire.reportsPath>../regalandroid-test/target/surefire-reports</sonar.surefire.reportsPath>
    <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
</properties>

 [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] Hello - Parent
    [INFO] sourcecode - Application
    [INFO] SourceCode - Integration tests
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Hello - Parent 1.0
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ Hello-parent ---
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ Hello-parent ---
    [INFO] Installing G:\Projects\pom.xml to C:\Users\myuser\.m2\repository\andersen\project\Hello-parent\1.0\Hello-parent-1.0.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building SourceCode - Application 1.0
    [INFO] ------------------------------------------------------------------------
    [WARNING] The POM for com.google.android:android:jar:4.0 is missing, no dependency information available
    [WARNING] The POM for android:android:jar:4.0 is missing, no dependency information available
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Skipping Hello - Parent
    [INFO] This project has been banned from the build due to previous failures.
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] Hello - Parent .................................... SUCCESS [1.157s]
    [INFO] SourceCode - Application ....................... FAILURE [0.348s]
    [INFO] SourceCode - Integration tests ................. SKIPPED
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3.703s
    [INFO] Finished at: Thu Dec 06 13:32:20 IST 2012
    [INFO] Final Memory: 4M/8M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project SourceCode: Could not resolve dependencies for project andersen.project:SourceCode:jar:1.0: The following artifacts could not be resolved: com.google.android:android:jar:4.0, android:android:jar:4.0: Failure to find com.google.android:android:jar:4.0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
    [ERROR] 
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :SourceCode


It would be great, if anyone give me step by step how to use.

Thanks in Advance
4

0 回答 0