org.gradle.api.artifacts.result.ResolvedArtifactResult Java Examples

The following examples show how to use org.gradle.api.artifacts.result.ResolvedArtifactResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayDistributionPlugin.java    From playframework with Apache License 2.0 6 votes vote down vote up
private Map<File, String> calculate() {
    Map<File, String> files = new HashMap<>();
    for (ResolvedArtifactResult artifact : getResolvedArtifacts()) {
        ComponentIdentifier componentId = artifact.getId().getComponentIdentifier();
        if (componentId instanceof ProjectComponentIdentifier) {
            // rename project dependencies
            ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) componentId;
            files.put(artifact.getFile(), renameForProject(projectComponentIdentifier, artifact.getFile()));
        } else if (componentId instanceof ModuleComponentIdentifier) {
            ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) componentId;
            files.put(artifact.getFile(), renameForModule(moduleComponentIdentifier, artifact.getFile()));
        } else {
            // don't rename other types of dependencies
            files.put(artifact.getFile(), artifact.getFile().getName());
        }
    }
    return Collections.unmodifiableMap(files);
}
 
Example #2
Source File: AppendMainArtifactsCollection.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
public Set<ResolvedArtifactResult> getArtifacts() {
    if (allResults.size() == 0) {
        allResults.addAll(artifactResults.getArtifacts());

        switch (artifactType) {
            case ASSETS:
                allResults.addAll(awbBundle.getResolvedAssetsArtifactResults());
                break;

            case ANDROID_RES:
                allResults.addAll(awbBundle.getResolvedResArtifactResults());
                break;

            case SYMBOL_LIST_WITH_PACKAGE_NAME:
                allResults.addAll(awbBundle.getResolvedSymbolListWithPackageNameArtifactResults());

        }

    }
    return allResults;
}
 
Example #3
Source File: IdeDependenciesExtractor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) {
    if (artifactTypes.isEmpty()) {
        return;
    }

    ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery();
    query.forComponents(dependencies.keySet());

    @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[artifactTypes.size()];
    query.withArtifacts(JvmLibrary.class, artifactTypes.toArray(artifactTypesArray));
    Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents();
    for (ComponentArtifactsResult componentResult : componentResults) {
        for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) {
            for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) {
                if (sourcesResult instanceof ResolvedArtifactResult) {
                    dependency.setSourceFile(((ResolvedArtifactResult) sourcesResult).getFile());
                }
            }

            for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) {
                if (javadocResult instanceof ResolvedArtifactResult) {
                    dependency.setJavadocFile(((ResolvedArtifactResult) javadocResult).getFile());
                }
            }
        }
    }
}
 
Example #4
Source File: IdeDependenciesExtractor.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) {
    if (artifactTypes.isEmpty()) {
        return;
    }

    ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery();
    query.forComponents(dependencies.keySet());

    @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[artifactTypes.size()];
    query.withArtifacts(JvmLibrary.class, artifactTypes.toArray(artifactTypesArray));
    Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents();
    for (ComponentArtifactsResult componentResult : componentResults) {
        for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) {
            for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) {
                if (sourcesResult instanceof ResolvedArtifactResult) {
                    dependency.setSourceFile(((ResolvedArtifactResult) sourcesResult).getFile());
                }
            }

            for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) {
                if (javadocResult instanceof ResolvedArtifactResult) {
                    dependency.setJavadocFile(((ResolvedArtifactResult) javadocResult).getFile());
                }
            }
        }
    }
}
 
Example #5
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 5 votes vote down vote up
public HashableResolvedArtifactResult(
        @NonNull ResolvedArtifactResult delegate,
        @NonNull AtlasDependencyGraph.DependencyType dependencyType,
        boolean wrappedModule,
        @Nullable ResolvedArtifactResult bundleResult) {
    this.delegate = delegate;
    this.dependencyType = dependencyType;
    this.wrappedModule = wrappedModule;
    this.bundleResult = bundleResult;
}
 
Example #6
Source File: BuildAtlasEnvTask.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void fillAwbAndroidRes(String name, String moudleName, AwbBundle awbBundle) {
    ResolvedArtifactResult id = null;
    if ((id = allAndroidRes.get(name)) == null) {
        id = allAndroidRes.get(moudleName);
    }
    if (id != null) {
        awbBundle.getResolvedResArtifactResults().add(id);
    }

}
 
