Java 类org.gradle.api.tasks.StopExecutionException 实例源码

项目:atlas    文件:InjectTransformManager.java   
/**
 * Update the parameters for the transformTask
 *
 * @param transformTask
 * @param consumedInputStreams
 * @param referencedInputStreams
 * @param outputStream
 */
private void updateTransformTaskConfig(TransformTask transformTask,
                                       @NonNull Collection<TransformStream> consumedInputStreams,
                                       @NonNull Collection<TransformStream> referencedInputStreams,
                                       @Nullable IntermediateStream outputStream) throws IllegalAccessException {
    Field consumedInputStreamsField = FieldUtils.getDeclaredField(StreamBasedTask.class,
                                                                  "consumedInputStreams",
                                                                  true);
    Field referencedInputStreamsField = FieldUtils.getDeclaredField(StreamBasedTask.class,
                                                                    "referencedInputStreams",
                                                                    true);
    Field outputStreamField = FieldUtils.getDeclaredField(StreamBasedTask.class,
                                                          "outputStream",
                                                          true);

    if (null == consumedInputStreamsField ||
            null == referencedInputStreamsField ||
            null == outputStreamField) {
        throw new StopExecutionException(
                "The TransformTask does not has field with name: consumedInputStreams or referencedInputStreams or outputStream! Plugin version does not support!");
    }
    consumedInputStreamsField.set(transformTask, consumedInputStreams);
    referencedInputStreamsField.set(transformTask, referencedInputStreams);
    outputStreamField.set(transformTask, outputStream);
}
项目:atlas    文件:InjectTransformManager.java   
/**
 * Gets the parameters of a transformTask
 *
 * @param transformTask
 * @return
 * @throws IllegalAccessException
 */
private TransformTaskParam getTransformParam(TransformTask transformTask) throws IllegalAccessException {
    TransformTaskParam transformTaskParam = new TransformTaskParam();
    Field consumedInputStreamsField = FieldUtils.getDeclaredField(StreamBasedTask.class,
                                                                  "consumedInputStreams",
                                                                  true);
    Field referencedInputStreamsField = FieldUtils.getDeclaredField(StreamBasedTask.class,
                                                                    "referencedInputStreams",
                                                                    true);
    Field outputStreamField = FieldUtils.getDeclaredField(StreamBasedTask.class,
                                                          "outputStream",
                                                          true);

    if (null == consumedInputStreamsField ||
            null == referencedInputStreamsField ||
            null == outputStreamField) {
        throw new StopExecutionException(
                "The TransformTask does not has field with name: consumedInputStreams or referencedInputStreams or outputStream! Plugin version does not support!");
    }
    transformTaskParam.consumedInputStreams = (Collection<TransformStream>) consumedInputStreamsField
            .get(transformTask);
    transformTaskParam.referencedInputStreams = (Collection<TransformStream>) referencedInputStreamsField
            .get(transformTask);
    transformTaskParam.outputStream = (IntermediateStream) outputStreamField.get(transformTask);
    return transformTaskParam;
}
项目:atlas    文件:MtlBaseTaskAction.java   
protected void setFieldValueByReflection(Task task, String fieldName, Object value) {
    Field field = FieldUtils.getField(task.getClass(), fieldName, true);
    if (null == field) {
        throw new StopExecutionException("The field with name:" +
                                                 fieldName +
                                                 " does not existed in class:" +
                                                 task.getClass().getName());
    }
    try {
        FieldUtils.writeField(field, task, value, true);
    } catch (IllegalAccessException e) {
        throw new StopExecutionException(e.getMessage());
    }
}
项目:atlas    文件:DexBuildTask.java   
private ClassPool initClassPool(File jar) {
    final ClassPool pool = ClassPool.getDefault();
    try {
        File verifyFile = PathUtil.getJarFile(com.taobao.verify.Verifier.class);
        pool.insertClassPath(verifyFile.getAbsolutePath());
        pool.insertClassPath(jar.getAbsolutePath());
    } catch (NotFoundException e) {
        throw new StopExecutionException(e.getMessage());
    }
    return pool;
}
项目:atlas    文件:AwbDexTask.java   
/**
 * Actual entry point for the action.
 * Calls out to the doTaskAction as needed.
 */
@TaskAction
public void taskAction() throws InterruptedException, ProcessException, IOException {
    Collection<File> _inputFiles = getInputFiles();
    File _inputDir = getInputDir();
    if (_inputFiles == null && _inputDir == null) {
        throw new StopExecutionException("Dex task " +
                                             getName() +
                                             ": inputDir and inputFiles cannot both be null");
    }
    doTaskAction(_inputFiles, _inputDir, false);
}
项目:atlas    文件:ApkFileListUtils.java   
/**
 * Records resource information for apk files
 */
