Search in sources :

Example 51 with InvalidUserDataException

use of org.gradle.api.InvalidUserDataException in project gradle by gradle.

the class PublishToMavenRepository method computeSpec.

private PublishSpec computeSpec() {
    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }
    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }
    getDuplicatePublicationTracker().checkCanPublish(publicationInternal, repository.getUrl(), repository.getName());
    MavenNormalizedPublication normalizedPublication = publicationInternal.asNormalisedPublication();
    return new PublishSpec(RepositorySpec.of(repository), normalizedPublication);
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) MavenNormalizedPublication(org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication)

Example 52 with InvalidUserDataException

use of org.gradle.api.InvalidUserDataException in project gradle by gradle.

the class DefaultFlatDirArtifactRepository method createRealResolver.

private IvyResolver createRealResolver() {
    Set<File> dirs = getDirs();
    if (dirs.isEmpty()) {
        throw new InvalidUserDataException("You must specify at least one directory for a flat directory repository.");
    }
    RepositoryTransport transport = transportFactory.createFileTransport(getName());
    Instantiator injector = createInjectorForMetadataSuppliers(transport, instantiatorFactory, null, null);
    IvyResolver resolver = new IvyResolver(getName(), transport, locallyAvailableResourceFinder, false, artifactFileStore, null, null, createMetadataSources(), IvyMetadataArtifactProvider.INSTANCE, injector, checksumService);
    for (File root : dirs) {
        resolver.addArtifactLocation(root.toURI(), "/[artifact]-[revision](-[classifier]).[ext]");
        resolver.addArtifactLocation(root.toURI(), "/[artifact](-[classifier]).[ext]");
    }
    return resolver;
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) IvyResolver(org.gradle.api.internal.artifacts.repositories.resolver.IvyResolver) Instantiator(org.gradle.internal.reflect.Instantiator) RepositoryTransport(org.gradle.api.internal.artifacts.repositories.transport.RepositoryTransport) File(java.io.File)

Example 53 with InvalidUserDataException

use of org.gradle.api.InvalidUserDataException in project gradle by gradle.

the class RealisedIvyModuleResolveMetadata method addVariantsFromRules.

private static void addVariantsFromRules(DefaultIvyModuleResolveMetadata componentMetadata, Map<String, ConfigurationMetadata> declaredConfigurations, VariantMetadataRules variantMetadataRules) {
    List<AdditionalVariant> additionalVariants = variantMetadataRules.getAdditionalVariants();
    if (additionalVariants.isEmpty()) {
        return;
    }
    for (AdditionalVariant additionalVariant : additionalVariants) {
        String name = additionalVariant.getName();
        String baseName = additionalVariant.getBase();
        ImmutableAttributes attributes;
        ImmutableCapabilities capabilities;
        List<ModuleDependencyMetadata> dependencies;
        ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts;
        ImmutableList<ExcludeMetadata> excludes;
        ModuleConfigurationMetadata baseConf = (ModuleConfigurationMetadata) declaredConfigurations.get(baseName);
        if (baseConf == null) {
            attributes = componentMetadata.getAttributes();
            capabilities = ImmutableCapabilities.EMPTY;
            dependencies = ImmutableList.of();
            artifacts = ImmutableList.of();
            excludes = ImmutableList.of();
        } else {
            attributes = baseConf.getAttributes();
            capabilities = (ImmutableCapabilities) baseConf.getCapabilities();
            dependencies = Cast.uncheckedCast(baseConf.getDependencies());
            artifacts = Cast.uncheckedCast(baseConf.getArtifacts());
            excludes = Cast.uncheckedCast(baseConf.getExcludes());
        }
        if (baseName == null || baseConf != null) {
            declaredConfigurations.put(name, applyRules(componentMetadata.getId(), name, variantMetadataRules, attributes, capabilities, artifacts, excludes, true, true, ImmutableSet.of(), null, dependencies, true, false));
        } else if (!additionalVariant.isLenient()) {
            throw new InvalidUserDataException("Configuration '" + baseName + "' not defined in module " + componentMetadata.getId().getDisplayName());
        }
    }
}
Also used : AdditionalVariant(org.gradle.internal.component.external.model.AdditionalVariant) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ImmutableCapabilities(org.gradle.internal.component.external.model.ImmutableCapabilities) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 54 with InvalidUserDataException

use of org.gradle.api.InvalidUserDataException in project gradle by gradle.

