Search in sources :

Example 66 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class FindBugsPlugin method configureFindBugsConfigurations.

private void configureFindBugsConfigurations() {
    Configuration configuration = project.getConfigurations().create("findbugsPlugins");
    configuration.setVisible(false);
    configuration.setTransitive(true);
    configuration.setDescription("The FindBugs plugins to be used for this project.");
}
Also used : Configuration(org.gradle.api.artifacts.Configuration)

Example 67 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class IdeaDependenciesProvider method getFileDependencies.

private Set<Dependency> getFileDependencies(IdeaModule ideaModule, GeneratedIdeaScope scope) {
    Collection<Configuration> plusConfigurations = getPlusConfigurations(ideaModule, scope);
    Collection<Configuration> minusConfigurations = getMinusConfigurations(ideaModule, scope);
    Set<Dependency> dependencies = Sets.newLinkedHashSet();
    Collection<IdeLocalFileDependency> ideLocalFileDependencies = dependenciesExtractor.extractLocalFileDependencies(plusConfigurations, minusConfigurations);
    for (IdeLocalFileDependency fileDependency : ideLocalFileDependencies) {
        dependencies.add(toLibraryDependency(fileDependency, ideaModule, scope));
    }
    return dependencies;
}
Also used : IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) Configuration(org.gradle.api.artifacts.Configuration) UnresolvedIdeRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.UnresolvedIdeRepoFileDependency) IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) IdeProjectDependency(org.gradle.plugins.ide.internal.resolver.model.IdeProjectDependency) Dependency(org.gradle.plugins.ide.idea.model.Dependency) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency)

Example 68 with Configuration

use of org.gradle.api.artifacts.Configuration in project atlas by alibaba.

the class PrepareAPTask method generate.

/**
     * 生成so的目录
     */
@TaskAction
void generate() {
    Project project = getProject();
    File apBaseFile = null;
    if (null != apContext.getApFile() && apContext.getApFile().exists()) {
        apBaseFile = apContext.getApFile();
    } else if (StringUtils.isNotBlank(apContext.getApDependency())) {
        Dependency dependency = project.getDependencies().create(apContext.getApDependency());
        Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
        configuration.setTransitive(false);
        for (File file : configuration.getFiles()) {
            if (file.getName().endsWith(".ap")) {
                apBaseFile = file;
                break;
            }
        }
    }
    if (null != apBaseFile && apBaseFile.exists()) {
        File explodedDir = project.file(project.getBuildDir().getAbsolutePath() + "/" + FD_INTERMEDIATES + "/exploded-ap" + "/");
        ZipUtils.unzip(apBaseFile, explodedDir.getAbsolutePath());
        apContext.setApExploredFolder(explodedDir);
        apContext.setBaseApk(new File(explodedDir, "android.apk"));
    }
}
Also used : Project(org.gradle.api.Project) Configuration(org.gradle.api.artifacts.Configuration) Dependency(org.gradle.api.artifacts.Dependency) File(java.io.File) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 69 with Configuration

use of org.gradle.api.artifacts.Configuration in project atlas by alibaba.

the class TDependencyManager method collectArtifacts.

/**
     * Collects the resolved artifacts and returns a configuration which contains them. If the
     * configuration has unresolved dependencies we check that we have the latest version of the
     * Google repository and the Android Support repository and we install them if not. After this,
     * the resolution is retried with a fresh copy of the configuration, that will contain the newly
     * updated repositories. If this passes, we return the correct configuration and we fill the
     * artifacts map.
     *
     * @param configuration the configuration from which we get the artifacts
     * @param artifacts     the map of artifacts that are being collected
     * @return a valid configuration that has only resolved dependencies.
     */
