phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

Generate *.class #87

Closed robertomorati closed 3 years ago

robertomorati commented 3 years ago

@phax

How are you doing?

Please, could you tell me if it's possible to generate a .class file instead of .java file?

All the best, Roberto Morati

phax commented 3 years ago

Hi Roberto, It's not possible. You can only create ".java" files and than you need to compile them separately. There is no build-in compilation - sorry. BR, Philip

glelouet commented 3 years ago

I think you can with the PR I made(dynamic class loader). Not sure though.

robertomorati commented 3 years ago

@glelouet

We have a maven plugin with a goal generate that generated some java files. Now I'm trying to update that goal to generate class with those java files.

First, I tried to generate those classes running the command line in java code, but one file depends on other files, so its crashes. Now, I studying about addCompileSourceRoot inside execute() of a goal, but it didn't work.

robertomorati commented 3 years ago

@glelouet I solved it using javac with wildcard (*) and sourcepath.

phax commented 3 years ago

Ok @robertomorati The upcoming version 4.0 will have ht epossibility to directly compile the created CodeModel classes when you are using a JDK. hat would simplify your process I assume