use of org.appformer.maven.integration.DependencyDescriptor in project drools by kiegroup.
the class KieRepositoryScannerImpl method updateKieModule.
private boolean updateKieModule(DependencyDescriptor oldDependency, Artifact artifact) {
org.appformer.maven.support.AFReleaseId newReleaseId = new DependencyDescriptor(artifact).getReleaseId();
InternalKieModule kieModule = createKieModule(newReleaseId, artifact.getFile());
if (kieModule != null) {
addDependencies(kieModule, artifactResolver, artifactResolver.getArtifactDependecies(newReleaseId.toString()));
ResultsImpl messages = kieModule.build();
if (messages.filterMessages(Message.Level.ERROR).isEmpty()) {
Results updateMessages = kieContainer.updateDependencyToVersion(adapt(oldDependency.getArtifactReleaseId()), adapt(newReleaseId));
oldDependency.setArtifactVersion(artifact.getVersion());
// append all update Results into build Results to notify listeners
messages.getMessages().addAll(updateMessages.getMessages());
}
listeners.fireKieScannerUpdateResultsEventImpl(messages);
return !messages.hasMessages(Message.Level.ERROR);
}
return false;
}
use of org.appformer.maven.integration.DependencyDescriptor in project drools by kiegroup.
the class KieRepositoryScannerImpl method addDependencies.
private void addDependencies(InternalKieModule kieModule, ArtifactResolver resolver, List<DependencyDescriptor> dependencies) {
for (DependencyDescriptor dep : dependencies) {
InternalKieModule dependency = (InternalKieModule) KieServices.Factory.get().getRepository().getKieModule(adapt(dep.getReleaseId()));
if (dependency != null) {
kieModule.addKieDependency(dependency);
} else {
Artifact depArtifact = resolver.resolveArtifact(dep.getReleaseId());
if (depArtifact != null && isKJar(depArtifact.getFile())) {
ReleaseId depReleaseId = adapt(new DependencyDescriptor(depArtifact).getReleaseId());
InternalKieModule zipKieModule = createKieModule(depReleaseId, depArtifact.getFile());
if (zipKieModule != null) {
kieModule.addKieDependency(zipKieModule);
}
}
}
}
}
use of org.appformer.maven.integration.DependencyDescriptor in project drools by kiegroup.
the class KieModuleMetaDataImpl method init.
private void init(ArtifactResolver artifactResolver) {
if (artifactResolver == null) {
return;
}
if (releaseId != null) {
addArtifact(artifactResolver.resolveArtifact(releaseId));
}
if (kieModule != null && kieModule.getPomModel() != null) {
for (AFReleaseId releaseId : kieModule.getPomModel().getDependencies(dependencyFilter)) {
addArtifact(artifactResolver.resolveArtifact(releaseId));
}
} else {
for (DependencyDescriptor dep : artifactResolver.getAllDependecies(dependencyFilter)) {
addArtifact(artifactResolver.resolveArtifact(dep.getReleaseId()));
}
}
packages.addAll(classes.keySet());
packages.addAll(rulesByPackage.keySet());
}
use of org.appformer.maven.integration.DependencyDescriptor in project drools by kiegroup.
the class KieRepositoryScannerImpl method scanForUpdates.
private Map<DependencyDescriptor, Artifact> scanForUpdates() {
artifactResolver = getResolverFor(kieContainer, true);
if (!kieProjectDescr.getReleaseId().equals(this.kieContainer.getReleaseId())) {
kieProjectDescr = new DependencyDescriptor(this.kieContainer.getReleaseId(), this.kieContainer.getCreationTimestamp());
}
Map<DependencyDescriptor, Artifact> newArtifacts = new HashMap<DependencyDescriptor, Artifact>();
Artifact newArtifact = artifactResolver.resolveArtifact(this.kieContainer.getConfiguredReleaseId());
if (newArtifact != null) {
DependencyDescriptor resolvedDep = new DependencyDescriptor(newArtifact);
if (resolvedDep.isNewerThan(kieProjectDescr)) {
newArtifacts.put(kieProjectDescr, newArtifact);
kieProjectDescr = new DependencyDescriptor(newArtifact);
}
}
for (DependencyDescriptor dep : artifactResolver.getAllDependecies()) {
ReleaseId artifactId = adapt(dep.getReleaseIdWithoutVersion());
DependencyDescriptor oldDep = usedDependencies.get(artifactId);
if (oldDep != null) {
newArtifact = artifactResolver.resolveArtifact(dep.getReleaseId());
if (newArtifact != null) {
DependencyDescriptor newDep = new DependencyDescriptor(newArtifact);
if (newDep.isNewerThan(oldDep)) {
newArtifacts.put(oldDep, newArtifact);
usedDependencies.put(artifactId, newDep);
}
}
}
}
return newArtifacts;
}
use of org.appformer.maven.integration.DependencyDescriptor in project drools by kiegroup.
the class KieRepositoryScannerImpl method buildArtifact.
private InternalKieModule buildArtifact(Artifact artifact, ArtifactResolver resolver) {
DependencyDescriptor dependencyDescriptor = new DependencyDescriptor(artifact);
ReleaseId releaseId = adapt(dependencyDescriptor.getReleaseId());
if (releaseId.isSnapshot()) {
((ReleaseIdImpl) releaseId).setSnapshotVersion(artifact.getVersion());
}
InternalKieModule kieModule = createKieModule(releaseId, artifact.getFile());
if (kieModule != null) {
addDependencies(kieModule, resolver, resolver.getArtifactDependecies(dependencyDescriptor.toString()));
kieModule.build();
}
return kieModule;
}
Aggregations