This is copied from the source code of the Maven JCasGen plugin. Check out the 
full sources here:

https://svn.apache.org/repos/asf/uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java

---

    args.addAll(asList("-jcasgeninput", typeSystemFile.getAbsolutePath(), 
"-jcasgenoutput",
            this.outputDirectory.getAbsolutePath(), "=jcasgenclasspath", 
classpath));

    // run JCasGen to generate the Java sources
    Jg jCasGen = new Jg();
    try {
      jCasGen.main0(args.toArray(new String[args.size()]), null, new 
JCasGenProgressMonitor(),
              new JCasGenErrors());
    } catch (JCasGenException e) {
      throw new MojoExecutionException(e.getMessage(), e.getCause());
    }

---

- Richard


On 19.09.2013, at 13:16, Eirini Psallida <[email protected]> wrote:

> Hi Richard!
> 
> I created the XML file, thanks a lot.
> Can you explain me a bit more how can i pass this XML to the JCasGen
> programmatically?
> 
> Eirini
> 
> 
> On Thu, Sep 19, 2013 at 12:48 PM, Richard Eckart de Castilho <[email protected]
>> wrote:
> 
>> Hi,
>> 
>> you can generate a type system descriptor in Java (there are Java objects
>> representing the type system descriptor). Then you can serialize
>> that to XML and pass it to the JCasGen programmatically, or possibly
>> pass the descriptor object directly to JCasGen (but I think that is not
>> supported right now).
>> 
>> This is a brief example how to create a type system descriptor in code:
>> 
>> // Create a new type system from scratch
>> TypeSystemDescription tsd = new TypeSystemDescription_impl();
>> TypeDescription tokenTypeDesc = tsd.addType("Token", "",
>> CAS.TYPE_NAME_ANNOTATION);
>> tokenTypeDesc.addFeature("length", "", CAS.TYPE_NAME_INTEGER);
>> 
>> -- Richard
>> 
>> On 19.09.2013, at 11:03, Eirini Psallida <[email protected]>
>> wrote:
>> 
>>> Hi,
>>> 
>>> i would like to define the Type System for my Annotator and then generate
>>> the java classes without
>>> using the XML descriptor and then the JCasGen button. I would like to do
>> it
>>> through java code only.
>>> How can i do this? I suppose i need the uima-tools.jar where JCasGen is
>>> implemented.
>>> 
>>> 
>>> Thanks,
>>> 
>>> Eirini
>> 
>> 

Reply via email to