use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest 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());
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest 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());
}
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 KieMetadataTest method compileAndLoadKieJarMetadataAllResourcesPackagedJar.
@Ignore("https://issues.redhat.com/browse/AF-2741\n" + "https://issues.redhat.com/browse/AF-2892")
// AF-1459 it tooks 30% of the time of the time spent by all module's test (108), alone it took 30 sec
@Test
public void compileAndLoadKieJarMetadataAllResourcesPackagedJar() throws Exception {
/**
* If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
*/
Path temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_ALL_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(temp);
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(temp, 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();
Map<String, Set<String>> rulesBP = kieModuleMetaInfo.getRulesByPackage();
assertThat(rulesBP).hasSize(6);
Map<String, TypeMetaInfo> typesMI = kieModuleMetaInfo.getTypeMetaInfos();
// This is a "magic number" test and may or may not be valid since changes
// to the mechanism for generating classes, especially in PMML processing,
// may cause this value to change.
assertThat(typesMI).hasSize(22);
Optional<KieModule> kieModuleOptional = res.getKieModule();
assertThat(kieModuleOptional).isPresent();
assertThat(res.getDependenciesAsURI()).hasSize(4);
KieModule kModule = kieModuleOptional.get();
KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule, res.getDependenciesAsURI());
assertThat(kieModuleMetaData).isNotNull();
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class ConcurrentBuildTest method compileAndLoadKieJarMetadataAllResourcesPackagedJar.
private KieCompilationResponse compileAndLoadKieJarMetadataAllResourcesPackagedJar() {
String alternateSettingsAbsPath = TestUtilMaven.getSettingsFile();
Path tmpRoot = Files.createTempDirectory("repo_" + UUID.randomUUID().toString());
Path tmp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
try {
TestUtil.copyTree(Paths.get(ResourcesConstants.KJAR_2_ALL_RESOURCES), tmp);
} catch (Exception e) {
logger.error(e.getMessage());
}
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_KIE_OBJECTS, KieDecorator.ENABLE_LOGGING));
final KieCompilationResponse res;
try {
final WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
final CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
res = (KieCompilationResponse) compiler.compile(req);
logger.info("\nFinished, successful:{} , all Metadata tmp:{} UUID:{} res.getMavenOutput().isEmpty():{}", res.isSuccessful(), tmp, req.getRequestUUID(), res.getMavenOutput().isEmpty());
if (!res.isSuccessful()) {
try {
logger.error("writing output on target folder:{}", tmp);
TestUtil.writeMavenOutputIntoTargetFolder(tmp, res.getMavenOutput(), "ConcurrentBuildTest.compileAndLoadKieJarMetadataAllResourcesPackagedJar_" + req.getRequestUUID());
} catch (Exception e) {
logger.error(e.getMessage());
}
}
} finally {
latch.countDown();
}
return res;
}
Aggregations