Search in sources :

Example 36 with Dependency

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

the class PlayRunAdapterV23X method getRunsupportClasspathDependencies.

@Override
public Iterable<Dependency> getRunsupportClasspathDependencies(String playVersion, String scalaCompatibilityVersion) {
    ImmutableList.Builder<Dependency> listBuilder = ImmutableList.builder();
    String runsupportPlayVersion = playVersion;
    boolean transitive = true;
    // use run-support from 2.3.7 for versions before Play 2.3.7
    if (VersionNumber.parse(playVersion).compareTo(MINIMUM_PLAY_VERSION_WITH_RUN_SUPPORT) < 0) {
        runsupportPlayVersion = "2.3.7";
        transitive = false;
    }
    DefaultExternalModuleDependency runSupportDependency = new DefaultExternalModuleDependency("com.typesafe.play", RUN_SUPPORT_PLAY_MODULE + "_" + scalaCompatibilityVersion, runsupportPlayVersion);
    runSupportDependency.setTransitive(transitive);
    listBuilder.add(runSupportDependency);
    String name = scalaCompatibilityVersion.equals("2.10") ? "io" : ("io_" + scalaCompatibilityVersion);
    DefaultExternalModuleDependency dependency = new DefaultExternalModuleDependency("org.scala-sbt", name, getIOSupportDependencyVersion(), "runtime");
    dependency.setTransitive(false);
    listBuilder.add(dependency);
    return listBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Dependency(org.gradle.api.artifacts.Dependency)

Example 37 with Dependency

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

the class JsHintPlugin method addConfiguration.

public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final JsHintExtension extension) {
    Configuration configuration = configurations.create(JsHintExtension.CONFIGURATION_NAME);
    configuration.defaultDependencies(new Action<DependencySet>() {

        @Override
        public void execute(DependencySet configDependencies) {
            String notation = JsHintExtension.DEFAULT_DEPENDENCY_GROUP + ":" + JsHintExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js";
            Dependency dependency = dependencies.create(notation);
            configDependencies.add(dependency);
        }
    });
    return configuration;
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) DependencySet(org.gradle.api.artifacts.DependencySet) Dependency(org.gradle.api.artifacts.Dependency)

Example 38 with Dependency

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

the class EnvJsPlugin method addConfiguration.

public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final EnvJsExtension extension) {
    Configuration configuration = configurations.create(EnvJsExtension.CONFIGURATION_NAME);
    configuration.defaultDependencies(new Action<DependencySet>() {

        @Override
        public void execute(DependencySet configDependencies) {
            String notation = EnvJsExtension.DEFAULT_DEPENDENCY_GROUP + ":" + EnvJsExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js";
            Dependency dependency = dependencies.create(notation);
            configDependencies.add(dependency);
        }
    });
    return configuration;
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) DependencySet(org.gradle.api.artifacts.DependencySet) Dependency(org.gradle.api.artifacts.Dependency)

Example 39 with Dependency

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

the class DefaultIdeDependencyResolver method getIdeLocalFileDependencies.

/**
     * Gets IDE local file dependencies.
     *
     * @param configuration Configuration
     * @return IDE local file dependencies
     */
public List<IdeLocalFileDependency> getIdeLocalFileDependencies(Configuration configuration) {
    List<SelfResolvingDependency> externalDependencies = new ArrayList<SelfResolvingDependency>();
    findAllExternalDependencies(externalDependencies, new ArrayList<Dependency>(), configuration);
    List<IdeLocalFileDependency> ideLocalFileDependencies = new ArrayList<IdeLocalFileDependency>();
    for (SelfResolvingDependency externalDependency : externalDependencies) {
        Set<File> resolvedFiles = externalDependency.resolve(configuration.isTransitive());
        for (File resolvedFile : resolvedFiles) {
            IdeLocalFileDependency ideLocalFileDependency = new IdeLocalFileDependency(resolvedFile);
            ideLocalFileDependencies.add(ideLocalFileDependency);
        }
    }
    return ideLocalFileDependencies;
}
Also used : IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) SelfResolvingDependency(org.gradle.api.artifacts.SelfResolvingDependency) ArrayList(java.util.ArrayList) UnresolvedIdeRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.UnresolvedIdeRepoFileDependency) SelfResolvingDependency(org.gradle.api.artifacts.SelfResolvingDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) IdeProjectDependency(org.gradle.plugins.ide.internal.resolver.model.IdeProjectDependency) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency) Dependency(org.gradle.api.artifacts.Dependency) File(java.io.File)

Example 40 with Dependency

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

the class DefaultConfiguration method createCopy.

