Search in sources :

Example 11 with InvalidUserCodeException

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

the class DefaultComponentMetadataHandler method createModuleSpecConfigurableRule.

private SpecConfigurableRule createModuleSpecConfigurableRule(Object id, ConfigurableRule<ComponentMetadataContext> instantiatingAction) {
    ModuleIdentifier moduleIdentifier;
    try {
        moduleIdentifier = moduleIdentifierNotationParser.parseNotation(id);
    } catch (UnsupportedNotationException e) {
        throw new InvalidUserCodeException(String.format(INVALID_SPEC_ERROR, id == null ? "null" : id.toString()), e);
    }
    Spec<ModuleVersionIdentifier> spec = new ModuleVersionIdentifierSpec(moduleIdentifier);
    return new SpecConfigurableRule(instantiatingAction, spec);
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) UnsupportedNotationException(org.gradle.internal.typeconversion.UnsupportedNotationException) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 12 with InvalidUserCodeException

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

the class DefaultDependencyResolutionManagement method ruleMutationDisallowedOnProject.

private void ruleMutationDisallowedOnProject(DisplayName ruleName) {
    UserCodeApplicationContext.Application current = context.current();
    DisplayName displayName = current == null ? null : current.getDisplayName();
    if (displayName == null) {
        displayName = UNKNOWN_CODE;
    }
    String message = "Build was configured to prefer settings component metadata rules over project rules but rule '" + ruleName + "' was added by " + displayName;
    switch(getConfiguredRulesMode()) {
        case FAIL_ON_PROJECT_RULES:
            throw new InvalidUserCodeException(message);
        case PREFER_SETTINGS:
            LOGGER.warn(message);
            break;
    }
}
Also used : InvalidUserCodeException(org.gradle.api.InvalidUserCodeException) UserCodeApplicationContext(org.gradle.configuration.internal.UserCodeApplicationContext) DisplayName(org.gradle.internal.DisplayName)

Aggregations

InvalidUserCodeException (org.gradle.api.InvalidUserCodeException)12 UnsupportedNotationException (org.gradle.internal.typeconversion.UnsupportedNotationException)4 Action (org.gradle.api.Action)3 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)3 File (java.io.File)2 Task (org.gradle.api.Task)2 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)2 VariantVersionMappingStrategy (org.gradle.api.publish.VariantVersionMappingStrategy)2 AttributeMatcher (org.gradle.internal.component.model.AttributeMatcher)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Map (java.util.Map)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 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 Transformer (org.gradle.api.Transformer)1 ArtifactView (org.gradle.api.artifacts.ArtifactView)1