use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario04BuildSingleProjectsWithManyProjectsOnPath.
/**
* Testing compiling only a single project.
*/
@Test
public void testScenario04BuildSingleProjectsWithManyProjectsOnPath() throws N4JSCompileException {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario04");
List<File> pProjectRoots = //
Arrays.asList(// A, NotAProject
new File(root, "wsp1"), // B,D
new File(root, "nest/wsp2"), // C
new File(root, "wsp3"), // E,H
new File(root, "nest/nest/wsp4"), // F
new File(root, "nest/wsp5"), // G
new File(root, "wsp6"));
List<File> toCompile = //
Arrays.asList(// requires B and A to be loaded.
new File(root, "nest/wsp2/D"));
hlc.compileProjects(pProjectRoots, toCompile);
assertNotExists(root, "wsp1/A/src-gen/packA/A.js");
assertNotExists(root, "nest/wsp2/B/src-gen/packB/B.js");
assertNotExists(root, "wsp3/C/src-gen/packC/C.js");
// Only those both should be available
assertExists(root, "nest/wsp2/D/src-gen/packD/D.js");
assertExists(root, "nest/wsp2/D/src-gen/packD/D2.js");
assertNotExists(root, "nest/nest/wsp4/E/src-gen/packE/E.js");
assertNotExists(root, "nest/nest/wsp4/E/src-gen/packE/E2.js");
assertNotExists(root, "nest/wsp5/F/src-gen/packF/F.js");
assertNotExists(root, "wsp6/G/src-gen/packG/G.js");
assertNotExists(root, "nest/nest/wsp4/H/src-gen/packH/H.js");
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario10BuildSingleFileWithProjectRootAndDependency.
/**
*/
@Test
public void testScenario10BuildSingleFileWithProjectRootAndDependency() throws N4JSCompileException {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario10");
List<File> toCompile = //
Arrays.asList(// requires nothing
new File(root, "nest/wsp2/D/src/packD/D2.n4js"));
List<File> wspRoots = //
Arrays.asList(new File(root, "nest/wsp2"), new File(root, "wsp1"));
hlc.compileSingleFiles(wspRoots, toCompile);
assertExists(root, "nest/wsp2/D/src-gen/packD/D2.js");
// those should be available
assertNotExists(root, "wsp1/A/src-gen/packA/A.js");
assertNotExists(root, "nest/wsp2/B/src-gen/packB/B.js");
assertNotExists(root, "nest/wsp2/B/src-gen/packB/B2.js");
assertNotExists(root, "nest/wsp2/D/src-gen/packD/D.js");
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario03brokenN4jsSyntax.
/**
* Broken source-file will result in compile-error.
*/
@Test(expected = N4JSCompileException.class)
public void testScenario03brokenN4jsSyntax() throws N4JSCompileException {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario03");
List<File> pProjectRoots = //
Arrays.asList(// A
new File(root, "wsp1"));
hlc.compileAllProjects(pProjectRoots);
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class HeadlessCompilerFactory method createCompilerWithProperties.
/**
* Construct a {@link N4HeadlessCompiler} with configuration based on the provided properties.
*
* @param properties
* preferences.
*/
public static N4HeadlessCompiler createCompilerWithProperties(Properties properties) {
Injector localinjector = new N4JSHeadlessStandaloneSetup(properties).createInjectorAndDoEMFRegistration();
N4HeadlessCompiler instance = localinjector.getInstance(N4HeadlessCompiler.class);
HeadlessExtensionRegistrationHelper headlessExtensionRegistrationHelper = localinjector.getInstance(HeadlessExtensionRegistrationHelper.class);
headlessExtensionRegistrationHelper.registerExtensions();
return instance;
}
Aggregations