private DefaultConfiguration createCopy(Set<Dependency> dependencies, Set<DependencyConstraint> dependencyConstraints, boolean recursive) {
    DetachedConfigurationsProvider configurationsProvider = new DetachedConfigurationsProvider();
    RootComponentMetadataBuilder rootComponentMetadataBuilder = this.rootComponentMetadataBuilder.withConfigurationsProvider(configurationsProvider);
    String newName = name + "Copy";
    Factory<ResolutionStrategyInternal> childResolutionStrategy = resolutionStrategy != null ? Factories.constant(resolutionStrategy.copy()) : resolutionStrategyFactory;
    DefaultConfiguration copiedConfiguration = instantiator.newInstance(DefaultConfiguration.class, domainObjectContext, newName, configurationsProvider, resolver, listenerManager, metaDataProvider, childResolutionStrategy, projectAccessListener, projectFinder, fileCollectionFactory, buildOperationExecutor, instantiator, artifactNotationParser, capabilityNotationParser, attributesFactory, rootComponentMetadataBuilder);
    configurationsProvider.setTheOnlyConfiguration(copiedConfiguration);
    // state, cachedResolvedConfiguration, and extendsFrom intentionally not copied - must re-resolve copy
    // copying extendsFrom could mess up dependencies when copy was re-resolved
    copiedConfiguration.visible = visible;
    copiedConfiguration.transitive = transitive;
    copiedConfiguration.description = description;
    copiedConfiguration.defaultDependencyActions = defaultDependencyActions;
    copiedConfiguration.dependencyResolutionListeners = dependencyResolutionListeners;
    copiedConfiguration.canBeConsumed = canBeConsumed;
    copiedConfiguration.canBeResolved = canBeResolved;
    copiedConfiguration.getArtifacts().addAll(getAllArtifacts());
    if (!configurationAttributes.isEmpty()) {
        for (Attribute<?> attribute : configurationAttributes.keySet()) {
            Object value = configurationAttributes.getAttribute(attribute);
            copiedConfiguration.getAttributes().attribute(Cast.<Attribute<Object>>uncheckedCast(attribute), value);
        }
    }
    // todo An ExcludeRule is a value object but we don't enforce immutability for DefaultExcludeRule as strong as we
    // should (we expose the Map). We should provide a better API for ExcludeRule (I don't want to use unmodifiable Map).
    // As soon as DefaultExcludeRule is truly immutable, we don't need to create a new instance of DefaultExcludeRule.
    Set<Configuration> excludeRuleSources = new LinkedHashSet<Configuration>();
    excludeRuleSources.add(this);
    if (recursive) {
        excludeRuleSources.addAll(getHierarchy());
    }
    for (Configuration excludeRuleSource : excludeRuleSources) {
        for (ExcludeRule excludeRule : excludeRuleSource.getExcludeRules()) {
            copiedConfiguration.excludeRules.add(new DefaultExcludeRule(excludeRule.getGroup(), excludeRule.getModule()));
        }
    }
    DomainObjectSet<Dependency> copiedDependencies = copiedConfiguration.getDependencies();
    for (Dependency dependency : dependencies) {
        copiedDependencies.add(dependency.copy());
    }
    DomainObjectSet<DependencyConstraint> copiedDependencyConstraints = copiedConfiguration.getDependencyConstraints();
    for (DependencyConstraint dependencyConstraint : dependencyConstraints) {
        copiedDependencyConstraints.add(((DefaultDependencyConstraint) dependencyConstraint).copy());
    }
    return copiedConfiguration;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ResolvedConfiguration(org.gradle.api.artifacts.ResolvedConfiguration) ResolvedProjectConfiguration(org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedProjectConfiguration) DefaultLenientConfiguration(org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration) Configuration(org.gradle.api.artifacts.Configuration) DefaultDependencyConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultDependencyConstraint) DependencyConstraint(org.gradle.api.artifacts.DependencyConstraint) Dependency(org.gradle.api.artifacts.Dependency) TaskDependency(org.gradle.api.tasks.TaskDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AbstractTaskDependency(org.gradle.api.internal.tasks.AbstractTaskDependency) ExcludeRule(org.gradle.api.artifacts.ExcludeRule) DefaultExcludeRule(org.gradle.api.internal.artifacts.DefaultExcludeRule) DefaultExcludeRule(org.gradle.api.internal.artifacts.DefaultExcludeRule) RootComponentMetadataBuilder(org.gradle.api.internal.artifacts.ivyservice.moduleconverter.RootComponentMetadataBuilder)

Aggregations

Dependency (org.gradle.api.artifacts.Dependency)58 Configuration (org.gradle.api.artifacts.Configuration)20 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)16 File (java.io.File)13 Project (org.gradle.api.Project)13 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)12 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)8 MinimalExternalModuleDependency (org.gradle.api.artifacts.MinimalExternalModuleDependency)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)6 Collectors (java.util.stream.Collectors)5 Inject (javax.inject.Inject)5 DependencySet (org.gradle.api.artifacts.DependencySet)5 ObjectFactory (org.gradle.api.model.ObjectFactory)5 TaskDependency (org.gradle.api.tasks.TaskDependency)5 EtaDependency (com.typelead.gradle.eta.api.EtaDependency)4 EtaProjectDependency (com.typelead.gradle.eta.api.EtaProjectDependency)4 Map (java.util.Map)4 Provider (org.gradle.api.provider.Provider)4