Search in sources :

Example 51 with CompilationResponse

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

the class KieClassLoaderProviderTest method loadProjectClassloaderFromStringTest.

@Test
public void loadProjectClassloaderFromStringTest() 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();
    Optional<ClassLoader> clazzLoader = CompilerClassloaderUtils.loadDependenciesClassloaderFromProject(uberfireTmp.toAbsolutePath().toString(), mavenRepoPath);
    assertThat(clazzLoader).isPresent();
    LoadProjectDependencyUtil.loadLoggerFactory(clazzLoader.get());
}
Also used : URLClassLoader(java.net.URLClassLoader) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) Test(org.junit.Test)

Example 52 with CompilationResponse

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

the class JGITCompilerBeforeDecoratorTest method compileTestTwo.

@Test
public void compileTestTwo() throws Exception {
    final FileSystem fileSystem = createFileSystem("myrepodecorator");
    // Compile the repo
    JGITCompilerBeforeDecorator compiler = new JGITCompilerBeforeDecorator(new BaseMavenCompiler(true, false));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(fileSystem.getPath("/"));
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.TRUE);
    CompilationResponse res = compiler.compile(req);
    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();
    final 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) 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) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) 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 53 with CompilationResponse

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

the class JGITCompilerBeforeDecoratorTest method compileWithOverrideTest.

@Test
public void compileWithOverrideTest() 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<>();
    org.uberfire.java.nio.file.Path path = fileSystem.getPath("/", "/dummyA/src/main/java/dummy/Person.java");
    InputStream input = new FileInputStream(new File("target/test-classes/kjar-2-single-resources_override/src/main/java/dummy/PersonOverride.java"));
    override.put(path, input);
    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();
    final Path incrementalConfiguration = Paths.get(tempPath.toUri() + TARGET_TAKARI_PLUGIN);
    assertThat(incrementalConfiguration.toFile().exists()).isTrue();
    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) Path(org.uberfire.java.nio.file.Path) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) FileInputStream(java.io.FileInputStream) 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) File(java.io.File) 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)

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