private Configuration collectArtifacts(Configuration configuration, Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts) {
    Set<ResolvedArtifact> allArtifacts;
    // Make a copy because Gradle keeps a per configuration state of resolution that we
    // need to reset.
    Configuration configurationCopy = configuration.copyRecursive();
    Set<UnresolvedDependency> unresolvedDependencies = configuration.getResolvedConfiguration().getLenientConfiguration().getUnresolvedModuleDependencies();
    if (unresolvedDependencies.isEmpty()) {
        allArtifacts = configuration.getResolvedConfiguration().getResolvedArtifacts();
    } else {
        if (!repositoriesUpdated && sdkLibData.useSdkDownload()) {
            List<String> repositoryPaths = new ArrayList<>();
            for (UnresolvedDependency dependency : unresolvedDependencies) {
                if (isGoogleOwnedDependency(dependency.getSelector())) {
                    repositoryPaths.add(getRepositoryPath(dependency.getSelector()));
                }
            }
            sdkLibData.setNeedsCacheReset(sdkHandler.checkResetCache());
            List<File> updatedRepositories = sdkHandler.getSdkLoader().updateRepositories(repositoryPaths, sdkLibData, logger);
            // resolution result.
            for (File updatedRepository : updatedRepositories) {
                project.getRepositories().maven(newRepo -> {
                    newRepo.setName("Updated " + updatedRepository.getPath());
                    newRepo.setUrl(updatedRepository.toURI());
                    newRepo.artifactUrls(project.getRootProject().file("sdk-manager"));
                });
            }
            repositoriesUpdated = true;
        }
        if (extraModelInfo.getMode() != STANDARD) {
            allArtifacts = configurationCopy.getResolvedConfiguration().getLenientConfiguration().getArtifacts(Specs.satisfyAll());
        } else {
            allArtifacts = configurationCopy.getResolvedConfiguration().getResolvedArtifacts();
        }
        // Modify the configuration to the one that passed.
        configuration = configurationCopy;
    }
    for (ResolvedArtifact artifact : allArtifacts) {
        ModuleVersionIdentifier id = artifact.getModuleVersion().getId();
        List<ResolvedArtifact> moduleArtifacts = artifacts.get(id);
        if (moduleArtifacts == null) {
            moduleArtifacts = Lists.newArrayList();
            artifacts.put(id, moduleArtifacts);
        }
        if (!moduleArtifacts.contains(artifact)) {
            moduleArtifacts.add(artifact);
        }
    }
    return configuration;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) Configuration(org.gradle.api.artifacts.Configuration) UnresolvedDependency(org.gradle.api.artifacts.UnresolvedDependency) ArrayList(java.util.ArrayList) File(java.io.File)

Example 70 with Configuration

use of org.gradle.api.artifacts.Configuration in project atlas by alibaba.

the class TDependencyManager method addDependsOnTaskInOtherProjects.

/**
     * Adds a dependency on tasks with the specified name in other projects.  The other projects
     * are determined from project lib dependencies using the specified configuration name.
     * These may be projects this project depends on or projects that depend on this project
     * based on the useDependOn argument.
     *
     * @param task                 Task to add dependencies to
     * @param useDependedOn        if true, add tasks from projects this project depends on, otherwise
     *                             use projects that depend on this one.
     * @param otherProjectTaskName name of task in other projects
     * @param configurationName    name of configuration to use to find the other projects
     */
private static void addDependsOnTaskInOtherProjects(final Task task, boolean useDependedOn, String otherProjectTaskName, String configurationName) {
    Project project = task.getProject();
    final Configuration configuration = project.getConfigurations().getByName(configurationName);
    task.dependsOn(configuration.getTaskDependencyFromProjectDependency(useDependedOn, otherProjectTaskName));
}
Also used : Project(org.gradle.api.Project) AndroidProject(com.android.builder.model.AndroidProject) Configuration(org.gradle.api.artifacts.Configuration)

Aggregations

Configuration (org.gradle.api.artifacts.Configuration)85 Project (org.gradle.api.Project)11 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)11 File (java.io.File)10 Dependency (org.gradle.api.artifacts.Dependency)10 Callable (java.util.concurrent.Callable)9 ResolvedConfiguration (org.gradle.api.artifacts.ResolvedConfiguration)9 ResolvedProjectConfiguration (org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedProjectConfiguration)9 DependencySet (org.gradle.api.artifacts.DependencySet)8 DefaultLenientConfiguration (org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration)7 LinkedHashSet (java.util.LinkedHashSet)6 Usage (org.gradle.api.attributes.Usage)6 Action (org.gradle.api.Action)5 ConventionMapping (org.gradle.api.internal.ConventionMapping)5 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)4 IConventionAware (org.gradle.api.internal.IConventionAware)4 ArchivePublishArtifact (org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)4 DefaultUsageContext (org.gradle.language.cpp.internal.DefaultUsageContext)4 Set (java.util.Set)3 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)3