Generate several files [message #1730381] |
Mon, 25 April 2016 11:16 |
|
Hey guys! I need some help, i hope you can enlight me
Im sitll working on my generator, i want to generate more than one file, but i dont really understand. I have checked the example generator codes, but i didnt get the point. I assume its more complicated compared to what i need. So, can you give me an example of code for this easy problem:
I want one file named "FirstFile", which contains "I am the first generated file!!", and one file named "SecondFile", which contains "I am the second file!!" , in the extend file. This is the code ive got:
package org.eclipse.vorto.example
import org.eclipse.core.runtime.IProgressMonitor
import org.eclipse.vorto.codegen.api.ICodeGenerator
import org.eclipse.vorto.codegen.api.tasks.Generated
import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask
import org.eclipse.vorto.codegen.api.tasks.IOutputter
import org.eclipse.vorto.codegen.api.tasks.eclipse.EclipseProjectGenerator
import org.eclipse.vorto.core.api.model.informationmodel.InformationModel
class MyGenerator implements ICodeGenerator<InformationModel> {
override generate(InformationModel infomodel, IProgressMonitor monitor) {
new EclipseProjectGenerator(infomodel.getName()+"Device").addTask(new EmptyJavaGeneratorTask()).javaNature().generate(infomodel,monitor);
}
public static class EmptyJavaGeneratorTask implements ICodeGeneratorTask<InformationModel> {
public override generate(InformationModel infomodel, IOutputter outputter) {
outputter.output(new Generated(infomodel.getName(),null, getContent));
}
def String getContent() {
return '//"I am the first generated file!!';
}
}
override getName() {
return "FirstFile";
}
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.02838 seconds