use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class OutputLogAfterDecoratorTest method compileWithOverrideTest.
@Test
public void compileWithOverrideTest() throws Exception {
Map<Path, InputStream> override = new HashMap<>();
org.uberfire.java.nio.file.Path path = org.uberfire.java.nio.file.Paths.get(tmpRoot + "/src/main/java/dummy/DummyOverride.java");
InputStream input = new FileInputStream(new File(ResourcesConstants.DUMMY_OVERRIDE + "/src/main/java/dummy/DummyOverride.java"));
override.put(path, input);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
OutputLogAfterDecorator decorator = new OutputLogAfterDecorator(new BaseMavenCompiler(true, true));
CompilationResponse res = decorator.compile(req, override);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(res.isSuccessful()).isTrue();
softly.assertThat(res.getMavenOutput().size()).isGreaterThan(0);
});
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class KieClassLoaderProviderTest method compileProjectInRepo.
private CompilationResponse compileProjectInRepo(String... mavenPhases) throws IOException {
tmpRoot = Files.createTempDirectory("repo");
tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_KIE_MULTIMODULE_CLASSLOADER_DIR);
uberfireTmp = Paths.get(tmp.toAbsolutePath().toString());
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(new HashSet<>());
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(uberfireTmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, mavenPhases, Boolean.FALSE);
return compiler.compile(req);
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class KieDefaultMavenIncrementalCompilerTest method compileProjectInRepo.
private CompilationResponse compileProjectInRepo(String... mavenPhases) throws IOException {
tmpRoot = Files.createTempDirectory("repo");
temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_DIR);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, mavenPhases, Boolean.FALSE);
return compiler.compile(req);
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class KieDefaultMavenCompilerTest method buildWithCloneTest.
@Test
public void buildWithCloneTest() throws Exception {
final String repoName = "myrepoxxxx";
final JGitFileSystem fs = (JGitFileSystem) ioService.newFileSystem(URI.create("git://" + repoName), new HashMap<String, Object>() {
{
put("init", Boolean.TRUE);
put("internal", Boolean.TRUE);
}
});
ioService.startBatch(fs);
ioService.write(fs.getPath("/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("target/test-classes/dummy_multimodule_untouched/pom.xml").toPath())));
ioService.write(fs.getPath("/dummyA/src/main/java/dummy/DummyA.java"), new String(java.nio.file.Files.readAllBytes(new File("target/test-classes/dummy_multimodule_untouched/dummyA/src/main/java/dummy/DummyA.java").toPath())));
ioService.write(fs.getPath("/dummyB/src/main/java/dummy/DummyB.java"), new String(java.nio.file.Files.readAllBytes(new File("target/test-classes/dummy_multimodule_untouched/dummyB/src/main/java/dummy/DummyB.java").toPath())));
ioService.write(fs.getPath("/dummyA/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("target/test-classes/dummy_multimodule_untouched/dummyA/pom.xml").toPath())));
ioService.write(fs.getPath("/dummyB/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("target/test-classes/dummy_multimodule_untouched/dummyB/pom.xml").toPath())));
ioService.endBatch();
Path tmpCloned = Files.createTempDirectory("cloned");
final File gitClonedFolder = new File(tmpCloned.toFile(), ".clone.git");
final Git cloned = Git.cloneRepository().setURI(fs.getGit().getRepository().getDirectory().toURI().toString()).setBare(false).setDirectory(gitClonedFolder).call();
assertThat(cloned).isNotNull();
// Compile the repo
Path prjFolder = Paths.get(gitClonedFolder + "/");
byte[] encoded = Files.readAllBytes(Paths.get(prjFolder + "/pom.xml"));
String pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertThat(pomAsAstring).doesNotContain(TestConstants.TAKARI_LIFECYCLE_ARTIFACT);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjFolder);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.FALSE);
CompilationResponse res = compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmpCloned, res, this.getClass(), testName);
assertThat(res.isSuccessful()).isTrue();
Path incrementalConfiguration = Paths.get(prjFolder + TestConstants.TARGET_TAKARI_PLUGIN);
assertThat(incrementalConfiguration.toFile()).exists();
encoded = Files.readAllBytes(Paths.get(prjFolder + "/pom.xml"));
pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertThat(pomAsAstring).contains(TestConstants.KIE_TAKARI_LIFECYCLE_ARTIFACT);
TestUtil.rm(tmpCloned.toFile());
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class KieDefaultMavenCompilerTest method buildWithJGitDecoratorTest.
@Test
public void buildWithJGitDecoratorTest() throws Exception {
String MAIN_BRANCH = "master";
// Setup origin in memory
final URI originRepo = URI.create("git://repo");
final JGitFileSystem origin = (JGitFileSystem) ioService.newFileSystem(originRepo, new HashMap<String, Object>() {
{
put("init", Boolean.TRUE);
put("internal", Boolean.TRUE);
put("listMode", "ALL");
}
});
assertThat(origin).isNotNull();
ioService.startBatch(origin);
ioService.write(origin.getPath("/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/pom.xml").toPath())));
ioService.write(origin.getPath("/dummyA/src/main/java/dummy/DummyA.java"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/src/main/java/dummy/DummyA.java").toPath())));
ioService.write(origin.getPath("/dummyB/src/main/java/dummy/DummyB.java"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/src/main/java/dummy/DummyB.java").toPath())));
ioService.write(origin.getPath("/dummyA/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/pom.xml").toPath())));
ioService.write(origin.getPath("/dummyB/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/pom.xml").toPath())));
ioService.endBatch();
RevCommit lastCommit = origin.getGit().resolveRevCommit(origin.getGit().getRef(MAIN_BRANCH).getObjectId());
assertThat(lastCommit).isNotNull();
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.UPDATE_JGIT_BEFORE_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(origin.getPath("/"));
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.FALSE);
CompilationResponse res = compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(origin.getPath("/"), res, this.getClass(), testName);
assertThat(res.isSuccessful()).isTrue();
lastCommit = origin.getGit().resolveRevCommit(origin.getGit().getRef(MAIN_BRANCH).getObjectId());
assertThat(lastCommit).isNotNull();
ioService.write(origin.getPath("/dummyA/src/main/java/dummy/DummyA.java"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/DummyA.java").toPath())));
RevCommit commitBefore = origin.getGit().resolveRevCommit(origin.getGit().getRef(MAIN_BRANCH).getObjectId());
assertThat(commitBefore).isNotNull();
assertThat(lastCommit.getId().toString()).isNotEqualTo(commitBefore.getId().toString());
// recompile
res = compiler.compile(req);
// assert commits
assertThat(res.isSuccessful()).isTrue();
}
Aggregations