コード例 #1
0
  private Map<DependencyDescriptor, Artifact> scanForUpdates() {
    Map<ReleaseId, DependencyDescriptor> replacedArtifacts =
        new HashMap<ReleaseId, DependencyDescriptor>();
    Map<DependencyDescriptor, Artifact> newArtifacts =
        new HashMap<DependencyDescriptor, Artifact>();

    ArtifactResolver artifactResolver = getArtifactResolver();
    // WORKAROUND: since aether doesn't obey update policy we have to create a new Session for each
    // scan
    artifactResolver.renewSession();

    for (Map.Entry<ReleaseId, DependencyDescriptor> entry : usedDependencies.entrySet()) {
      Artifact newArtifact = artifactResolver.resolveArtifact(entry.getKey());
      if (newArtifact == null) {
        continue;
      }
      DependencyDescriptor resolvedDep = new DependencyDescriptor(newArtifact);
      if (resolvedDep.isNewerThan(entry.getValue())) {
        newArtifacts.put(entry.getValue(), newArtifact);
        replacedArtifacts.put(entry.getKey(), resolvedDep);
      }
    }

    for (Map.Entry<ReleaseId, DependencyDescriptor> entry : replacedArtifacts.entrySet()) {
      usedDependencies.put(entry.getKey(), entry.getValue());
    }

    return newArtifacts;
  }
コード例 #2
0
 private void indexAtifacts() {
   Collection<DependencyDescriptor> deps = getArtifactResolver().getAllDependecies();
   for (DependencyDescriptor dep : deps) {
     if (!dep.isFixedVersion()) {
       Artifact artifact = getArtifactResolver().resolveArtifact(dep.getReleaseId());
       log.debug(artifact + " resolved to  " + artifact.getFile());
       if (isKJar(artifact.getFile())) {
         usedDependencies.put(dep.getReleaseId(), new DependencyDescriptor(artifact));
       }
     }
   }
 }
コード例 #3
0
 private void updateKieModule(DependencyDescriptor oldDependency, Artifact artifact) {
   ReleaseId newReleaseId = new DependencyDescriptor(artifact).getReleaseId();
   ZipKieModule kieModule = createZipKieModule(newReleaseId, artifact.getFile());
   if (kieModule != null) {
     ResultsImpl messages = build(kieModule);
     if (messages.filterMessages(Message.Level.ERROR).isEmpty()) {
       ((InternalKieContainer) kieContainer)
           .updateDependencyToVersion(oldDependency.getArtifactReleaseId(), newReleaseId);
       oldDependency.setArtifactVersion(artifact.getVersion());
     }
   }
 }
コード例 #4
0
 private InternalKieModule buildArtifact(Artifact artifact, ArtifactResolver resolver) {
   DependencyDescriptor dependencyDescriptor = new DependencyDescriptor(artifact);
   ReleaseId releaseId = dependencyDescriptor.getReleaseId();
   if (releaseId.isSnapshot()) {
     ((ReleaseIdImpl) releaseId).setSnapshotVersion(artifact.getVersion());
   }
   ZipKieModule kieModule = createZipKieModule(releaseId, artifact.getFile());
   if (kieModule != null) {
     addDependencies(
         kieModule, resolver, resolver.getArtifactDependecies(dependencyDescriptor.toString()));
     build(kieModule);
   }
   return kieModule;
 }
コード例 #5
0
 private void addDependencies(
     InternalKieModule kieModule,
     ArtifactResolver resolver,
     List<DependencyDescriptor> dependencies) {
   for (DependencyDescriptor dep : dependencies) {
     Artifact depArtifact = resolver.resolveArtifact(dep.getReleaseId());
     if (depArtifact != null && isKJar(depArtifact.getFile())) {
       ReleaseId depReleaseId = new DependencyDescriptor(depArtifact).getReleaseId();
       ZipKieModule zipKieModule = createZipKieModule(depReleaseId, depArtifact.getFile());
       if (zipKieModule != null) {
         kieModule.addKieDependency(zipKieModule);
       }
     }
   }
 }