Java 类org.gradle.api.GradleScriptException 实例源码

项目:Reer    文件:DefaultExceptionAnalyser.java   
private Throwable findDeepestRootException(Throwable exception) {
    // TODO: fix the way we work out which exception is important: TaskExecutionException is not always the most helpful
    Throwable locationAware = null;
    Throwable result = null;
    Throwable contextMatch = null;
    for (Throwable current = exception; current != null; current = current.getCause()) {
        if (current instanceof LocationAwareException) {
            locationAware = current;
        } else if (current instanceof GradleScriptException || current instanceof TaskExecutionException) {
            result = current;
        } else if (contextMatch == null && current.getClass().getAnnotation(Contextual.class) != null) {
            contextMatch = current;
        }
    }
    if (locationAware != null) {
        return locationAware;
    } else if (result != null) {
        return result;
    } else if (contextMatch != null) {
        return contextMatch;
    } else {
        return exception;
    }
}
项目:Reer    文件:DefaultScriptRunnerFactory.java   
@Override
public void run(Object target, ServiceRegistry scriptServices) throws GradleScriptException {
    if (!compiledScript.getRunDoesSomething()) {
        return;
    }

    ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
    T script = getScript();
    script.init(target, scriptServices);
    Thread.currentThread().setContextClassLoader(script.getContextClassloader());
    script.getStandardOutputCapture().start();
    try {
        script.run();
    } catch (Throwable e) {
        throw new GradleScriptException(String.format("A problem occurred evaluating %s.", script), e);
    } finally {
        script.getStandardOutputCapture().stop();
        Thread.currentThread().setContextClassLoader(originalLoader);
    }
}
项目:copyrightr    文件:Parser.java   
/**
 * Parse the files, looking for the copyright notice, then print out a 
 * summary, if the failOnMissing flag is set and there are missing 
 * copyright notices, the build will fail.
 */
public void parse() {
    Set<File> files = asFileTree.getFiles();
    for (File file : files) {
        try {
            parseFile(file);
        } catch (CopyrightrException ex) {
            logger.error(ex.getMessage());
        }
    }

    // print out the statistics
    logger.lifecycle("  Copyrightr found the following:");
    logger.lifecycle("  ===============================");
    logger.lifecycle("    Searched files: " + statistics.getNumFiles());
    logger.lifecycle("         found (c): " + statistics.getNumFound());
    logger.lifecycle("       missing (c): " + statistics.getNumMissing());
    logger.lifecycle("       updated (c): " + statistics.getNumUpdated());
    logger.lifecycle("   not updated (c): " + statistics.getNumNotUpdated());

    if(failOnMissing && statistics.getNumMissing() > 0) {
        throw new GradleScriptException(String.format("Missing copyright notices on %d files, failing...", statistics.getNumMissing()), new Exception("Missing copyright notices in file(s)"));
    }

}
项目:Pushjet-Android    文件:DefaultExceptionAnalyser.java   
private Throwable findDeepestRootException(Throwable exception) {
    // TODO: fix the way we work out which exception is important: TaskExecutionException is not always the most helpful
    Throwable locationAware = null;
    Throwable result = null;
    Throwable contextMatch = null;
    for (Throwable current = exception; current != null; current = current.getCause()) {
        if (current instanceof LocationAwareException) {
            locationAware = current;
        } else if (current instanceof GradleScriptException || current instanceof TaskExecutionException) {
            result = current;
        } else if (contextMatch == null && current.getClass().getAnnotation(Contextual.class) != null) {
            contextMatch = current;
        }
    }
    if (locationAware != null) {
        return locationAware;
    } else if (result != null) {
        return result;
    } else if (contextMatch != null) {
        return contextMatch;
    } else {
        return exception;
    }
}
项目:Pushjet-Android    文件:DefaultExceptionAnalyser.java   
private Throwable findDeepestRootException(Throwable exception) {
    // TODO: fix the way we work out which exception is important: TaskExecutionException is not always the most helpful
    Throwable locationAware = null;
    Throwable result = null;
    Throwable contextMatch = null;
    for (Throwable current = exception; current != null; current = current.getCause()) {
        if (current instanceof LocationAwareException) {
            locationAware = current;
        } else if (current instanceof GradleScriptException || current instanceof TaskExecutionException) {
            result = current;
        } else if (contextMatch == null && current.getClass().getAnnotation(Contextual.class) != null) {
            contextMatch = current;
        }
    }
    if (locationAware != null) {
        return locationAware;
    } else if (result != null) {
        return result;
    } else if (contextMatch != null) {
        return contextMatch;
    } else {
        return exception;
    }
}
项目:Reer    文件:IdeaScalaConfigurer.java   
private VersionNumber findIdeaTargetVersion() {
    VersionNumber targetVersion = null;
    String targetVersionString = rootProject.getExtensions().getByType(IdeaModel.class).getTargetVersion();
    if (targetVersionString != null) {
        targetVersion = VersionNumber.parse(targetVersionString);
        if (targetVersion.equals(VersionNumber.UNKNOWN)) {
            throw new GradleScriptException("String \'" + targetVersionString + "\' is not a valid value for IdeaModel.targetVersion.", null);
        }
    }
    return targetVersion;
}
项目:gradle-website-optimizer    文件:Utils.java   
public static String readMinifiedFile(Project project, TagPair tag) {
    File file = getDestinationFile(project, tag);

    try (FileInputStream fileIn = new FileInputStream(file)) {
        try (BufferedInputStream in = new BufferedInputStream(fileIn)) {
            return IOUtils.toString(in);
        }
    } catch (IOException e) {
        throw new GradleScriptException("Unable to read minified file!", e);
    }
}
项目:testobject-gradle-plugin    文件:TestObjectTestServer.java   
private void login(TestObjectClient client, String user, String password) {
    try {
        client.login(user, password);

        logger.info(String.format("user %s successfully logged in", user));
    } catch (Exception e) {
        throw new GradleScriptException(String.format("unable to login user %s", user), e);
    }
}
项目:testobject-gradle-plugin    文件:TestObjectTestServer.java   
private void updateInstrumentationSuite(File testApk, File appAk, TestObjectClient client, String team, String app, Long testSuite,
        TestSuiteResource.InstrumentationTestSuiteRequest request) {
    try {
        client.updateInstrumentationTestSuite(team, app, testSuite, appAk, testApk, request);
        logger.info(String.format("Uploaded appAPK : %s and testAPK : %s", appAk.getAbsolutePath(), testApk.getAbsolutePath()));
    } catch (Exception e) {
        throw new GradleScriptException(String.format("unable to update testSuite %s", testSuite), e);
    }
}
项目:Reer    文件:ScriptRunner.java   
/**
 * Executes the script. This is generally more efficient than using {@link #getScript()}.
 *
 * @throws GradleScriptException On execution failure.
 */
void run(Object target, ServiceRegistry scriptServices) throws GradleScriptException;
项目:Pushjet-Android    文件:ScriptRunner.java   
/**
 * Executes the script.
 *
 * @throws GradleScriptException On execution failure.
 */
void run() throws GradleScriptException;
项目:Pushjet-Android    文件:ScriptRunner.java   
/**
 * Executes the script.
 *
 * @throws GradleScriptException On execution failure.
 */
void run() throws GradleScriptException;