# Writing a RuleSource plugin that post-processes .class files

**URL:** <https://discuss.gradle.org/t/writing-a-rulesource-plugin-that-post-processes-class-files/19013>\
**Category:** Help/Discuss\
**Created:** [August 17, 2016, 5:35pm UTC](https://discuss.gradle.org/t/writing-a-rulesource-plugin-that-post-processes-class-files/19013 "2016-08-17T17:35:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [August 17, 2016, 6:33pm UTC](https://discuss.gradle.org/t/writing-a-rulesource-plugin-that-post-processes-class-files/19013/2 "2016-08-17T18:33:59Z")

</div>

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:

```gradle

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.:

```gradle
compileEntitiesJava.doLast {
  //call your enhancer here
}

```

Hope that helps 🙂

Stefan

---

_[View the full topic](https://discuss.gradle.org/t/writing-a-rulesource-plugin-that-post-processes-class-files/19013)._
