1

I have a set of ruby files where I have some string of type:

@something = [Whatever.new('1rabbit'), 
              Whatever.new('2rabbit'), 
              Whatever.new('3rabbit')]

I would like to parse out this information from the ruby file during compilation phase (javac run with maven - but i think it is no difference how javac is run), and create a .class enum of type:

public enum Something {
  1RABBIT,
  2RABBIT,
  3RABBIT
}

and store it into the target folder. Then, I can use this enum whatever I want (after this initial compilation). I looked into AnnotationProcessors, and bytecode generation, but the first requires annotations, and the second is done during runtime. And I cannot find out how to do it properly.

What is the correct tool to do this, and how?

2
  • Why don't you just use JSON and parse it into a Java program? Commented Dec 19, 2016 at 12:27
  • I have some legacy code in ruby files. My example is just a simplification Commented Dec 19, 2016 at 12:47

1 Answer 1

2

mavens life cycle has a generate sources phase. There you cold use the exec-maven-plugin to run a script generating the enums.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.