Search in sources :

Example 6 with Module

use of org.gradle.api.internal.artifacts.Module in project gradle by gradle.

the class IvyPublishPlugin method disableGradleMetadataGenerationIfCustomLayout.

private void disableGradleMetadataGenerationIfCustomLayout(NamedDomainObjectList<IvyArtifactRepository> repositories, GenerateModuleMetadata generateTask) {
    AtomicBoolean didWarn = new AtomicBoolean();
    Spec<? super Task> checkStandardLayout = task -> {
        boolean standard = repositories.stream().allMatch(this::hasStandardPattern);
        if (!standard && !didWarn.getAndSet(true)) {
            LOGGER.warn("Publication of Gradle Module Metadata is disabled because you have configured an Ivy repository with a non-standard layout");
        }
        return standard;
    };
    Spec<TaskInternal> spec = new AndSpec<TaskInternal>(generateTask.getOnlyIf(), checkStandardLayout);
    generateTask.setOnlyIf(Cast.<Spec<? super Task>>uncheckedCast(spec));
}
Also used : NamedDomainObjectFactory(org.gradle.api.NamedDomainObjectFactory) VersionMappingStrategyInternal(org.gradle.api.publish.internal.versionmapping.VersionMappingStrategyInternal) Path(org.gradle.model.Path) PluginManager(org.gradle.api.plugins.PluginManager) IvyArtifactNotationParserFactory(org.gradle.api.publish.ivy.internal.artifact.IvyArtifactNotationParserFactory) GenerateModuleMetadata(org.gradle.api.publish.tasks.GenerateModuleMetadata) NamedDomainObjectList(org.gradle.api.NamedDomainObjectList) Task(org.gradle.api.Task) PublishingExtension(org.gradle.api.publish.PublishingExtension) PublishingPlugin(org.gradle.api.publish.plugins.PublishingPlugin) IvyPublicationIdentity(org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity) TaskProvider(org.gradle.api.tasks.TaskProvider) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) Project(org.gradle.api.Project) Set(java.util.Set) NamedDomainObjectSet(org.gradle.api.NamedDomainObjectSet) GenerateIvyDescriptor(org.gradle.api.publish.ivy.tasks.GenerateIvyDescriptor) IvyPublication(org.gradle.api.publish.ivy.IvyPublication) List(java.util.List) Spec(org.gradle.api.specs.Spec) TaskContainer(org.gradle.api.tasks.TaskContainer) AndSpec(org.gradle.api.specs.AndSpec) IvyRepositoryDescriptor(org.gradle.api.internal.artifacts.repositories.descriptor.IvyRepositoryDescriptor) NotationParser(org.gradle.internal.typeconversion.NotationParser) PublishToIvyRepository(org.gradle.api.publish.ivy.tasks.PublishToIvyRepository) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultIvyPublicationIdentity(org.gradle.api.publish.ivy.internal.publication.DefaultIvyPublicationIdentity) Logger(org.gradle.api.logging.Logger) Module(org.gradle.api.internal.artifacts.Module) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) DefaultVersionMappingStrategy(org.gradle.api.publish.ivy.internal.versionmapping.DefaultVersionMappingStrategy) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) DefaultIvyPublication(org.gradle.api.publish.ivy.internal.publication.DefaultIvyPublication) StringUtils.capitalize(org.apache.commons.lang.StringUtils.capitalize) Usage(org.gradle.api.attributes.Usage) TaskInternal(org.gradle.api.internal.TaskInternal) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin) Cast(org.gradle.internal.Cast) RepositoryDescriptor(org.gradle.api.internal.artifacts.repositories.descriptor.RepositoryDescriptor) Instantiator(org.gradle.internal.reflect.Instantiator) IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) FileResolver(org.gradle.api.internal.file.FileResolver) ObjectFactory(org.gradle.api.model.ObjectFactory) Logging(org.gradle.api.logging.Logging) DefaultIvyArtifactRepository(org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository) DependencyMetaDataProvider(org.gradle.api.internal.artifacts.configurations.DependencyMetaDataProvider) Plugin(org.gradle.api.Plugin) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository) AndSpec(org.gradle.api.specs.AndSpec) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TaskInternal(org.gradle.api.internal.TaskInternal)

Example 7 with Module

use of org.gradle.api.internal.artifacts.Module in project gradle by gradle.

the class Upload method upload.

