use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultIncrementalCompilerEnabler in project kie-wb-common by kiegroup.
the class DefaultIncrementalCompilerEnablerTest method testReadKiePluginTest.
@Test
public void testReadKiePluginTest() throws Exception {
Path tmpRoot = Files.createTempDirectory("repo");
// NIO creation and copy content
Path temp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
TestUtil.copyTree(Paths.get("src/test/projects/dummy_kie_multimodule_untouched"), temp);
// end NIO
Path tmp = Paths.get(tmpRoot.toAbsolutePath().toString(), "dummy");
Path mainPom = Paths.get(tmp.toAbsolutePath().toString(), "pom.xml");
byte[] encoded = Files.readAllBytes(Paths.get(tmp.toAbsolutePath().toString(), "pom.xml"));
String pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertFalse(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
assertFalse(pomAsAstring.contains("<packaging>kjar</packaging>"));
byte[] encodedDummyB = Files.readAllBytes(Paths.get(tmp.toAbsolutePath().toString(), "/dummyB/pom.xml"));
String pomAsAstringDummyB = new String(encodedDummyB, StandardCharsets.UTF_8);
assertTrue(pomAsAstringDummyB.contains("<packaging>kjar</packaging>"));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(), info, new String[] { MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE, "-X" }, new HashMap<>(), Boolean.FALSE);
DefaultIncrementalCompilerEnabler enabler = new DefaultIncrementalCompilerEnabler(Compilers.JAVAC);
assertTrue(enabler.process(req).getResult());
assertTrue(info.isKiePluginPresent());
encoded = Files.readAllBytes(Paths.get(mainPom.toString()));
pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertTrue(pomAsAstring.contains("kie-takari-plugin"));
TestUtil.rm(tmpRoot.toFile());
}
use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultIncrementalCompilerEnabler in project kie-wb-common by kiegroup.
the class MavenUtilsTest method presenceOfDepInThePrj.
@Test
public void presenceOfDepInThePrj() throws Exception {
DefaultIncrementalCompilerEnabler enabler = new DefaultIncrementalCompilerEnabler(Compilers.JAVAC);
List<String> pomList = new ArrayList<>();
MavenUtils.searchPoms(Paths.get("src/test/projects/dummy_kie_multimodule_untouched/"), pomList);
assertTrue(pomList.size() == 3);
List<Artifact> deps = MavenUtils.resolveDependenciesFromMultimodulePrj(pomList);
assertTrue(deps.size() == 1);
Artifact artifact = deps.get(0);
assertTrue(artifact.getArtifactId().equals("kie-api"));
assertTrue(artifact.getGroupId().equals("org.kie"));
assertTrue(artifact.getVersion().equals("6.5.0.Final"));
assertTrue(artifact.getType().equals("jar"));
assertTrue(artifact.toString().equals("org.kie:kie-api:jar:6.5.0.Final"));
}
use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultIncrementalCompilerEnabler in project kie-wb-common by kiegroup.
the class DefaultIncrementalCompilerEnablerTest method testReadPomsInaPrjTest.
@Test
public void testReadPomsInaPrjTest() throws Exception {
FileSystemProvider fs = FileSystemProviders.getDefaultProvider();
Path tmpRoot = Files.createTempDirectory("repo");
// NIO creation and copy content
Path temp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
TestUtil.copyTree(Paths.get("src/test/projects/dummy_multimodule_untouched"), temp);
// end NIO
Path tmp = Paths.get(tmpRoot.toAbsolutePath().toString(), "dummy");
Path mainPom = Paths.get(temp.toAbsolutePath().toString(), "pom.xml");
byte[] encoded = Files.readAllBytes(Paths.get(temp.toAbsolutePath().toString(), "pom.xml"));
String pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertFalse(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(), info, new String[] { MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE }, new HashMap<>(), Boolean.FALSE);
DefaultIncrementalCompilerEnabler enabler = new DefaultIncrementalCompilerEnabler(Compilers.JAVAC);
Assert.assertTrue(enabler.process(req).getResult());
encoded = Files.readAllBytes(Paths.get(mainPom.toString()));
pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
Assert.assertTrue(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
assertFalse(pomAsAstring.contains("kie-takari-plugin"));
TestUtil.rm(tmpRoot.toFile());
}
Aggregations