Search in sources :

Example 21 with CompilationResponse

use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.

the class KieClassLoaderProviderTest method loadTargetFolderClassloaderTest.

@Test
public void loadTargetFolderClassloaderTest() throws Exception {
    // we use NIO for this part of the test because Uberfire lack the implementation to copy a tree
    CompilationResponse res = compileProjectInRepo(MavenCLIArgs.COMPILE);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
    List<String> pomList = MavenUtils.searchPoms(uberfireTmp);
    Optional<ClassLoader> clazzLoader = CompilerClassloaderUtils.getClassloaderFromProjectTargets(pomList);
    assertThat(clazzLoader).isPresent();
    LoadProjectDependencyUtil.loadDummyB(clazzLoader.get());
}
Also used : URLClassLoader(java.net.URLClassLoader) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) Test(org.junit.Test)

Example 22 with CompilationResponse

use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.

the class KieClassLoaderProviderTest method loadProjectClassloaderTest.

@Test
public void loadProjectClassloaderTest() throws Exception {
    // we use NIO for this part of the test because Uberfire lack the implementation to copy a tree
    CompilationResponse res = compileProjectInRepo(MavenCLIArgs.COMPILE);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
    List<String> pomList = MavenUtils.searchPoms(Paths.get(ResourcesConstants.DUMMY_KIE_MULTIMODULE_CLASSLOADER_DIR));
    Optional<ClassLoader> clazzLoader = CompilerClassloaderUtils.loadDependenciesClassloaderFromProject(pomList, mavenRepoPath);
    assertThat(clazzLoader).isPresent();
    ClassLoader prjClassloader = clazzLoader.get();
    LoadProjectDependencyUtil.loadLoggerFactory(prjClassloader);
}
Also used : URLClassLoader(java.net.URLClassLoader) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) Test(org.junit.Test)

Example 23 with CompilationResponse

use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.

the class KieDefaultMavenIncrementalCompilerTest method testIncrementalWithPluginEnabledThreeTime.

@Test
public void testIncrementalWithPluginEnabledThreeTime() throws Exception {
    tmpRoot = Files.createTempDirectory("repo");
    // NIO creation and copy content
    Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_DIR);
    // end NIO
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_INCREMENTAL_BUILD));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.FALSE);
    CompilationResponse res = compiler.compile(req);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
    res = compiler.compile(req);
    assertThat(res.isSuccessful()).isTrue();
    res = compiler.compile(req);
    assertThat(res.isSuccessful()).isTrue();
    Path incrementalConfiguration = Paths.get(tmp.toAbsolutePath().toString(), "/target/incremental/io.takari.maven.plugins_takari-lifecycle-plugin_compile_compile");
    assertThat(incrementalConfiguration.toFile()).exists();
}
Also used : Path(org.uberfire.java.nio.file.Path) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) Test(org.junit.Test)

Example 24 with CompilationResponse

use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.

the class JGITCompilerBeforeDecoratorTest method compileWithEmptyOverrideTest.

@Test
public void compileWithEmptyOverrideTest() throws Exception {
    final FileSystem fileSystem = createFileSystem("myrepo");
    // Compile the repo
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(fileSystem.getPath("/"));
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.TRUE);
    Map<Path, InputStream> override = new HashMap<>();
    JGITCompilerBeforeDecorator compiler = new JGITCompilerBeforeDecorator(new BaseMavenCompiler(true, false));
    CompilationResponse res = compiler.compile(req, override);
    final java.nio.file.Path tempPath = ((Git) compiler.getGitMap().get(fileSystem)).getRepository().getDirectory().toPath().getParent();
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tempPath, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
    Path incrementalConfiguration = Paths.get(tempPath.toUri() + TARGET_TAKARI_PLUGIN);
    assertThat(incrementalConfiguration.toFile()).exists();
    TestUtil.rm(tempPath.toFile());
}
Also used : Path(org.uberfire.java.nio.file.Path) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) JGitFileSystem(org.uberfire.java.nio.fs.jgit.JGitFileSystem) FileSystem(org.uberfire.java.nio.file.FileSystem) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) Path(org.uberfire.java.nio.file.Path) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Example 25 with CompilationResponse

use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.

the class ClasspathDepsAfterDecoratorTest method failCompileTest.

@Test
public void failCompileTest() throws IOException {
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, createdNewPrjInRepo("dummy-fail", ResourcesConstants.DUMMY_FAIL_DEPS_SIMPLE), new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    ClasspathDepsAfterDecorator decorator = new ClasspathDepsAfterDecorator(new BaseMavenCompiler(false, false));
    CompilationResponse res = decorator.compile(req);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(res.isSuccessful()).isFalse();
        softly.assertThat(res.getDependencies()).hasSize(0);
    });
}
Also used : DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Aggregations

CompilationResponse (org.kie.workbench.common.services.backend.compiler.CompilationResponse)53 Test (org.junit.Test)51 Path (org.uberfire.java.nio.file.Path)38 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultCompilationRequest)24 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)23 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)23 File (java.io.File)18 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)18 HashMap (java.util.HashMap)17 JGitFileSystem (org.uberfire.java.nio.fs.jgit.JGitFileSystem)16 AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)13 AFCompiler (org.kie.workbench.common.services.backend.compiler.nio.AFCompiler)13 CompilationRequest (org.kie.workbench.common.services.backend.compiler.nio.CompilationRequest)13 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.nio.WorkspaceCompilationInfo)13 URLClassLoader (java.net.URLClassLoader)11 URI (java.net.URI)10 Git (org.eclipse.jgit.api.Git)9 BaseCompilerTest (org.kie.workbench.common.services.backend.compiler.BaseCompilerTest)8 BaseMavenCompiler (org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler)8 ArrayList (java.util.ArrayList)7