@TaskAction
protected void upload() {
    getLogger().info("Publishing configuration: {}", configuration);
    DeprecationLogger.deprecateTaskType(Upload.class, getPath()).willBeRemovedInGradle8().withUpgradeGuideSection(7, "upload_task_deprecation").nagUser();
    Module module = ((ConfigurationInternal) configuration).getModule();
    ArtifactPublisher artifactPublisher = getPublicationServices().createArtifactPublisher();
    File descriptorDestination = isUploadDescriptor() ? getDescriptorDestination() : null;
    List<PublicationAwareRepository> publishRepositories = collect(getRepositories(), Transformers.cast(PublicationAwareRepository.class));
    try {
        artifactPublisher.publish(publishRepositories, module, configuration, descriptorDestination);
    } catch (Exception e) {
        throw new PublishException(String.format("Could not publish configuration '%s'", configuration.getName()), e);
    }
}
Also used : ArtifactPublisher(org.gradle.api.internal.artifacts.ArtifactPublisher) PublicationAwareRepository(org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository) PublishException(org.gradle.api.artifacts.PublishException) Module(org.gradle.api.internal.artifacts.Module) File(java.io.File) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) PublishException(org.gradle.api.artifacts.PublishException)

Example 8 with Module

use of org.gradle.api.internal.artifacts.Module in project gradle by gradle.

the class ShortCircuitEmptyConfigurationResolver method emptyGraph.

private void emptyGraph(ConfigurationInternal configuration, ResolverResults results, boolean verifyLocking) {
    if (verifyLocking && configuration.getResolutionStrategy().isDependencyLockingEnabled()) {
        DependencyLockingProvider dependencyLockingProvider = configuration.getResolutionStrategy().getDependencyLockingProvider();
        DependencyLockingState lockingState = dependencyLockingProvider.loadLockState(configuration.getName());
        if (lockingState.mustValidateLockState() && !lockingState.getLockedDependencies().isEmpty()) {
            // Invalid lock state, need to do a real resolution to gather locking failures
            delegate.resolveGraph(configuration, results);
            return;
        }
        dependencyLockingProvider.persistResolvedDependencies(configuration.getName(), Collections.emptySet(), Collections.emptySet());
    }
    Module module = configuration.getModule();
    ModuleVersionIdentifier id = moduleIdentifierFactory.moduleWithVersion(module);
    ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
    ResolutionResult emptyResult = DefaultResolutionResultBuilder.empty(id, componentIdentifier, configuration.getAttributes());
    ResolvedLocalComponentsResult emptyProjectResult = new ResolvedLocalComponentsResultGraphVisitor(thisBuild);
    results.graphResolved(emptyResult, emptyProjectResult, EmptyResults.INSTANCE);
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DependencyLockingProvider(org.gradle.api.internal.artifacts.dsl.dependencies.DependencyLockingProvider) DependencyLockingState(org.gradle.api.internal.artifacts.dsl.dependencies.DependencyLockingState) ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) Module(org.gradle.api.internal.artifacts.Module) ResolvedLocalComponentsResult(org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedLocalComponentsResult) ResolvedLocalComponentsResultGraphVisitor(org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedLocalComponentsResultGraphVisitor)

Example 9 with Module

use of org.gradle.api.internal.artifacts.Module in project gradle by gradle.

the class DefaultProjectLocalComponentProvider method getLocalComponentMetadata.

private LocalComponentMetadata getLocalComponentMetadata(ProjectState projectState, ProjectInternal project) {
    Module module = project.getDependencyMetaDataProvider().getModule();
    ModuleVersionIdentifier moduleVersionIdentifier = moduleIdentifierFactory.moduleWithVersion(module.getGroup(), module.getName(), module.getVersion());
    ProjectComponentIdentifier componentIdentifier = projectState.getComponentIdentifier();
    DefaultLocalComponentMetadata metaData = new DefaultLocalComponentMetadata(moduleVersionIdentifier, componentIdentifier, module.getStatus(), (AttributesSchemaInternal) project.getDependencies().getAttributesSchema());
    for (ConfigurationInternal configuration : project.getConfigurations().withType(ConfigurationInternal.class)) {
        metadataBuilder.addConfiguration(metaData, configuration);
    }
    return metaData;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) Module(org.gradle.api.internal.artifacts.Module) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)

Aggregations

Module (org.gradle.api.internal.artifacts.Module)9 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)5 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)5 DefaultLocalComponentMetadata (org.gradle.internal.component.local.model.DefaultLocalComponentMetadata)4 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)3 ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)3 ResolutionResult (org.gradle.api.artifacts.result.ResolutionResult)2 ResolvedLocalComponentsResult (org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedLocalComponentsResult)2 ResolvedLocalComponentsResultGraphVisitor (org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedLocalComponentsResultGraphVisitor)2 File (java.io.File)1 List (java.util.List)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Inject (javax.inject.Inject)1 StringUtils.capitalize (org.apache.commons.lang.StringUtils.capitalize)1 NamedDomainObjectFactory (org.gradle.api.NamedDomainObjectFactory)1 NamedDomainObjectList (org.gradle.api.NamedDomainObjectList)1 NamedDomainObjectSet (org.gradle.api.NamedDomainObjectSet)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1