當前位置: 首頁>>代碼示例>>Java>>正文


Java GradleException類代碼示例

本文整理匯總了Java中org.gradle.api.GradleException的典型用法代碼示例。如果您正苦於以下問題:Java GradleException類的具體用法?Java GradleException怎麽用?Java GradleException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GradleException類屬於org.gradle.api包,在下文中一共展示了GradleException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: publishArtifacts

import org.gradle.api.GradleException; //導入依賴的package包/類
@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);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:22,代碼來源:MavenDeployAction.java

示例2: getClasspathForClass

import org.gradle.api.GradleException; //導入依賴的package包/類
public static File getClasspathForClass(Class<?> targetClass) {
    URI location;
    try {
        CodeSource codeSource = targetClass.getProtectionDomain().getCodeSource();
        if (codeSource != null && codeSource.getLocation() != null) {
            location = codeSource.getLocation().toURI();
            if (location.getScheme().equals("file")) {
                return new File(location);
            }
        }
        if (targetClass.getClassLoader() != null) {
            String resourceName = targetClass.getName().replace('.', '/') + ".class";
            URL resource = targetClass.getClassLoader().getResource(resourceName);
            if (resource != null) {
                return getClasspathForResource(resource, resourceName);
            }
        }
        throw new GradleException(String.format("Cannot determine classpath for class %s.", targetClass.getName()));
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:ClasspathUtil.java

示例3: execute

import org.gradle.api.GradleException; //導入依賴的package包/類
@Override
public WorkResult execute(JavadocSpec spec) {
    JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
    javadocExecHandleBuilder.setExecutable(spec.getExecutable());
    javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());

    ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
    if (spec.isIgnoreFailures()) {
        execAction.setIgnoreExitValue(true);
    }

    try {
        execAction.execute();
    } catch (ExecException e) {
        LOG.info("Problems generating Javadoc."
                + "\n  Command line issued: " + execAction.getCommandLine()
                + "\n  Generated Javadoc options file has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
        throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
    }

    return new SimpleWorkResult(true);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:JavadocGenerator.java

示例4: getExecHandle

import org.gradle.api.GradleException; //導入依賴的package包/類
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;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:17,代碼來源:JavadocExecHandleBuilder.java

示例5: execute

import org.gradle.api.GradleException; //導入依賴的package包/類
@Override
public void execute(Task task) {
    Set<? extends Task> taskDependencies = task.getTaskDependencies().getDependencies(task);

    if (taskDependencies.isEmpty()) {
        TreeFormatter formatter = new TreeFormatter();
        formatter.node("No buildable binaries found");
        formatter.startChildren();
        for (BinarySpecInternal binary : notBuildable) {
            formatter.node(binary.getDisplayName());
            formatter.startChildren();
            binary.getBuildAbility().explain(formatter);
            formatter.endChildren();
        }
        formatter.endChildren();
        throw new GradleException(formatter.toString());
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:19,代碼來源:ComponentModelBasePlugin.java

示例6: doRunWithFailure

import org.gradle.api.GradleException; //導入依賴的package包/類
@Override
protected ExecutionFailure doRunWithFailure() {
    if (isForkRequired()) {
        return doStart().waitForFailure();
    }

    StandardOutputListener outputListener = new OutputListenerImpl();
    StandardOutputListener errorListener = new OutputListenerImpl();
    BuildListenerImpl buildListener = new BuildListenerImpl();
    try {
        doRun(outputListener, errorListener, buildListener).rethrowFailure();
        throw new AssertionError("expected build to fail but it did not.");
    } catch (GradleException e) {
        return assertResult(new InProcessExecutionFailure(buildListener.executedTasks, buildListener.skippedTasks,
                new OutputScrapingExecutionFailure(outputListener.toString(), errorListener.toString()), e));
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:18,代碼來源:InProcessGradleExecuter.java

示例7: setupProjectLayout

import org.gradle.api.GradleException; //導入依賴的package包/類
@TaskAction
public void setupProjectLayout() {
    final String type = getType();
    BuildInitTestFramework testFramework = BuildInitTestFramework.fromName(getTestFramework());
    final ProjectLayoutSetupRegistry projectLayoutRegistry = getProjectLayoutRegistry();
    if (!projectLayoutRegistry.supports(type)) {
        String supportedTypes = Joiner.on(", ").join(Iterables.transform(projectLayoutRegistry.getSupportedTypes(), new Function<String, String>() {
            @Override
            public String apply(String input) {
                return "'" + input + "'";
            }
        }));
        throw new GradleException("The requested build setup type '" + type + "' is not supported. Supported types: " + supportedTypes + ".");
    }

    ProjectInitDescriptor initDescriptor = projectLayoutRegistry.get(type);
    if (!testFramework.equals(BuildInitTestFramework.NONE) && !initDescriptor.supports(testFramework)) {
        throw new GradleException("The requested test framework '" + testFramework.getId() + "' is not supported in '" + type + "' setup type");
    }

    initDescriptor.generate(testFramework);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:InitBuild.java

示例8: runAudit

import org.gradle.api.GradleException; //導入依賴的package包/類
public Collection<MavenPackageDescriptor> runAudit() {
    try {
        List<MavenPackageDescriptor> results = new LinkedList<>();
        Collection<PackageDescriptor> packages = request.run();
        for (PackageDescriptor pkg : packages) {
            MavenPackageDescriptor mvnPkg = new MavenPackageDescriptor(pkg);
            if (parents.containsKey(pkg)) {
                PackageDescriptor parent = parents.get(pkg);
                if (parent != null) {
                    mvnPkg.setParent(new MavenIdWrapper(parent));
                }
            }
            if (mvnPkg.getVulnerabilityMatches() > 0) {
                results.add(mvnPkg);
            }
        }
        return results;
    }
    catch(IOException e) {
        throw new GradleException("Error trying to get audit results", e);
    }
}
 
開發者ID:OSSIndex,項目名稱:ossindex-gradle-plugin,代碼行數:23,代碼來源:DependencyAuditor.java

示例9: generate

import org.gradle.api.GradleException; //導入依賴的package包/類
/**
 * Generate this file
 */
@TaskAction
public void generate() throws IOException {

    dependencyDiff = getDependencyDiff();

    //If it's patch, get the diff operation
    if (null == dependencyDiff) {
        return;
    }

    try {
        appVariantOutputContext.artifactBundleInfos = getArtifactBundleInfo(getDependencyDiff(),
                                                                            getManifestFile(),
                                                                            getApDir());
        FileUtils.writeStringToFile(new File(getOutJsonFile(), "dependencyDiff.json"),
                                    JSON.toJSONString(dependencyDiff, true));
    } catch (Exception e) {
        throw new GradleException(e.getMessage());
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:24,代碼來源:DiffBundleInfoTask.java

示例10: resolveToFoundResult

import org.gradle.api.GradleException; //導入依賴的package包/類
private Result resolveToFoundResult(PluginResolver effectivePluginResolver, PluginRequest request) {
    Result result = new Result(request);
    try {
        effectivePluginResolver.resolve(request, result);
    } catch (Exception e) {
        throw new LocationAwareException(
            new GradleException(String.format("Error resolving plugin %s", request.getDisplayName()), e),
            request.getScriptDisplayName(), request.getLineNumber());
    }

    if (!result.isFound()) {
        String message = buildNotFoundMessage(request, result);
        Exception exception = new UnknownPluginException(message);
        throw new LocationAwareException(exception, request.getScriptDisplayName(), request.getLineNumber());
    }

    return result;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:19,代碼來源:DefaultPluginRequestApplicator.java

示例11: parseJavaVersionCommandOutput

import org.gradle.api.GradleException; //導入依賴的package包/類
private JavaVersion parseJavaVersionCommandOutput(String javaExecutable, BufferedReader reader) {
    try {
        String versionStr = reader.readLine();
        while (versionStr != null) {
            Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"").matcher(versionStr);
            if (matcher.matches()) {
                return JavaVersion.toVersion(matcher.group(1));
            }
            versionStr = reader.readLine();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    throw new GradleException(String.format("Could not determine Java version using executable %s.", javaExecutable));
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:17,代碼來源:DefaultJvmVersionDetector.java

示例12: executeSQLExecutor

import org.gradle.api.GradleException; //導入依賴的package包/類
@TaskAction
public void executeSQLExecutor() {

    String taskName = this.getName();

    if (sqlFiles==null) {
        throw new GradleException("sqlFiles is null");
    }


    List<File> files = convertToFileList(sqlFiles);

    try {
        SqlExecutorStep step = new SqlExecutorStep(taskName);
        step.execute(database, files,sqlParameters);
        log.info("Task start");
    } catch (Exception e) {
        log.error("Exception in creating / invoking SqlExecutorStep.", e);

        GradleException ge = TaskUtil.toGradleException(e);
        throw ge;
    }
}
 
開發者ID:sogis,項目名稱:gretl,代碼行數:24,代碼來源:SqlExecutor.java

示例13: setLaunchables

import org.gradle.api.GradleException; //導入依賴的package包/類
public Builder setLaunchables(Iterable<? extends Launchable> launchables) {
    Set<String> taskPaths = new LinkedHashSet<String>();
    List<InternalLaunchable> launchablesParams = Lists.newArrayList();
    for (Launchable launchable : launchables) {
        Object original = new ProtocolToModelAdapter().unpack(launchable);
        if (original instanceof InternalLaunchable) {
            // A launchable created by the provider - just hand it back
            launchablesParams.add((InternalLaunchable) original);
        } else if (original instanceof TaskListingLaunchable) {
            // A launchable synthesized by the consumer - unpack it into a set of task names
            taskPaths.addAll(((TaskListingLaunchable) original).getTaskNames());
        } else if (launchable instanceof Task) {
            // A task created by a provider that does not understand launchables
            taskPaths.add(((Task) launchable).getPath());
        } else {
            throw new GradleException("Only Task or TaskSelector instances are supported: "
                + (launchable != null ? launchable.getClass() : "null"));
        }
    }
    // Tasks are ignored by providers if launchables is not null
    this.launchables = launchablesParams.isEmpty() ? null : launchablesParams;
    tasks = Lists.newArrayList(taskPaths);
    return this;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:25,代碼來源:ConsumerOperationParameters.java

示例14: getClassObfMap

import org.gradle.api.GradleException; //導入依賴的package包/類
private Map<String, String> getClassObfMap(GradleVariantConfiguration config) {
    Map<String, String> classMap = new HashMap<String, String>();
    boolean isMinifyEnabled = config.isMinifyEnabled();
    File proguardOut = new File(Joiner.on(File.separatorChar).join(
        String.valueOf(appVariantContext.getScope().getGlobalScope().getBuildDir()), FD_OUTPUTS, "mapping",
        appVariantContext.getScope().getVariantConfiguration().getDirName()));
    File mappingFile = new File(proguardOut, "mapping.txt");
    // Parse the mapping file to generate the new mainDexListFile
    if (isMinifyEnabled && mappingFile.exists()) {
        MappingReader mappingReader = new MappingReader(mappingFile);
        MappingReaderProcess process = new MappingReaderProcess();
        try {
            mappingReader.pump(process);
        } catch (IOException e) {
            throw new GradleException(e.getMessage(), e);
        }
        classMap = process.classMapping;
    }
    return classMap;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:21,代碼來源:MainDexLister.java

示例15: generate

import org.gradle.api.GradleException; //導入依賴的package包/類
@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());
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:22,代碼來源:GeneratorTask.java


注:本文中的org.gradle.api.GradleException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。