Writing a RuleSource plugin that post-processes .class files

Hey Janito,

the software model for Java projects is not production ready and will not be developed further. Instead, we will enhance the existing model to provide many of the same benefits.

Now to give you a rough idea how to solve your problem with the current model:

First question: Does Ebean provide an annotation processor? Then you’d just have to change the main java compile task and be done.

If class manipulation is the only way, then you need a new sourceSet that is compiled before the main sourceSet:


sourceSets {
  entities {
    java {
      srcDir 'src/entities/java'
    }
  }
  
  configure([main, test]) {
    compileClasspath += entities.output
    runtimeClasspath += entities.output
  }
}

configurations {
  compile.extendsFrom(entitiesCompile)
  runtime.extendsFrom(entitiesRuntime)
}

Then, you’ll want to call your enhancer as an action right after the compile task for this sourceSet, so that the classes are replaced with the enhanced ones. This will make sure that up-to-date checking will look at your enhanced classes, not the original ones.:

compileEntitiesJava.doLast {
  //call your enhancer here
}

Hope that helps :slight_smile:

Stefan