Search in sources :

Example 11 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultArtifactResolutionQuery method execute.

@Override
public ArtifactResolutionResult execute() {
    if (componentType == null) {
        throw new IllegalStateException("Must specify component type and artifacts to query.");
    }
    List<? extends ResolutionAwareRepository> repositories = repositoriesSupplier.get();
    ConfigurationInternal detachedConfiguration = configurationContainer.detachedConfiguration();
    ResolutionStrategyInternal resolutionStrategy = detachedConfiguration.getResolutionStrategy();
    ComponentResolvers componentResolvers = ivyFactory.create(detachedConfiguration.getName(), resolutionStrategy, repositories, metadataHandler.getComponentMetadataProcessorFactory(), ImmutableAttributes.EMPTY, null, attributesFactory, componentMetadataSupplierRuleExecutor);
    ComponentMetaDataResolver componentMetaDataResolver = componentResolvers.getComponentResolver();
    ArtifactResolver artifactResolver = new ErrorHandlingArtifactResolver(componentResolvers.getArtifactResolver());
    return createResult(componentMetaDataResolver, artifactResolver);
}
Also used : ComponentMetaDataResolver(org.gradle.internal.resolve.resolver.ComponentMetaDataResolver) ErrorHandlingArtifactResolver(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingArtifactResolver) ComponentResolvers(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentResolvers) ResolutionStrategyInternal(org.gradle.api.internal.artifacts.configurations.ResolutionStrategyInternal) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ArtifactResolver(org.gradle.internal.resolve.resolver.ArtifactResolver) ErrorHandlingArtifactResolver(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingArtifactResolver)

Example 12 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultArtifactPublisher method publish.

@Override
public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final Module module, final Configuration configuration, final File descriptor) throws PublishException {
    Set<ConfigurationInternal> allConfigurations = Cast.uncheckedCast(configuration.getAll());
    Set<ConfigurationInternal> configurationsToPublish = Cast.uncheckedCast(configuration.getHierarchy());
    // Will create `ivy.xml` even for Maven publishing! (as long as `Upload.uploadDescriptor == true`)
    if (descriptor != null) {
        // Convert once, in order to write the Ivy descriptor with _all_ configurations
        DefaultIvyModulePublishMetadata publishMetaData = toPublishMetaData(module, allConfigurations, false);
        ivyModuleDescriptorWriter.write(publishMetaData, descriptor);
    }
    // Convert a second time with only the published configurations: this ensures that the correct artifacts are included
    DefaultIvyModulePublishMetadata publishMetaData = toPublishMetaData(module, configurationsToPublish, true);
    if (descriptor != null) {
        IvyArtifactName artifact = new DefaultIvyArtifactName("ivy", "ivy", "xml");
        publishMetaData.addArtifact(artifact, descriptor);
    }
    for (PublicationAwareRepository repository : repositories) {
        ModuleVersionPublisher publisher = repository.createPublisher();
        LOGGER.info("Publishing to {}", publisher);
        publisher.publish(publishMetaData);
    }
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) PublicationAwareRepository(org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 13 with ConfigurationInternal

use of org.gradle.api.internal.artifacts.configurations.ConfigurationInternal in project gradle by gradle.

the class DefaultArtifactPublisher method addConfigurations.

private void addConfigurations(DefaultIvyModulePublishMetadata metaData, Collection<? extends ConfigurationInternal> configurations, boolean validateArtifacts) {
    for (ConfigurationInternal configuration : configurations) {
        BuildableLocalConfigurationMetadata configurationMetadata = addConfiguration(metaData, configuration);
        dependenciesConverter.addDependenciesAndExcludes(configurationMetadata, configuration);
        OutgoingVariant outgoingVariant = configuration.convertToOutgoingVariant();
        for (PublishArtifact publishArtifact : outgoingVariant.getArtifacts()) {
            if (!validateArtifacts || isValidToPublish(publishArtifact)) {
                metaData.addArtifact(configuration.getName(), publishArtifact);
            }
        }
    }
}
Also used : OutgoingVariant(org.gradle.api.internal.artifacts.configurations.OutgoingVariant) BuildableLocalConfigurationMetadata(org.gradle.internal.component.local.model.BuildableLocalConfigurationMetadata) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Aggregations

ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)13 File (java.io.File)3 PublicationAwareRepository (org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository)3 Configuration (org.gradle.api.artifacts.Configuration)2 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)2 Module (org.gradle.api.internal.artifacts.Module)2 ModuleVersionPublisher (org.gradle.api.internal.artifacts.ModuleVersionPublisher)2 OutgoingVariant (org.gradle.api.internal.artifacts.configurations.OutgoingVariant)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 BiFunction (java.util.function.BiFunction)1 Inject (javax.inject.Inject)1 InvokerHelper (org.codehaus.groovy.runtime.InvokerHelper)1 Action (org.gradle.api.Action)1