Search in sources :

Example 46 with InvalidUserDataException

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

the class DependenciesAwareVersionCatalogBuilder method copyDependencyVersion.

private static void copyDependencyVersion(Dependency dependency, String group, String name, MutableVersionConstraint v) {
    if (dependency instanceof ExternalModuleDependency) {
        VersionConstraint vc = ((ExternalModuleDependency) dependency).getVersionConstraint();
        copyConstraint(vc, v);
    } else {
        String version = dependency.getVersion();
        if (version == null || version.isEmpty()) {
            throw new InvalidUserDataException("Version for dependency " + group + ":" + name + " must not be empty");
        }
        v.require(version);
    }
}
Also used : ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) MutableVersionConstraint(org.gradle.api.artifacts.MutableVersionConstraint) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency)

Example 47 with InvalidUserDataException

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

the class PublishToIvyRepository method publish.

@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }
    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }
    getDuplicatePublicationTracker().checkCanPublish(publicationInternal, repository.getUrl(), repository.getName());
    doPublish(publicationInternal, repository);
}
Also used : IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) InvalidUserDataException(org.gradle.api.InvalidUserDataException) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository) TaskAction(org.gradle.api.tasks.TaskAction)

Example 48 with InvalidUserDataException

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

the class SigningExtension method addSignatureSpecConventions.

/**
 * Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec.
 */
protected void addSignatureSpecConventions(SignatureSpec spec) {
    if (!(spec instanceof IConventionAware)) {
        throw new InvalidUserDataException("Cannot add conventions to signature spec \'" + String.valueOf(spec) + "\' as it is not convention aware");
    }
    ConventionMapping conventionMapping = ((IConventionAware) spec).getConventionMapping();
    conventionMapping.map("signatory", new Callable<Signatory>() {

        @Override
        public Signatory call() {
            return getSignatory();
        }
    });
    conventionMapping.map("signatureType", new Callable<SignatureType>() {

        @Override
        public SignatureType call() {
            return getSignatureType();
        }
    });
    conventionMapping.map("required", new Callable<Boolean>() {

        @Override
        public Boolean call() {
            return isRequired();
        }
    });
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) Signatory(org.gradle.plugins.signing.signatory.Signatory) SignatureType(org.gradle.plugins.signing.type.SignatureType) DefaultTypeTransformation.castToBoolean(org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToBoolean) IConventionAware(org.gradle.api.internal.IConventionAware) ConventionMapping(org.gradle.api.internal.ConventionMapping)

Example 49 with InvalidUserDataException

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

the class CgenTask method getDestDirFile.

@OutputDirectory
protected File getDestDirFile() {
    final Reference<File> javaSourceDir = new Reference<>(null);
    if (destDir != null) {
        javaSourceDir.set(destDir);
    } else if (destDirName != null) {
        javaSourceDir.set(getProject().file(destDirName));
    } else {
        getProject().getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {

            @Override
            public void execute(final JavaPlugin plugin) {
                SourceSetContainer sourceSets = (SourceSetContainer) getProject().getProperties().get("sourceSets");
                Set<File> sourceDirs = sourceSets.getByName("main").getJava().getSrcDirs();
                if (sourceDirs != null && !sourceDirs.isEmpty()) {
                    // find java directory, if there is no such dir, take first
                    for (File dir : sourceDirs) {
                        if (dir.getName().endsWith("java")) {
                            javaSourceDir.set(dir);
                            break;
                        }
                    }
                    if (javaSourceDir.get() == null) {
                        javaSourceDir.set(sourceDirs.iterator().next());
                    }
                }
            }
        });
    }
    if (javaSourceDir.get() == null) {
        throw new InvalidUserDataException("cgen.destDir is not set and there is no Java source sets found.");
    }
    if (!javaSourceDir.get().exists()) {
        javaSourceDir.get().mkdirs();
    }
    return javaSourceDir.get();
}
Also used : Action(org.gradle.api.Action) ClientClassGenerationAction(org.apache.cayenne.gen.ClientClassGenerationAction) ClassGenerationAction(org.apache.cayenne.gen.ClassGenerationAction) Reference(groovy.lang.Reference) InvalidUserDataException(org.gradle.api.InvalidUserDataException) JavaPlugin(org.gradle.api.plugins.JavaPlugin) File(java.io.File)

Example 50 with InvalidUserDataException

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

the class AnnotationProcessorDiscoveringCompiler method getEffectiveAnnotationProcessors.

/**
 * Scans the processor path for processor declarations. Filters them if the explicit <code>-processor</code> argument is given.
 * Treats explicit processors that didn't have a matching declaration on the path as non-incremental.
 */
private Set<AnnotationProcessorDeclaration> getEffectiveAnnotationProcessors(JavaCompileSpec spec) {
    Map<String, AnnotationProcessorDeclaration> declarations = annotationProcessorDetector.detectProcessors(spec.getAnnotationProcessorPath());
    List<String> compilerArgs = spec.getCompileOptions().getCompilerArgs();
    int processorIndex = compilerArgs.lastIndexOf("-processor");
    if (processorIndex == -1) {
        return Sets.newLinkedHashSet(declarations.values());
    }
    if (processorIndex == compilerArgs.size() - 1) {
        throw new InvalidUserDataException("No processor specified for compiler argument -processor in requested compiler args: " + Joiner.on(" ").join(compilerArgs));
    }
    Collection<String> explicitProcessors = Splitter.on(',').splitToList(compilerArgs.get(processorIndex + 1));
    Set<AnnotationProcessorDeclaration> effectiveProcessors = Sets.newLinkedHashSet();
    for (String explicitProcessor : explicitProcessors) {
        AnnotationProcessorDeclaration declaration = declarations.get(explicitProcessor);
        if (declaration != null) {
            effectiveProcessors.add(declaration);
        } else {
            effectiveProcessors.add(new AnnotationProcessorDeclaration(explicitProcessor, IncrementalAnnotationProcessorType.UNKNOWN));
        }
    }
    return effectiveProcessors;
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) AnnotationProcessorDeclaration(org.gradle.api.internal.tasks.compile.processing.AnnotationProcessorDeclaration)

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