Search in sources :

Example 1 with EclipseJavaCompilerSettings

use of org.drools.compiler.commons.jci.compilers.EclipseJavaCompilerSettings in project drools by kiegroup.

the class AbstractKnowledgeTest method compile.

public List<String> compile(KieModuleModel kproj, MemoryFileSystem srcMfs, MemoryFileSystem trgMfs, List<String> classes) {
    for (KieBaseModel kbase : kproj.getKieBaseModels().values()) {
        Folder srcFolder = srcMfs.getFolder("src/main/resources/" + kbase.getName());
        Folder trgFolder = trgMfs.getFolder(kbase.getName());
        copyFolder(srcMfs, srcFolder, trgMfs, trgFolder, kproj);
    }
    Folder srcFolder = srcMfs.getFolder("META-INF");
    Folder trgFolder = trgMfs.getFolder("META-INF");
    trgFolder.create();
    copyFolder(srcMfs, srcFolder, trgMfs, trgFolder, kproj);
    EclipseJavaCompilerSettings settings = new EclipseJavaCompilerSettings();
    settings.setSourceVersion("1.5");
    settings.setTargetVersion("1.5");
    EclipseJavaCompiler compiler = new EclipseJavaCompiler(settings, "");
    CompilationResult res = compiler.compile(classes.toArray(new String[classes.size()]), trgMfs, trgMfs);
    if (res.getErrors().length > 0) {
        fail(res.getErrors()[0].getMessage());
    }
    List<String> classes2 = new ArrayList<String>(classes.size());
    for (String str : classes) {
        classes2.add(filenameToClassname(str));
    }
    return classes2;
}
Also used : KieBaseModel(org.kie.api.builder.model.KieBaseModel) EclipseJavaCompiler(org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler) ArrayList(java.util.ArrayList) CompilationResult(org.drools.compiler.commons.jci.compilers.CompilationResult) Folder(org.drools.compiler.compiler.io.Folder) EclipseJavaCompilerSettings(org.drools.compiler.commons.jci.compilers.EclipseJavaCompilerSettings)

Aggregations

ArrayList (java.util.ArrayList)1 CompilationResult (org.drools.compiler.commons.jci.compilers.CompilationResult)1 EclipseJavaCompiler (org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler)1 EclipseJavaCompilerSettings (org.drools.compiler.commons.jci.compilers.EclipseJavaCompilerSettings)1 Folder (org.drools.compiler.compiler.io.Folder)1 KieBaseModel (org.kie.api.builder.model.KieBaseModel)1