Maven 从 3.1.1 升级到 3.3.3 时,Maven 'clean install' 失败

Maven 'clean install' fails when maven is upgraded from 3.1.1 to 3.3.3

我正在尝试为 android 构建我从 github 克隆的莱特币钱包:https://github.com/Litecoin-Java/bitcoin-wallet

几天来我一直在用头撞墙,因为不断尝试构建这个东西会导致越来越多的错误。 github 上的说明只是对 运行 "mvn clean install" 说,但对我来说似乎并不那么简单。这是我第一次使用 maven,也是我第一次使用 bitcoinj 库。

这是一个合二为一的问题,因为当我尝试将 bitcoinj 依赖项设置为 v0.12.3(最新)而不是 v0.10.3(非常旧... )

经过几天的修改,我终于让它工作了:

HOME_JAVA、ANDROID_HOME等环境变量设置正确。我还确保将 maven、androidsdk/tools 和 /platform-tools 添加到我的路径中。

我 运行宁 Ubuntu 14.04.

运行 maven 3.1.1 和 bitcoinj v0.10.3 我得到

[INFO] base .............................................. SUCCESS [0.384s]
[INFO] Bitcoin Integration for Android ................... SUCCESS [1.448s]
[INFO] Bitcoin Wallet .................................... SUCCESS [49.624s]
[INFO] Sample for Bitcoin Integration for Android ........ SUCCESS [2.128s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

升级到 maven 3.3.3(同时仍在使用 bitcoinj v0.10.3)我得到:

[INFO] base ............................................... SUCCESS [  0.453 s]
[INFO] Bitcoin Integration for Android .................... SUCCESS [  1.937 s]
[INFO] Bitcoin Wallet ..................................... FAILURE [ 41.376 s]
[INFO] Sample for Bitcoin Integration for Android ......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.952 s
[INFO] Finished at: 2015-05-22T11:23:01+00:00
[INFO] Final Memory: 29M/332M
[INFO] ------------------------------------------------------------------------
[ERROR] Unable to provision, see the following errors:
[ERROR] 
[ERROR] 1) No implementation for org.eclipse.aether.connector.wagon.WagonProvider was bound.
[ERROR] while locating org.eclipse.aether.connector.wagon.WagonRepositoryConnectorFactory
[ERROR] at ClassRealm[extension>com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.0, parent: sun.misc.Launcher$AppClassLoader@665ce0fe] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR] at ClassRealm[extension>com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.0, parent: sun.misc.Launcher$AppClassLoader@665ce0fe] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR] while locating org.eclipse.aether.spi.connector.RepositoryConnectorFactory annotated with @com.google.inject.name.Named(value=wagon)
[ERROR] 
[ERROR] 1 error

将 bitcoinj 依赖项的版本设置为 0.12.3 我得到:

