Search in sources :

Example 1 with ModuleParseResult

use of org.wildfly.build.util.ModuleParseResult in project wildfly-gradle-tools by wildfly.

the class ModuleTemplate method parse.

public static ModuleTemplate parse(Path template, TemplatePatterns templateValues) throws IOException, ParsingException {
    final String fileContent = Files.lines(template, CustomCharset.utf8).collect(Collectors.joining("\n"));
    final String replacedContent = templateValues.replaceAllVariables(fileContent);
    final ModuleParseResult parseResult;
    try (InputStream stream = new ByteArrayInputStream(replacedContent.getBytes(CustomCharset.utf8))) {
        parseResult = ModuleParser.parse(stream);
    }
    return new ModuleTemplate(replacedContent, parseResult);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ModuleParseResult(org.wildfly.build.util.ModuleParseResult)

Example 2 with ModuleParseResult

use of org.wildfly.build.util.ModuleParseResult in project wildfly-gradle-tools by wildfly.

the class FeaturePackFunctionalTest method testFeaturePackTask.

@Test
public void testFeaturePackTask() throws Exception {
    BuildResult result = testProject.runTask("featurepack");
    assertEquals(result.task(":featurepack").getOutcome(), TaskOutcome.SUCCESS);
    File expectedModuleFile = new File(testProject.getWorkDirectory() + File.separator + "featurepack" + File.separator + "modules" + File.separator + "system" + File.separator + "layers" + File.separator + "base" + File.separator + "org" + File.separator + "hibernate" + File.separator + "orm53" + File.separator + "module.xml");
    assertTrue("The module.xml has not been created " + expectedModuleFile.getPath(), expectedModuleFile.exists());
    ModuleParseResult parseResult = ModuleParser.parse(expectedModuleFile.toPath());
    assertThat(parseResult.getIdentifier().getSlot(), is("orm53"));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) ModuleParseResult(org.wildfly.build.util.ModuleParseResult) Test(org.junit.Test)

Aggregations

ModuleParseResult (org.wildfly.build.util.ModuleParseResult)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 BuildResult (org.gradle.testkit.runner.BuildResult)1 Test (org.junit.Test)1