public static ApkFiles recordApkFileInfos(AppVariantContext appVariantContext) {

    ApkFiles apkFiles = new ApkFiles();

    List<File> mainBundleResFolders = new ArrayList<File>();
    mainBundleResFolders.add(appVariantContext.getScope().getVariantData().mergeResourcesTask.getOutputDir());
    prepareApkFileList(appVariantContext.getScope().getVariantData().mergeAssetsTask.getOutputDir(),
                       "assets", apkFiles);
    for (File resFolder : mainBundleResFolders) {
        prepareApkFileList(resFolder, "res", apkFiles);
    }

    // Record the resource information for each bundle
    AtlasDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(appVariantContext.getScope().
        getVariantConfiguration().getFullName());
    if (null == dependencyTree) {
        throw new StopExecutionException("DependencyTree cannot be null!");
    }

    List<AwbBundle> libs = dependencyTree.getAwbBundles();

    for (AwbBundle awbLib : libs) {
        File mergeAssertFolder = appVariantContext.getMergeAssets(awbLib);
        File mergeResFolder = appVariantContext.getMergeResources(awbLib);
        String awbName = awbLib.getName();
        prepareApkFileList(mergeAssertFolder, "assets", awbName, apkFiles);
        prepareApkFileList(mergeResFolder, "res", awbName, apkFiles);
    }

    return apkFiles;
}
项目:atlas    文件:AwoPropHandler.java   
public void process(TBuildType buildType, BundleConfig bundleConfig) throws Exception {

        String propfile = EnvHelper.getEnv("awoprop");

        if (StringUtils.isEmpty(propfile)) {
            return;
        }

        Properties properties = new Properties();
        properties.load(new FileInputStream(propfile));

        String ap_path = properties.getProperty(AP_PATH);
        boolean refresh_ap = "true".equals(properties.getProperty(REFRESH_AP));
        String mtl_url = properties.getProperty(MTL_URL);

        if (!refresh_ap && StringUtils.isNotEmpty(ap_path) && new File(ap_path).exists()) {
            //not need download
            System.out.println("[awo] ap file exist");
        }

        if (StringUtils.isEmpty(mtl_url)) {
            throw new StopExecutionException("mtl_url is not configed");
        }

        ap_path = ApDownloader.downloadAP(mtl_url, new File(propfile).getParentFile()).getAbsolutePath();
        properties.setProperty(AP_PATH, ap_path);
        properties.store(new FileOutputStream(propfile), "update path");

        buildType.setBaseApFile(new File(ap_path));

        bundleConfig.setAwoBuildEnabled(true);
        bundleConfig.setAwoDynDeploy("true".equals(properties.getProperty(SUPPORT_DYN, "true")));
        bundleConfig.setAwoApkBuild("true".equals(properties.getProperty(SUPPORT_APK, "true")));
    }
项目:atlas    文件:AtlasBuilder.java   
/**
 * Deal with awb resources
 *
 * @param aaptCommand
 * @param enforceUniquePackageName
 * @param processOutputHandler
 * @param mainSymbolFile
 */
