コード例 #1
0
 @Override
 public void completeVersions(ModuleVersionQuery query, ModuleVersionResult result) {
   // abort if not JVM
   if (query.getType() != ModuleQuery.Type.JVM) return;
   if (query.getName() == null || !JDK_MODULES.contains(query.getName())) return;
   if (query.getVersion() != null && !query.getVersion().equals(JDK_VERSION)) return;
   final ModuleVersionDetails newVersion = result.addVersion(JDK_VERSION);
   newVersion.setDoc(doc(query.getName()));
   newVersion.setVersion(JDK_VERSION);
 }
コード例 #2
0
ファイル: AetherUtils.java プロジェクト: ysb33r/ceylon
 private void addSearchResult(
     String groupId,
     String artifactId,
     String version,
     ModuleVersionResult result,
     Overrides overrides,
     String repositoryDisplayString)
     throws AetherException {
   ArtifactOverrides artifactOverrides = null;
   if (overrides != null) {
     ArtifactContext ctx =
         new ArtifactContext(MavenRepository.NAMESPACE, groupId + ":" + artifactId, version);
     // see if this artifact is replaced
     ArtifactContext replaceContext = overrides.replace(ctx);
     if (replaceContext != null) {
       String[] groupArtifactIds = nameToGroupArtifactIds(replaceContext.getName());
       if (groupArtifactIds == null) return; // abort
       groupId = groupArtifactIds[0];
       artifactId = groupArtifactIds[1];
       version = replaceContext.getVersion();
       ctx = replaceContext;
     } else if (overrides.isVersionOverridden(ctx)) {
       // perhaps its version is overridden?
       version = overrides.getVersionOverride(ctx);
       ctx.setVersion(version);
     }
     artifactOverrides = overrides.getArtifactOverrides(ctx);
   }
   DependencyDescriptor info =
       impl.getDependencies(groupId, artifactId, version, null, "pom", false);
   if (info != null) {
     StringBuilder description = new StringBuilder();
     StringBuilder licenseBuilder = new StringBuilder();
     collectInfo(info, description, licenseBuilder);
     Set<ModuleDependencyInfo> dependencies = new HashSet<>();
     Set<ModuleVersionArtifact> artifactTypes = new HashSet<>();
     artifactTypes.add(new ModuleVersionArtifact(".jar", null, null));
     Set<String> authors = new HashSet<>();
     for (DependencyDescriptor dep : info.getDependencies()) {
       String namespace = MavenRepository.NAMESPACE;
       String depName = dep.getGroupId() + ":" + dep.getArtifactId();
       String depVersion = dep.getVersion();
       boolean export = false;
       boolean optional = dep.isOptional();
       if (overrides != null) {
         ArtifactContext depCtx = new ArtifactContext(namespace, depName, dep.getVersion());
         if (overrides.isRemoved(depCtx)
             || (artifactOverrides != null
                 && (artifactOverrides.isRemoved(depCtx)
                     || artifactOverrides.isAddedOrUpdated(depCtx)))) continue;
         ArtifactContext replaceCtx = overrides.replace(depCtx);
         if (replaceCtx != null) {
           depCtx = replaceCtx;
           namespace = replaceCtx.getNamespace();
           depName = replaceCtx.getName();
         }
         if (overrides.isVersionOverridden(depCtx))
           depVersion = overrides.getVersionOverride(depCtx);
         if (artifactOverrides != null) {
           if (artifactOverrides.isShareOverridden(depCtx))
             export = artifactOverrides.isShared(depCtx);
           if (artifactOverrides.isOptionalOverridden(depCtx))
             optional = artifactOverrides.isOptional(depCtx);
         }
       }
       ModuleDependencyInfo moduleDependencyInfo =
           new ModuleDependencyInfo(namespace, depName, depVersion, optional, export);
       dependencies.add(moduleDependencyInfo);
     }
     if (artifactOverrides != null) {
       for (DependencyOverride add : artifactOverrides.getAdd()) {
         ArtifactContext ac = add.getArtifactContext();
         ModuleDependencyInfo moduleDependencyInfo =
             new ModuleDependencyInfo(
                 ac.getNamespace(),
                 ac.getName(),
                 ac.getVersion(),
                 add.isOptional(),
                 add.isShared());
         dependencies.add(moduleDependencyInfo);
       }
     }
     ModuleVersionDetails moduleVersionDetails =
         new ModuleVersionDetails(
             MavenRepository.NAMESPACE,
             groupId + ":" + artifactId,
             version,
             description.length() > 0 ? description.toString() : null,
             licenseBuilder.length() > 0 ? licenseBuilder.toString() : null,
             authors,
             dependencies,
             artifactTypes,
             true,
             repositoryDisplayString);
     result.addVersion(moduleVersionDetails);
   }
 }