Ritmo2k
Ritmo2k

Reputation: 1021

Programmatically composing a BeanShell script from multiple Java class files

I am working on a project that must generate Java code for use with a BeanShell interpreter. The past convention involved creating a regular Java class and manually copying and pasting the applicable parts into a BeanShell script and deploying it.

For obvious reasons, I wrote a small script to parse the required sections based on region comments and write them all out to the BeanShell script file.

For example (excluding the additional data to handle unindenting):

//region
import java.util.UUID;
//endRegion

public class Foo {
    public static void main(String[] args)
    {
        //region
        System.out.println(UUID.randomUUID().toString());
        //endRegion
    }
}

results in:

import java.util.UUID;

System.out.println(UUID.randomUUID().toString());

This worked sufficiently for simple cases. However, the complexity is growing and I'd like to start using abstract classes. My simple script only accounts for a single class.

Does a toolkit already exist to help manage the process of parsing the desired sections out of each class and merging them all into a single file?

Upvotes: 0

Views: 54

Answers (0)

Related Questions