use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class ClasspathKieProjectTest method checkPomProperties.
private void checkPomProperties(final String pomProperties, final String expectedGroupId, final String expectedVersion) {
Assertions.assertThat(pomProperties).isNotNull();
final ReleaseId actualReleaseId = ReleaseIdImpl.fromPropertiesString(pomProperties);
Assertions.assertThat(actualReleaseId.getGroupId()).isEqualTo(expectedGroupId);
Assertions.assertThat(actualReleaseId.getVersion()).isEqualTo(expectedVersion);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class KieProjectRuntimeModulesTest method createModuleAndFindResources.
@Test
public void createModuleAndFindResources() throws IOException, ClassNotFoundException, InterruptedException {
createKieModule("fol4", false);
ReleaseId releaseId = KieServices.Factory.get().newReleaseId("fol4", "art1", "1.0-SNAPSHOT");
KieContainer kieContainer = KieServices.Factory.get().newKieContainer(releaseId);
assertNotNull(kieContainer);
InputStream is = kieContainer.getClassLoader().getResourceAsStream("/META-INF/beans.xml");
assertNotNull(is);
byte[] bytesFromStream = readBytesFromInputStream(is);
Enumeration<URL> foundResources = kieContainer.getClassLoader().getResources("/META-INF/beans.xml");
assertNotNull(foundResources);
List<URL> resourcesAsList = Collections.list(foundResources);
assertNotNull(resourcesAsList);
assertEquals(1, resourcesAsList.size());
URL resourceUrl = resourcesAsList.get(0);
byte[] bytesFromURL = readBytesFromInputStream(resourceUrl.openStream());
assertTrue(Arrays.equals(bytesFromStream, bytesFromURL));
String url = resourceUrl.toString();
assertNotNull(url);
assertEquals("mfs:/META-INF/beans.xml", url);
String file = resourceUrl.getFile();
assertNotNull(file);
assertEquals("/META-INF/beans.xml", file);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class KieBuilderImpl method buildAll.
public KieBuilder buildAll(BiFunction<InternalKieModule, ClassLoader, KieModuleKieProject> kprojectSupplier, Predicate<String> classFilter) {
PomModel pomModel = init();
// kModuleModel will be null if a provided pom.xml or kmodule.xml is invalid
if (!isBuilt() && kModuleModel != null) {
trgMfs = new MemoryFileSystem();
writePomAndKModule();
addKBasesFilesToTrg();
markSource();
MemoryKieModule memoryKieModule = new MemoryKieModule(adapt(releaseId), kModuleModel, trgMfs);
if (kieDependencies != null && !kieDependencies.isEmpty()) {
for (KieModule kieModule : kieDependencies) {
memoryKieModule.addKieDependency((InternalKieModule) kieModule);
}
}
if (pomModel != null) {
memoryKieModule.setPomModel(pomModel);
}
KieModuleKieProject kProject = kprojectSupplier.apply(memoryKieModule, classLoader);
for (ReleaseId unresolvedDep : memoryKieModule.getUnresolvedDependencies()) {
results.addMessage(Level.ERROR, "pom.xml", "Unresolved dependency " + unresolvedDep);
}
List<String> pmmlFileNames = getPmmlFileNames(srcMfs);
if (pmmlFileNames != null && !pmmlFileNames.isEmpty()) {
buildPMMLPojos(pmmlFileNames, kProject);
}
compileJavaClasses(kProject.getClassLoader(), classFilter);
buildKieProject(results, kProject, trgMfs);
kModule = kProject.getInternalKieModule();
}
return this;
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class KieContainerImpl method updateDependencyToVersion.
public Results updateDependencyToVersion(ReleaseId currentReleaseId, ReleaseId newReleaseId) {
ReleaseId installedReleaseId = getReleaseId();
if (currentReleaseId.getGroupId().equals(installedReleaseId.getGroupId()) && currentReleaseId.getArtifactId().equals(installedReleaseId.getArtifactId())) {
// upgrading the kProject itself: taking the kmodule from there
return updateToVersion(newReleaseId);
}
checkNotClasspathKieProject();
// upgrading a transitive dependency: taking the kmodule from the krepo
// if the new and the current release are equal (a snapshot) check if there is an older version with the same releaseId
InternalKieModule currentKM = currentReleaseId.equals(newReleaseId) ? (InternalKieModule) ((KieRepositoryImpl) kr).getOldKieModule(currentReleaseId) : (InternalKieModule) kr.getKieModule(currentReleaseId);
return update(currentKM, newReleaseId);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class KieModuleKieProject method updateToModule.
public Map<String, KieBaseModel> updateToModule(InternalKieModule updatedKieModule) {
Map<String, KieBaseModel> oldKieBaseModels = new HashMap<String, KieBaseModel>();
oldKieBaseModels.putAll(kBaseModels);
this.kieModules = null;
this.kJarFromKBaseName.clear();
ReleaseId currentReleaseId = this.kieModule.getReleaseId();
ReleaseId updatingReleaseId = updatedKieModule.getReleaseId();
if (currentReleaseId.getGroupId().equals(updatingReleaseId.getGroupId()) && currentReleaseId.getArtifactId().equals(updatingReleaseId.getArtifactId())) {
this.kieModule = updatedKieModule;
} else if (this.kieModule.getKieDependencies().keySet().contains(updatingReleaseId)) {
this.kieModule.addKieDependency(updatedKieModule);
}
synchronized (this) {
cleanIndex();
// this might override class definitions, not sure we can do it any other way though
init();
// reset resource provider so it will serve resources from updated kmodule
this.cl.setResourceProvider(kieModule.createResourceProvider());
}
return oldKieBaseModels;
}
Aggregations