the class RealisedMavenModuleResolveMetadata method addVariantsFromRules.

private static List<ConfigurationMetadata> addVariantsFromRules(ModuleComponentResolveMetadata componentMetadata, ImmutableList<ConfigurationMetadata> derivedVariants, VariantMetadataRules variantMetadataRules) {
    List<AdditionalVariant> additionalVariants = variantMetadataRules.getAdditionalVariants();
    if (additionalVariants.isEmpty()) {
        return derivedVariants;
    }
    ImmutableList.Builder<ConfigurationMetadata> builder = new ImmutableList.Builder<>();
    builder.addAll(derivedVariants);
    Map<String, ConfigurationMetadata> variantsByName = derivedVariants.stream().collect(Collectors.toMap(ConfigurationMetadata::getName, Function.identity()));
    for (AdditionalVariant additionalVariant : additionalVariants) {
        String name = additionalVariant.getName();
        String baseName = additionalVariant.getBase();
        ImmutableAttributes attributes;
        ImmutableCapabilities capabilities;
        List<? extends ModuleDependencyMetadata> dependencies;
        ImmutableList<? extends ModuleComponentArtifactMetadata> artifacts;
        ConfigurationMetadata baseConf = variantsByName.get(baseName);
        if (baseConf == null) {
            attributes = componentMetadata.getAttributes();
            capabilities = ImmutableCapabilities.EMPTY;
            dependencies = ImmutableList.of();
            artifacts = ImmutableList.of();
        } else {
            attributes = baseConf.getAttributes();
            capabilities = (ImmutableCapabilities) baseConf.getCapabilities();
            dependencies = ((ModuleConfigurationMetadata) baseConf).getDependencies();
            artifacts = Cast.uncheckedCast(baseConf.getArtifacts());
        }
        if (baseName == null || baseConf != null) {
            builder.add(applyRules(componentMetadata.getId(), name, variantMetadataRules, attributes, capabilities, dependencies, artifacts, true, true, ImmutableSet.of(), true, false));
        } else if (!additionalVariant.isLenient()) {
            throw new InvalidUserDataException("Variant '" + baseName + "' not defined in module " + componentMetadata.getId().getDisplayName());
        }
    }
    return builder.build();
}
Also used : AdditionalVariant(org.gradle.internal.component.external.model.AdditionalVariant) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ImmutableCapabilities(org.gradle.internal.component.external.model.ImmutableCapabilities) ImmutableList(com.google.common.collect.ImmutableList) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) InvalidUserDataException(org.gradle.api.InvalidUserDataException)

Example 55 with InvalidUserDataException

use of org.gradle.api.InvalidUserDataException in project gradle by gradle.

the class ConfigurationFinder method find.

public static Configuration find(ConfigurationContainer configurations, String configurationName) {
    NameMatcher matcher = new NameMatcher();
    Configuration configuration = matcher.find(configurationName, configurations.getAsMap());
    if (configuration != null) {
        return configuration;
    }
    // if configuration with exact name is present return it
    configuration = configurations.findByName(configurationName);
    if (configuration != null) {
        return configuration;
    }
    throw new InvalidUserDataException(matcher.formatErrorMessage("configuration", configurations));
}
Also used : NameMatcher(org.gradle.util.internal.NameMatcher) Configuration(org.gradle.api.artifacts.Configuration) InvalidUserDataException(org.gradle.api.InvalidUserDataException)

Aggregations

InvalidUserDataException (org.gradle.api.InvalidUserDataException)61 File (java.io.File)18 Task (org.gradle.api.Task)6 ArrayList (java.util.ArrayList)5 LinkedHashSet (java.util.LinkedHashSet)5 Action (org.gradle.api.Action)5 TaskAction (org.gradle.api.tasks.TaskAction)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 DefaultTask (org.gradle.api.DefaultTask)4 ImmutableList (com.google.common.collect.ImmutableList)3 Closure (groovy.lang.Closure)3 Map (java.util.Map)3 MavenArtifactRepository (org.gradle.api.artifacts.repositories.MavenArtifactRepository)3 TaskInternal (org.gradle.api.internal.TaskInternal)3 MavenPublicationInternal (org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal)3 DirectorySensitivity (org.gradle.internal.fingerprint.DirectorySensitivity)3 LineEndingSensitivity (org.gradle.internal.fingerprint.LineEndingSensitivity)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Nullable (javax.annotation.Nullable)2