Example #7
Source File: BuildAtlasEnvTask.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void fillAwbAndroidAssets(String name, String moudleName, AwbBundle awbBundle) {
    ResolvedArtifactResult id = null;
    if ((id = allAndroidAssets.get(name)) == null) {
        id = allAndroidAssets.get(moudleName);
    }
    if (id != null) {
        awbBundle.getResolvedAssetsArtifactResults().add(id);
    }
}
 
Example #8
Source File: BuildAtlasEnvTask.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void fillAwbAndroidRs(String name, String moudleName, AwbBundle awbBundle) {
    ResolvedArtifactResult id = null;
    if ((id = allAndroidRnames.get(name)) == null) {
        id = allAndroidRnames.get(moudleName);
    }
    if (id != null) {
        awbBundle.getResolvedSymbolListWithPackageNameArtifactResults().add(id);
    }

}
 
Example #9
Source File: AppendMainArtifactsCollection.java    From atlas with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Iterator<ResolvedArtifactResult> iterator() {
    if (allResults.size() == 0) {
        getArtifacts();
    }
    return allResults.iterator();
}
 
Example #10
Source File: MainArtifactsCollection.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public Set<ResolvedArtifactResult> getArtifacts() {
        mainDexs = new HashSet<>();
    for (ResolvedArtifactResult resolvedArtifactResult:fullArtifacts){
        String name = resolvedArtifactResult.getFile().getAbsolutePath();
        if (AtlasBuildContext.atlasMainDexHelperMap.get(variantName).getMainManifestFiles().containsKey(name.substring(0,name.lastIndexOf(File.separatorChar)))){
            mainDexs.add(resolvedArtifactResult);
        }
    }
    return mainDexs;

}
 
Example #11
Source File: MainArtifactsCollection.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public FileCollection getArtifactFiles() {
    Set<File> mainDexFiles = new HashSet<>();
    if (mainDexs != null){
        for (ResolvedArtifactResult resolvedArtifactResult:mainDexs){
            mainDexFiles.add(resolvedArtifactResult.getFile());
        }
    }else {
        getArtifacts();
        getArtifactFiles();
    }

    return project.files(mainDexFiles);
}
 
Example #12
Source File: AwbBundle.java    From atlas with Apache License 2.0 4 votes vote down vote up
public List<ResolvedArtifactResult> getResolvedAssetsArtifactResults() {
    return resolvedAssetsArtifactResults;
}
 
Example #13
Source File: PlayDistributionPlugin.java    From playframework with Apache License 2.0 4 votes vote down vote up
Set<ResolvedArtifactResult> getResolvedArtifacts() {
    ArtifactCollection artifacts = configuration.getIncoming().getArtifacts();
    return artifacts.getArtifacts();
}
 
Example #14
Source File: GradlePluginApp.java    From steady with Apache License 2.0 4 votes vote down vote up
@Override
  protected void executeGoal() throws Exception {

      if (projectOutputType == null) {
          getLogger().quiet("Skip vulas-app in project {}", project.getName());
          return;
      }

      String configurationName=VulasConfiguration.getGlobal().getConfiguration().getString("vulas.gradle.configuration." + projectOutputType.toString().toLowerCase());

      if (configurationName == null) {
          configurationName = defaultConfigurations.get(projectOutputType);
      }

      Configuration configToAnalyze = project.getConfigurations().getAt(configurationName);
      getLogger().quiet("Resolving configuration {}", configToAnalyze.getName());

      //DependencyResolver.resolve(configToAnalyze);

      Set<ResolvedArtifactResult> artifacts = DependencyResolver.resolve(configToAnalyze);
      Set<ResolvedArtifactResult> direct_artifacts = DependencyResolver.resolveDirectOnly(configToAnalyze);

      int count = 0;
      Dependency dep = null;
      //Path to dependency info
final Map<Path, Dependency> dep_for_path = new HashMap<Path, Dependency>();
Library lib = null;
      for (ResolvedArtifactResult a : artifacts) {

          ModuleComponentIdentifier ci = ((ModuleComponentArtifactIdentifier)a.getId()).getComponentIdentifier();
          
          lib = new Library();
	lib.setLibraryId(new LibraryId(ci.getGroup(), ci.getModule(), ci.getVersion()));

	// Create dependency and put into map
          //TODO: hardcoded runtime scope, how to match gradle configs to maven scopes?
	dep = new Dependency(this.goal.getGoalContext().getApplication(), lib, Scope.RUNTIME, direct_artifacts.contains(a), null, a.getFile().getPath());
	dep_for_path.put(a.getFile().toPath(), dep);
      }
			
((AbstractAppGoal)this.goal).setKnownDependencies(dep_for_path);

      goal.executeSync();

      cleanupTempFiles();
  }
 
