Search in sources :

Example 71 with GradleException

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

the class JavadocExecHandleBuilder method getExecHandle.

public ExecAction getExecHandle() {
    try {
        options.write(optionsFile);
    } catch (IOException e) {
        throw new GradleException("Failed to store javadoc options.", e);
    }
    ExecAction execAction = execActionFactory.newExecAction();
    execAction.workingDir(execDirectory);
    execAction.executable(GUtil.elvis(executable, Jvm.current().getJavadocExecutable()));
    execAction.args("@" + optionsFile.getAbsolutePath());
    options.contributeCommandLineOptions(execAction);
    return execAction;
}
Also used : ExecAction(org.gradle.process.internal.ExecAction) GradleException(org.gradle.api.GradleException) IOException(java.io.IOException)

Example 72 with GradleException

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

the class ClasspathUtil method getClasspathForResource.

public static File getClasspathForResource(URL resource, String name) {
    URI location;
    try {
        location = toURI(resource);
        String path = location.getPath();
        if (location.getScheme().equals("file")) {
            assert path.endsWith("/" + name);
            return new File(path.substring(0, path.length() - (name.length() + 1)));
        } else if (location.getScheme().equals("jar")) {
            String schemeSpecificPart = location.getRawSchemeSpecificPart();
            int pos = schemeSpecificPart.indexOf("!");
            if (pos > 0) {
                assert schemeSpecificPart.substring(pos + 1).equals("/" + name);
                URI jarFile = new URI(schemeSpecificPart.substring(0, pos));
                if (jarFile.getScheme().equals("file")) {
                    return new File(jarFile.getPath());
                }
            }
        }
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    throw new GradleException(String.format("Cannot determine classpath for resource '%s' from location '%s'.", name, location));
}
Also used : GradleException(org.gradle.api.GradleException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) File(java.io.File)

Example 73 with GradleException

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

the class CachingTaskDependencyResolveContext method resolve.

public Set<Task> resolve(Task task) {
    this.task = task;
    try {
        return doResolve();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not determine the dependencies of %s.", task), e);
    } finally {
        queue.clear();
        this.task = null;
    }
}
Also used : GradleException(org.gradle.api.GradleException) GradleException(org.gradle.api.GradleException)

Example 74 with GradleException

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

the class GeneratorTask method generate.

@SuppressWarnings("UnusedDeclaration")
@TaskAction
void generate() {
    File inputFile = getInputFileIfExists();
    if (inputFile != null) {
        try {
            domainObject = generator.read(inputFile);
        } catch (RuntimeException e) {
            throw new GradleException(String.format("Cannot parse file '%s'.\n" + "       Perhaps this file was tinkered with? In that case try delete this file and then retry.", inputFile), e);
        }
    } else {
        domainObject = generator.defaultInstance();
    }
    beforeConfigured.execute(domainObject);
    generator.configure(domainObject);
    afterConfigured.execute(domainObject);
    generator.write(domainObject, getOutputFile());
}
Also used : GradleException(org.gradle.api.GradleException) File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile) InputFile(org.gradle.api.tasks.InputFile) TaskAction(org.gradle.api.tasks.TaskAction)

Example 75 with GradleException

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

the class MavenDeployAction method publishArtifacts.

@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws DeploymentException {
    RemoteRepository gradleRepo = remoteRepository;
    if (artifacts.iterator().next().isSnapshot() && remoteSnapshotRepository != null) {
        gradleRepo = remoteSnapshotRepository;
    }
    if (gradleRepo == null) {
        throw new GradleException("Must specify a repository for deployment");
    }
    org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo);
    DeployRequest request = new DeployRequest();
    request.setRepository(aetherRepo);
    for (Artifact artifact : artifacts) {
        request.addArtifact(artifact);
    }
    LOGGER.info("Deploying to {}", gradleRepo.getUrl());
    repositorySystem.deploy(session, request);
}
Also used : GradleException(org.gradle.api.GradleException) DeployRequest(org.sonatype.aether.deployment.DeployRequest) RemoteRepository(org.apache.maven.artifact.ant.RemoteRepository) Artifact(org.sonatype.aether.artifact.Artifact)

Aggregations

GradleException (org.gradle.api.GradleException)114 File (java.io.File)40 IOException (java.io.IOException)32 TaskAction (org.gradle.api.tasks.TaskAction)16 ArrayList (java.util.ArrayList)10 UncheckedIOException (org.gradle.api.UncheckedIOException)10 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)9 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)8 HashSet (java.util.HashSet)8 FileOutputStream (java.io.FileOutputStream)6 Method (java.lang.reflect.Method)6 UncheckedException (org.gradle.internal.UncheckedException)6 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)5 URL (java.net.URL)5 List (java.util.List)5 ConsoleRenderer (org.gradle.internal.logging.ConsoleRenderer)5 ProcessOutputHandler (com.android.ide.common.process.ProcessOutputHandler)4 FileInputStream (java.io.FileInputStream)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 MalformedURLException (java.net.MalformedURLException)4