关于Joda-Time的Maven抱怨,即使我安装了它

时间:2013-09-26 11:16:57

标签: java android maven ant activeandroid

因为我想使用ActiveAndroidActiveAndroid-Validation我需要使用Maven(直到昨天我才听说过)。所以我安装了maven然后尝试安装ActiveAndroid。

我使用custom serializer在ActiveAndroid中编写了一个JodaTime,并在ActiveAndroid libs文件夹中包含了一个JodaTime jar。当我使用ant构建项目时,它非常有效。首先使用Maven我downloaded并使用JodaTime源文件夹中的mvn clean install在Maven中安装JodaTime。看到以下几行,这是成功的:

[INFO] --- maven-install-plugin:2.4:install (default-install) @ joda-time ---
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/pom.xml to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.pom
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-javadoc.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-javadoc.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-sources.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.603s
[INFO] Finished at: Thu Sep 26 13:00:54 CEST 2013
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------

然后我尝试使用ActiveAndroid源文件夹中的相同mvn clean install安装ActiveAndroid。但是,这导致了以下错误:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.095s
[INFO] Finished at: Thu Sep 26 13:01:08 CEST 2013
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project activeandroid: Compilation failure: Compilation failure:
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[3,21] package org.joda.time does not exist
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[22,16] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[7,24] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[19,26] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[27,28] cannot find symbol
[ERROR] symbol  : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] -> [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/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :activeandroid

有人知道如何解决这个问题吗?欢迎所有提示!

== EDIT == 可以找到ActiveAndroid的pom.xml here。我没有改变任何内容。

2 个答案:

答案 0 :(得分:1)

如果您的IDE没有抱怨,则表示您的IDE可以构建项目。

然后我假设您的IDE不依赖于maven来构建。我建议maven和你的IE之间更强大的集成。 您不应该将libs手动添加到类路径(在IDE中)

你的POM错过了依赖

<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.3</version>
</dependency>

答案 1 :(得分:0)

由于你的构建中有android-maven-plugin,你需要提供SDK的路径。对于这个maven插件,可以通过在POM的属性部分中将其添加为属性(android.sdk.path)来完成。

所以你会有这样的事情:

<properties>
    <android.sdk.path>your/path/here</android.sdk.path>
</properties>

要快速解决方案,您只需将其添加到POM的属性部分即可。但是,像这样的本地设置通常会转到maven安装中conf dir中的settings.xml文件。无论您使用什么样的pom,这都会使这个属性始终存在。或者,如果您跳过activeProfiles部分,则必须在启用该配置文件的情况下调用maven - “mvn -pandroidProfile clean install”。

<profiles>
    <profile>
        <id>androidProfile</id>
        <properties>
            <android.sdk.path>your/path/here</android.sdk.path>
        </properties>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>androidProfile</activeProfile>
</activeProfiles>