Scala Maven重新编译中的错误,无需更改代码

时间:2012-03-31 20:01:17

标签: scala maven scala-maven-plugin

当我查看https://github.com/alexeyr/scala-time并使用Maven构建一次时,一切正常。然后我触摸src / main / scala / org / scala_tools / time / Implicits.scala来触发重新编译。再次运行mvn compile,我得到56个类似于

的错误
[ERROR] F:\MyProgramming\scala-time\src\main\scala\org\scala_tools\time\StaticDateTime.scala:29: error: value second is not a member of Int
[ERROR]   def nextSecond = now + 1.second

似乎没有看到触摸文件中定义的含义并使用import org.scala_tools.time.Implicits._导入。但与此同时,没有错误object Implicits is not a member of package org.scala_tools.time,正如我希望在这种情况下看到的那样。

mvn clean之后,可以再次编译一次而不会出错。

  1. 有人可以重现吗?

  2. 如果是,我该如何解决?

  3. 更新:它也发生在SBT上,但只有Implicits.scala实际上已经足够改变以产生不同的类文件(例如添加一行object Implicits2 extends Implicits)。错误集是不同的!

2 个答案:

答案 0 :(得分:1)

  

不满意修复:rm -rf target; mvn compile - rampion 9小时前

无用修复,因为他可以mvn clean compile - 这将是跨平台的解决方案:)

答案 1 :(得分:1)

我可以在没有maven的情况下重新创建错误,因此看起来这可能与scalac的使用方式(或scalac的错误)有关:

% rm -rf target
% mkdir -p target/classes
% cat scalac-args | sed "s;~;$HOME;g" | xargs scalac-2.9 # runs successfully
% cat scalac-args | sed "s;~;$HOME;g" | xargs scalac-2.9
#...
56 errors found

sed命令只解析.m2中的scalac-args目录

scalac-args

的位置
-target:jvm-1.5
-classpath
~/.m2/repository/org/scala-lang/scala-library/2.9.1-1/scala-library-2.9.1-1.jar:~/.m2/repository/org/joda/joda-convert/1.2/joda-convert-1.2.jar:~/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar:target/classes
-d
target/classes
src/main/scala/org/scala_tools/time/DurationBuilder.scala
src/main/scala/org/scala_tools/time/Implicits.scala
src/main/scala/org/scala_tools/time/Imports.scala
src/main/scala/org/scala_tools/time/RichAbstractDateTime.scala
src/main/scala/org/scala_tools/time/RichAbstractInstant.scala
src/main/scala/org/scala_tools/time/RichAbstractPartial.scala
src/main/scala/org/scala_tools/time/RichAbstractReadableInstantFieldProperty.scala
src/main/scala/org/scala_tools/time/RichChronology.scala
src/main/scala/org/scala_tools/time/RichDate.scala
src/main/scala/org/scala_tools/time/RichDateMidnight.scala
src/main/scala/org/scala_tools/time/RichDateTime.scala
src/main/scala/org/scala_tools/time/RichDateTimeFormatter.scala
src/main/scala/org/scala_tools/time/RichDateTimeProperty.scala
src/main/scala/org/scala_tools/time/RichDateTimeZone.scala
src/main/scala/org/scala_tools/time/RichDuration.scala
src/main/scala/org/scala_tools/time/RichInstant.scala
src/main/scala/org/scala_tools/time/RichInt.scala
src/main/scala/org/scala_tools/time/RichLocalDate.scala
src/main/scala/org/scala_tools/time/RichLocalDateProperty.scala
src/main/scala/org/scala_tools/time/RichLocalDateTime.scala
src/main/scala/org/scala_tools/time/RichLocalDateTimeProperty.scala
src/main/scala/org/scala_tools/time/RichLocalTime.scala
src/main/scala/org/scala_tools/time/RichLocalTimeProperty.scala
src/main/scala/org/scala_tools/time/RichLong.scala
src/main/scala/org/scala_tools/time/RichMonthDay.scala
src/main/scala/org/scala_tools/time/RichMonthDayProperty.scala
src/main/scala/org/scala_tools/time/RichPartial.scala
src/main/scala/org/scala_tools/time/RichPartialProperty.scala
src/main/scala/org/scala_tools/time/RichPeriod.scala
src/main/scala/org/scala_tools/time/RichReadableDateTime.scala
src/main/scala/org/scala_tools/time/RichReadableDuration.scala
src/main/scala/org/scala_tools/time/RichReadableInstant.scala
src/main/scala/org/scala_tools/time/RichReadableInterval.scala
src/main/scala/org/scala_tools/time/RichReadablePartial.scala
src/main/scala/org/scala_tools/time/RichReadablePeriod.scala
src/main/scala/org/scala_tools/time/RichYearMonth.scala
src/main/scala/org/scala_tools/time/RichYearMonthProperty.scala
src/main/scala/org/scala_tools/time/StaticDateTime.scala
src/main/scala/org/scala_tools/time/StaticDateTimeFormat.scala
src/main/scala/org/scala_tools/time/StaticDateTimeZone.scala
src/main/scala/org/scala_tools/time/StaticDuration.scala
src/main/scala/org/scala_tools/time/StaticInterval.scala
src/main/scala/org/scala_tools/time/StaticLocalDate.scala
src/main/scala/org/scala_tools/time/StaticLocalDateTime.scala
src/main/scala/org/scala_tools/time/StaticLocalTime.scala
src/main/scala/org/scala_tools/time/StaticPartial.scala
src/main/scala/org/scala_tools/time/StaticPeriod.scala

已经下载了正确的罐子。

如果我在target/classes参数中将target/classes/org/scala_tools/time/替换为-classpath,那么它可以正常工作。

% rm -rf target
% mkdir -p target/classes
% cat scalac-args | sed "s;~;$HOME;g" | xargs scalac-2.9 # runs successfully
% cat scalac-args | sed "s;~;$HOME;g" | xargs scalac-2.9 # runs successfully

因此,当路径上有一个目录时,maven-scala-plugin期望scalac期望scalac查看包相应的子目录,但{{1}}没有这样做。我不确定谁错了。