use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class KieMetadataTest method compileAndloadKieJarSingleMetadataWithPackagedJar.
@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileAndloadKieJarSingleMetadataWithPackagedJar() throws Exception {
/**
* If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
*/
Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_SINGLE_RESOURCES);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
if (!res.isSuccessful()) {
List<String> msgs = res.getMavenOutput();
for (String msg : msgs) {
logger.info(msg);
}
}
assertThat(res.isSuccessful()).isTrue();
Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
assertThat(metaDataOptional).isPresent();
KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
assertThat(kieModuleMetaInfo).isNotNull();
Optional<KieModule> kieModuleOptional = res.getKieModule();
assertThat(kieModuleOptional).isPresent();
KieModule kModule = kieModuleOptional.get();
assertThat(res.getDependenciesAsURI()).hasSize(4);
KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule, res.getDependenciesAsURI());
assertThat(kieModuleMetaData).isNotNull();
// comment if you want read the log file after the test run
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class KieMetadataTest method compileAndloadKieJarSingleMetadata.
@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileAndloadKieJarSingleMetadata() {
/**
* If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
*/
try {
Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_SINGLE_RESOURCES);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
if (!res.isSuccessful()) {
List<String> msgs = res.getMavenOutput();
for (String msg : msgs) {
logger.info(msg);
}
}
assertThat(res.isSuccessful()).isTrue();
Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
assertThat(metaDataOptional).isPresent();
KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
assertThat(kieModuleMetaInfo).isNotNull();
Optional<KieModule> kieModuleOptional = res.getKieModule();
assertThat(kieModuleOptional).isPresent();
assertThat(res.getDependenciesAsURI()).hasSize(4);
// comment if you want read the log file after the test run
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class ArchetypeTest method testArchetypeGenerate.
@Test
public void testArchetypeGenerate() throws Exception {
Path tmpRoot = Files.createTempDirectory("repo");
Path tmp = Paths.get(tmpRoot.toAbsolutePath().toString());
assertThat(isDirEmpty(tmpRoot)).isTrue();
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath.toAbsolutePath().toString(), info, new String[] { MavenConfig.ARCHETYPE_GENERATE, MavenConfig.ARCHETYPE_GENERATE_BLANK, MavenConfig.GROUP_ID + groupId, MavenConfig.ARTIFACT_ID + artifactId, MavenConfig.ARCHETYPE_ARTIFACT_ID + archetypeArtifactId }, Boolean.TRUE);
CompilationResponse res = compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmpRoot, res, this.getClass(), testName);
assertThat(res.isSuccessful()).isTrue();
assertThat(res.getMavenOutput().size()).isGreaterThan(0);
assertThat(isDirEmpty(tmpRoot)).isFalse();
Path prj = Paths.get(tmpRoot.toAbsolutePath().toString(), artifactId);
assertThat(isDirEmpty(prj)).isFalse();
Path appDir = Paths.get(prj.toAbsolutePath().toString(), "/src/main/java/" + (groupId.replace(".", "/")));
assertThat(isDirEmpty(appDir)).isFalse();
Path testDir = Paths.get(prj.toAbsolutePath().toString(), "/src/test/java/" + (groupId.replace(".", "/")));
assertThat(isDirEmpty(testDir)).isFalse();
Path pom = Paths.get(tmpRoot.toAbsolutePath().toString(), artifactId + "/pom.xml");
assertThat(Files.exists(pom)).isTrue();
TestUtil.rm(tmpRoot.toFile());
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class DefaultRemoteExecutor method internalBuild.
private CompletableFuture<KieCompilationResponse> internalBuild(String projectPath, String mavenRepoPath, String settingsXmlPath, boolean skipProjectDepCreation, String goal) {
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(projectPath));
AFCompiler compiler = getCompiler(projectPath);
CompilationRequest req;
if (settingsXmlPath != null) {
req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.ALTERNATE_USER_SETTINGS + settingsXmlPath, goal }, skipProjectDepCreation);
} else {
req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { goal }, skipProjectDepCreation);
}
return runInItsOwnThread(compiler, req);
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class DefaultLocalExecutor method setupCompileInfo.
private CompilerAggregateEntryCache setupCompileInfo(Path workingDir) {
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.UPDATE_JGIT_BEFORE_BUILD, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(workingDir);
return new CompilerAggregateEntryCache(compiler, info);
}
Aggregations