[ERROR] Failed to execute goal on project wallet: Could not resolve dependencies for project de.schildbach.wallet:wallet:apk:3.29-test: Could not find artifact com.google:bitcoinj:jar:0.12.3 in central (http://repo.maven.apache.org/maven2) -> 

我不,这意味着我需要自己获取和构建 0.12.3,但我不知道如何让我的项目知道在哪里可以找到我的自定义构建版本。

我不知道是什么原因造成的,因为我没有像我之前所说的那样使用 bitcoinj 或 maven。我遇到的大多数错误至少会出现一些 google 对我有帮助的结果,但是当我搜索其中任何一个的版本问题时我找不到太多。

这是整个项目的 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>de.schildbach.wallet</groupId>
    <artifactId>base</artifactId>
    <name>base</name>
    <version>1</version>
    <packaging>pom</packaging>

    <modules>
        <module>wallet</module>
        <module>integration-android</module>
        <module>sample-integration-android</module>
    </modules>

    <build>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.15</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.2.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <genDirectory>${basedir}/gen</genDirectory>
                    </configuration>
                    <extensions>true</extensions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.9</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.8</version>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>

这里是 'wallet' 文件夹的 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>

    <artifactId>wallet</artifactId>
    <packaging>apk</packaging>
    <version>3.29-test</version>
    <name>Bitcoin Wallet</name>

    <parent>
        <groupId>de.schildbach.wallet</groupId>
        <artifactId>base</artifactId>
        <version>1</version>
    </parent>

    <dependencies>

        <!-- android.*, java.*, javax.* -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.0.1.2</version>
            <scope>provided</scope>
        </dependency>

        <!-- android.annotation.* -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>annotations</artifactId>
            <!-- version should match android artifact, but not available on maven central -->
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>

        <!-- android.support.v4.* -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>r7</version>
        </dependency>

        <!-- com.actionbarsherlock.* -->
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>library</artifactId>
            <version>4.1.0</version>
            <type>apklib</type>
        </dependency>

        <!-- com.google.bitcoin.* -->
        <dependency>
            <groupId>com.google</groupId>
            <artifactId>bitcoinj</artifactId>
            <version>0.12.3</version>
        </dependency>

        <!-- de.schildbach.wallet.integration.android.* -->
        <dependency>
            <groupId>de.schildbach.wallet</groupId>
            <artifactId>integration-android</artifactId>
            <version>1.0</version>
        </dependency>

        <!-- com.google.zxing.* -->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>2.2</version>
        </dependency>

        <!-- org.slf4j.* -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>

        <!-- ch.qos.logback.classic.* -->
        <dependency>
            <groupId>com.github.tony19</groupId>
            <artifactId>logback-android-classic</artifactId>
            <version>1.0.10-2</version>
        </dependency>

        <!-- ch.qos.logback.core.* -->
        <dependency>
            <groupId>com.github.tony19</groupId>
            <artifactId>logback-android-core</artifactId>
            <version>1.0.10-2</version>
        </dependency>

        <!-- javax.annotation.* -->
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>2.0.1</version>
        </dependency>

        <!-- org.junit.* -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <configuration>
                            <release>true</release>
                            <proguard>
                                <skip>false</skip>
                            </proguard>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <!-- to build, run: mvn clean install -->
    <!-- then to install on an android device, run: mvn android:deploy -->
    <build>
        <sourceDirectory>src</sourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.2</version>
                <configuration>
                    <excludeJarResources>
                        <excludeJarResource>.*\.jar$</excludeJarResource>
                    </excludeJarResources>
                    <sdk>
                        <platform>14</platform>
                    </sdk>
                    <sign>
                        <debug>both</debug>
                    </sign>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <additionalProjectnatures>
                        <projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>com.android.ide.eclipse.adt.ResourceManagerBuilder</buildcommand>
                        <buildcommand>com.android.ide.eclipse.adt.PreCompilerBuilder</buildcommand>
                        <buildcommand>com.android.ide.eclipse.adt.ApkBuilder</buildcommand>
                    </additionalBuildcommands>
                    <classpathContainers>
                        <classpathContainer>com.android.ide.eclipse.adt.ANDROID_FRAMEWORK</classpathContainer>
                        <!-- This is a workaround: we do not want JRE_CONTAINER, however if we remove it, it will be automatically added, and 
                            placed first. So we add it in the second position, so that the project is recognized as an Android project. -->
                        <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
                    </classpathContainers>
                    <excludes>
                        <exclude>android:android</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- to generate reports, run: mvn clean install site -->
    <!-- then browse to: target/site/index.html -->
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <onlyAnalyze>de.schildbach.wallet.-</onlyAnalyze>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

</project>

感谢您的帮助。

似乎对于 0.12.3 版本依赖项已经更改了 groupid。

这是新的依赖关系:

<dependency>
  <groupId>org.bitcoinj</groupId>
  <artifactId>bitcoinj-core</artifactId>
  <version>0.12.3</version>
  <scope>compile</scope>
</dependency>

你可以查看它here (Maven central) and here(bitcoinj 站点)。

maven 3.2 和 3.3 存在一些兼容性问题。请使用 maven 3.1 。试试这个:

brew install homebrew/versions/maven31
sudo ln -s /usr/local/Cellar/maven31/3.1.1 /usr/local/Cellar/maven/
brew switch maven 3.1.1