When I check 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 a 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 appears not to see the implicits defined in the touched 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.
After mvn clean
it can be compiled once without error again.
Can anybody reproduce this?
If yes, how can I fix it?
UPDATE: it also happens with SBT, but only if Implicits.scala
is actually changed enough to produce different class files (e.g. add a line object Implicits2 extends Implicits
). And the set of errors is different!
I can recreate the error without maven
, so it looks like this might be an issue with how scalac
is being used (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 sed
command just resolves the .m2
directory 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 proper jars have already been downloaded.
If I replace target/classes
with target/classes/org/scala_tools/time/
in the -classpath
argument, then it works fine then.
% 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 the maven-scala-plugin
expects scalac
to look in package-appropriate subdirectories when given a directory on the path, but scalac
isn't doing that. I'm not sure who's wrong.