Skip to content

Commit

Permalink
EBean enhanced classes should also update analysis
Browse files Browse the repository at this point in the history
Ensured when ebean enhances classes, that these also update the
analysis.
  • Loading branch information
jroper authored and huntc committed Feb 17, 2014
1 parent d642112 commit 7a955a9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions framework/src/sbt-plugin/src/main/scala/PlayCommands.scala
Expand Up @@ -123,8 +123,10 @@ trait PlayCommands extends PlayAssetsCompiler with PlayEclipse with PlayInternal

IO.write(timestampFile, System.currentTimeMillis.toString)

val ebeanEnhancement = classpath.contains("play-java-ebean")

// EBean
if (classpath.contains("play-java-ebean")) {
if (ebeanEnhancement) {

val originalContextClassLoader = Thread.currentThread.getContextClassLoader

Expand Down Expand Up @@ -182,7 +184,15 @@ trait PlayCommands extends PlayAssetsCompiler with PlayEclipse with PlayInternal
(managedClassesDirectory ** "*.class").get.filterNot(managedSet.contains(_)).foreach(_.delete())
}

if (!enhancedClasses.isEmpty) {
// If ebean enhancement was done, then it's possible that any of the java classes were enhanced, we don't know
// which, otherwise it's just the enhanced classes that we did accessor generation/rewriting for
val possiblyEnhancedClasses = if (ebeanEnhancement) {
javaClasses ++ enhancedTemplateClasses
} else {
enhancedClasses
}

if (!possiblyEnhancedClasses.isEmpty) {
/**
* Updates stamp of product (class file) by preserving the type of a passed stamp.
* This way any stamp incremental compiler chooses to use to mark class files will
Expand All @@ -196,7 +206,7 @@ trait PlayCommands extends PlayAssetsCompiler with PlayEclipse with PlayInternal
// Since we may have modified some of the products of the incremental compiler, that is, the compiled template
// classes and compiled Java sources, we need to update their timestamps in the incremental compiler, otherwise
// the incremental compiler will see that they've changed since it last compiled them, and recompile them.
val updatedAnalysis = analysis.copy(stamps = enhancedClasses.foldLeft(analysis.stamps) { (stamps, classFile) =>
val updatedAnalysis = analysis.copy(stamps = possiblyEnhancedClasses.foldLeft(analysis.stamps) { (stamps, classFile) =>
val existingStamp = stamps.product(classFile)
if (existingStamp == Stamp.notPresent) {
throw new java.io.IOException("Tried to update a stamp for class file that is not recorded as "
Expand Down

0 comments on commit 7a955a9

Please sign in to comment.