public void processAwbResources(AaptPackageProcessBuilder aaptCommand,
                                boolean enforceUniquePackageName,
                                ProcessOutputHandler processOutputHandler,
                                File mainSymbolFile) throws IOException, InterruptedException, ProcessException {
    if (!atlasExtension.getTBuildConfig().getUseCustomAapt()) {
        throw new StopExecutionException("Must set useCustomAapt value to true for awb build!");
    }

    checkState(getTargetInfo() != null,
               "Cannot call processResources() before setTargetInfo() is called.");

    // launch aapt: create the command line
    ProcessInfo processInfo = aaptCommand.build(getTargetInfo().getBuildTools(),
                                                getTargetInfo().getTarget(),
                                                getLogger());

    processInfo = new TProcessInfo(processInfo, aaptCommand.getSymbolOutputDir());

    // Print log
    //        if (null != getLogger()) {
    //            getLogger().info("[Aapt]" + processInfo.getExecutable() + " "
    //                    + StringUtils.join(processInfo.getArgs(), " "));
    //        }

    ProcessResult result = getProcessExecutor().execute(processInfo, processOutputHandler);
    result.rethrowFailure().assertNormalExitValue();

    processAwbSymbols(aaptCommand, mainSymbolFile, enforceUniquePackageName);
}
项目:shipkit    文件:ExecCommandFactory.java   
public static Action<ExecResult> stopExecution() {
    return new Action<ExecResult>() {
        public void execute(ExecResult exec) {
            if (exec.getExitValue() != 0) {
                LOG.info("External process returned exit code: {}. Stopping the execution of the task.");
                //Cleanly stop executing the task, without making the task failed.
                throw new StopExecutionException();
            }
        }
    };
}
项目:appversion-plugin    文件:AppVersionPlugin.java   
@Override
public void apply(final Project project) {
    if (!hasAndroidPlugin(project)) {
        throw new StopExecutionException("No 'android' or 'android-library' plugin detected.");
    }

    final AppVersionExtension ext = project.getExtensions().create("appversion", AppVersionExtension.class);
    try {
        ext.setCode(getGitTags(project));
        ext.setName(getGitTagDescriptions(project));
    } catch (Throwable t) {
        //todo
    }
}
项目:gradle-release-plugin    文件:SVNInfo.java   
public SVNRevision getRevision() {
    if (revision == null) {
        return SVNRevision.HEAD;
    }

    SVNRevision svnr = SVNRevision.parse(revision);
    if (SVNRevision.UNDEFINED.equals(svnr)) {
        getLogger().error("--> revision " + revision +" is invalid");
        throw new StopExecutionException();
    }
    return svnr;
}
项目:Reer    文件:AbstractFileCollection.java   
public FileCollection stopExecutionIfEmpty() {
    if (isEmpty()) {
        throw new StopExecutionException(String.format("%s does not contain any files.", getCapDisplayName()));
    }
    return this;
}
项目:Pushjet-Android    文件:DelegatingFileCollection.java   
public FileCollection stopExecutionIfEmpty() throws StopExecutionException {
    return getDelegate().stopExecutionIfEmpty();
}
项目:Pushjet-Android    文件:AbstractFileCollection.java   
public FileCollection stopExecutionIfEmpty() {
    if (isEmpty()) {
        throw new StopExecutionException(String.format("%s does not contain any files.", getCapDisplayName()));
    }
    return this;
}
项目:Pushjet-Android    文件:DelegatingFileCollection.java   
public FileCollection stopExecutionIfEmpty() throws StopExecutionException {
    return getDelegate().stopExecutionIfEmpty();
}
项目:Pushjet-Android    文件:AbstractFileCollection.java   
public FileCollection stopExecutionIfEmpty() {
    if (isEmpty()) {
        throw new StopExecutionException(String.format("%s does not contain any files.", getCapDisplayName()));
    }
    return this;
}
项目:gnag    文件:GnagCheck.java   
private void executeGnagCheck() {
    final Set<Violation> allDetectedViolations = new HashSet<>();

    violationDetectors
            .stream()
            .filter(ViolationDetector::isEnabled)
            .forEach(violationDetector -> {

                    if (violationDetector instanceof BaseExecutedViolationDetector) {
                        ((BaseExecutedViolationDetector) violationDetector).executeReporter();
                    }

                    final List<Violation> detectedViolations = violationDetector.getDetectedViolations();
                    allDetectedViolations.addAll(detectedViolations);

                    System.out.println(
                            violationDetector.name() + " detected " + detectedViolations.size() + " violations.");
            });

    final File reportsDir = projectHelper.getReportsDir();

    if (allDetectedViolations.isEmpty()) {
        ReportWriter.deleteLocalReportFiles(reportsDir);

        getProject().setStatus(CheckStatus.getSuccessfulCheckStatus());

        System.out.println("Congrats, no poop code found!");
    } else {
        ReportWriter.writeLocalReportFiles(allDetectedViolations, reportsDir);

        getProject().setStatus(new CheckStatus(FAILURE, allDetectedViolations));

        final String failedMessage
                = "One or more violation detectors has found violations. Check the report at "
                + reportsDir
                + File.separatorChar
                + REPORT_FILE_NAME + " for details.";

        if (gnagPluginExtension.shouldFailOnError() && !taskExecutionGraphIncludesGnagReport()) {
            throw new GradleException(failedMessage);
        } else {
            System.out.println(failedMessage);
            throw new StopExecutionException(failedMessage);
        }
    }
}
项目:Reer    文件:FileCollection.java   
/**
 * Throws a {@link StopExecutionException} if this collection is empty.
 *
 * @return this
 * @throws StopExecutionException When this collection is empty.
 */
FileCollection stopExecutionIfEmpty() throws StopExecutionException;
项目:Pushjet-Android    文件:FileCollection.java   
/**
 * Throws a {@link StopExecutionException} if this collection is empty.
 *
 * @return this
 * @throws StopExecutionException When this collection is empty.
 */
FileCollection stopExecutionIfEmpty() throws StopExecutionException;
项目:Pushjet-Android    文件:FileCollection.java   
/**
 * Throws a {@link StopExecutionException} if this collection is empty.
 *
 * @return this
 * @throws StopExecutionException When this collection is empty.
 */
FileCollection stopExecutionIfEmpty() throws StopExecutionException;