Search in sources :

Example 1 with DependencyDescriptor

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;
}
Also used : DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor) Results(org.kie.api.builder.Results) ResultsImpl(org.drools.compiler.kie.builder.impl.ResultsImpl) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 2 with DependencyDescriptor

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);
                }
            }
        }
    }
}
Also used : DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor) ReleaseId(org.kie.api.builder.ReleaseId) Artifact(org.eclipse.aether.artifact.Artifact) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 3 with DependencyDescriptor

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());
}
Also used : AFReleaseId(org.appformer.maven.support.AFReleaseId) DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor)

Example 4 with DependencyDescriptor

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;
}
Also used : DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor) HashMap(java.util.HashMap) ReleaseId(org.kie.api.builder.ReleaseId) Artifact(org.eclipse.aether.artifact.Artifact)

Example 5 with DependencyDescriptor

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;
}
Also used : ReleaseIdImpl(org.drools.compiler.kproject.ReleaseIdImpl) DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor) ReleaseId(org.kie.api.builder.ReleaseId) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Aggregations

DependencyDescriptor (org.appformer.maven.integration.DependencyDescriptor)7 ReleaseId (org.kie.api.builder.ReleaseId)4 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)3 Artifact (org.eclipse.aether.artifact.Artifact)3 HashMap (java.util.HashMap)2 AFReleaseId (org.appformer.maven.support.AFReleaseId)1 ResultsImpl (org.drools.compiler.kie.builder.impl.ResultsImpl)1 ReleaseIdImpl (org.drools.compiler.kproject.ReleaseIdImpl)1 Results (org.kie.api.builder.Results)1 KieScannerMBeanImpl (org.kie.scanner.management.KieScannerMBeanImpl)1