Error in Scala recompiling Maven without changing code
When I go out https://github.com/alexeyr/scala-time and build it once using Maven everything works fine. Then I touch src / main / scala / org / scala_tools / time / Implicits.scala to trigger the recompilation. Run mvn compile
again and I get 56 errors similar to
[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
It seems that there are no implications defined in the affected file and imported with import org.scala_tools.time.Implicits._
. But at the same time, there is no error object Implicits is not a member of package org.scala_tools.time
, as I would expect to see in this case.
Once mvn clean
it can be compiled once, without errors.
-
Can anyone reproduce this?
-
If so, how can I fix it?
UPDATE: This also happens with SBT, but only if Implicits.scala
actually changed enough to create different class files (add a line for example object Implicits2 extends Implicits
). And the set of errors is different!
source to share
I can recover the error without maven
, so it looks like it might be a problem with how it is used scalac
(or a bug with 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
(the command sed
just resolves the directory .m2
in scalac-args
)
Where scalac-args
is
-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
And the correct jars are already loaded.
If I replace target/classes
with target/classes/org/scala_tools/time/
in the argument -classpath
then it works fine.
% 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
So, it looks like it maven-scala-plugin
expects what scalac
will look like in the subdirectories corresponding to the packages if a directory is given in the path, but scalac
does not. I'm not sure who's wrong.
source to share