Question

Eclipse can compile java source code to byte code automatically. I write some enhancers with javassist, which can modify the existing byte code and add some new fields and methods to them.

How to configure eclipse that when it compiles, it will automatically invoke my enhancers to modify the byte code and save them to .class files as normal? That my other java code can find and invoke these new fields and methods.

Is it a complicated work that may be I need to write a custom eclipse plugin?

Was it helpful?

Solution

You don't need to write a plugin, you only need to add a builder to each Java project where you want to invoke your tool. Use project properties -> Builders -> New to either add a small Ant script or an external program. That builder is then invoked each time the eclipse build process runs.

There is a small tutorial in the eclipse help to demonstrate this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top