use of org.finos.legend.engine.shared.javaCompiler.ClassPathFilter in project legend-engine by finos.
the class JavaHelper method createNewJavaCompiler.
private static EngineJavaCompiler createNewJavaCompiler() {
List<ClassPathFilter> filters = Lists.mutable.of(new ExecutionPlanDependenciesFilter());
ExecutionPlanJavaCompilerExtensionLoader.extensions().forEach(ext -> filters.add(ext.getExtraClassPathFilter()));
return new EngineJavaCompiler(JavaVersion.JAVA_8, new CompositeClassPathFilter(filters));
}
use of org.finos.legend.engine.shared.javaCompiler.ClassPathFilter in project legend-engine by finos.
the class TestJavaCompileClassPathFilter method compilesWhenPackageIsFilteredIn.
@Test
public void compilesWhenPackageIsFilteredIn() throws Exception {
ClassPathFilter filter = new ClassPathFilter() {
@Override
public boolean isPermittedPackage(String packageName) {
return packageName.equals(JavaVersion.class.getPackage().getName());
}
@Override
public boolean isPermittedClass(String packageName, String className) {
return isPermittedPackage(packageName);
}
};
EngineJavaCompiler c = new EngineJavaCompiler(JavaVersion.JAVA_8, filter);
c.compile(Lists.mutable.with(StringJavaSource.newStringJavaSource("engine.generated", "Example", code)));
Assert.assertEquals("JAVA_8", execute(c));
}
use of org.finos.legend.engine.shared.javaCompiler.ClassPathFilter in project legend-engine by finos.
the class TestJavaCompileClassPathFilter method failsWhenPackageIsFilteredOut.
@Test(expected = JavaCompileException.class)
public void failsWhenPackageIsFilteredOut() throws Exception {
ClassPathFilter filter = new ClassPathFilter() {
@Override
public boolean isPermittedPackage(String packageName) {
return !packageName.equals(JavaVersion.class.getPackage().getName());
}
@Override
public boolean isPermittedClass(String packageName, String className) {
return isPermittedPackage(packageName);
}
};
EngineJavaCompiler c = new EngineJavaCompiler(JavaVersion.JAVA_8, filter);
c.compile(Lists.mutable.with(StringJavaSource.newStringJavaSource("engine.generated", "Example", code)));
}
use of org.finos.legend.engine.shared.javaCompiler.ClassPathFilter in project legend-engine by finos.
the class TestJavaCompileClassPathFilter method succeedsWhenPackageIsFilteredOutButFilteringSwitchedOff.
@Test
public void succeedsWhenPackageIsFilteredOutButFilteringSwitchedOff() throws Exception {
ClassPathFilter filter = new ClassPathFilter() {
@Override
public boolean isPermittedPackage(String packageName) {
return !packageName.equals(JavaVersion.class.getPackage().getName());
}
@Override
public boolean isPermittedClass(String packageName, String className) {
return isPermittedPackage(packageName);
}
};
EngineJavaCompiler c = new EngineJavaCompiler(JavaVersion.JAVA_8, filter);
c.setFilteringEnabled(false);
c.compile(Lists.mutable.with(StringJavaSource.newStringJavaSource("engine.generated", "Example", code)));
Assert.assertEquals("JAVA_8", execute(c));
}
use of org.finos.legend.engine.shared.javaCompiler.ClassPathFilter in project legend-engine by finos.
the class TestJavaCompileClassPathFilter method compilesWhenClassIsFilteredIn.
@Test
public void compilesWhenClassIsFilteredIn() throws Exception {
ClassPathFilter filter = new ClassPathFilter() {
@Override
public boolean isPermittedPackage(String packageName) {
return packageName.equals(JavaVersion.class.getPackage().getName());
}
@Override
public boolean isPermittedClass(String packageName, String className) {
return isPermittedPackage(packageName) && className.equals(JavaVersion.class.getSimpleName());
}
};
EngineJavaCompiler c = new EngineJavaCompiler(JavaVersion.JAVA_8, filter);
c.compile(Lists.mutable.with(StringJavaSource.newStringJavaSource("engine.generated", "Example", code)));
Assert.assertEquals("JAVA_8", execute(c));
}
Aggregations