Example #15
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 4 votes vote down vote up
public ResolvedArtifactResult getBundleResult() {
    return bundleResult;
}
 
Example #16
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 4 votes vote down vote up
public ResolvedArtifactResult getDelegate() {
    return delegate;
}
 
Example #17
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
private static MavenCoordinates computeMavenCoordinates(
        @NonNull ResolvedArtifactResult artifact) {
    // instance should be a hashable.
    AtlasDependencyGraph.HashableResolvedArtifactResult hashableResult = (AtlasDependencyGraph.HashableResolvedArtifactResult) artifact;

    ComponentIdentifier id = artifact.getId().getComponentIdentifier();

    final File artifactFile = artifact.getFile();
    final String fileName = artifactFile.getName();
    String extension = hashableResult.getDependencyType().getExtension();
    if (id instanceof ModuleComponentIdentifier) {
        ModuleComponentIdentifier moduleComponentId = (ModuleComponentIdentifier) id;
        final String module = moduleComponentId.getModule();
        final String version = moduleComponentId.getVersion();
        String classifier = null;

        if (!artifact.getFile().isDirectory()) {
            // attempts to compute classifier based on the filename.
            String pattern = "^" + module + "-" + version + "-(.+)\\." + extension + "$";

            Pattern p = Pattern.compile(pattern);
            Matcher m = p.matcher(fileName);
            if (m.matches()) {
                classifier = m.group(1);
            }
        }

        return new MavenCoordinatesImpl(
                moduleComponentId.getGroup(), module, version, extension, classifier);
    } else if (id instanceof ProjectComponentIdentifier) {
        return new MavenCoordinatesImpl(
                "artifacts", ((ProjectComponentIdentifier) id).getProjectPath(), "unspecified");
    } else if (id instanceof OpaqueComponentArtifactIdentifier) {
        // We have a file based dependency
        if (hashableResult.getDependencyType() == DependencyType.JAVA) {
            return getMavenCoordForLocalFile(artifactFile);
        } else {
            // local aar?
            assert artifactFile.isDirectory();
            return getMavenCoordForLocalFile(artifactFile);
        }
    }

    throw new RuntimeException(
            "Don't know how to compute maven coordinate for artifact '"
                    + artifact.getId().getDisplayName()
                    + "' with component identifier of type '"
                    + id.getClass()
                    + "'.");
}
 
Example #18
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Nullable
public static String getVariant(@NonNull ResolvedArtifactResult artifact) {
    VariantAttr variantAttr =
            artifact.getVariant().getAttributes().getAttribute(VariantAttr.ATTRIBUTE);
    return variantAttr == null ? null : variantAttr.getName();
}
 
Example #19
Source File: FeatureVariantContext.java    From atlas with Apache License 2.0 4 votes vote down vote up
public File getModifiedManifest(ResolvedArtifactResult artifact) {
    return new File(getModifyManifestDir(),
            MergeManifests.getArtifactName(artifact) +
                    ".xml");

}
 
Example #20
Source File: AwbBundle.java    From atlas with Apache License 2.0 4 votes vote down vote up
public List<ResolvedArtifactResult> getResolvedSymbolListWithPackageNameArtifactResults() {
    return resolvedSymbolListWithPackageNameArtifactResults;
}
 
Example #21
Source File: MainArtifactsCollection.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Spliterator<ResolvedArtifactResult> spliterator() {
    return getArtifacts().spliterator();
}
 
Example #22
Source File: AwbBundle.java    From atlas with Apache License 2.0 4 votes vote down vote up
public List<ResolvedArtifactResult> getResolvedResArtifactResults() {
    return resolvedResArtifactResults;
}
 
Example #23
Source File: BuildAtlasEnvTask.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Iterator<ResolvedArtifactResult> iterator() {
    return getArtifacts().iterator();
}
 
Example #24
Source File: BuildAtlasEnvTask.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Set<ResolvedArtifactResult> getArtifacts() {
    return ImmutableSet.of();
}
 
Example #25
Source File: MainArtifactsCollection.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public Iterator<ResolvedArtifactResult> iterator() {
    return getArtifacts().iterator();
}
 
Example #26
Source File: MainArtifactsCollection.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public void forEach(Consumer<? super ResolvedArtifactResult> action) {
    getArtifacts().forEach(action);
}