Search in sources :

Example 1 with StopExecutionException

use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.

the class AtlasBuilder method processAwbResources.

/**
     * 处理awb的资源
     *
     * @param aaptCommand
     * @param enforceUniquePackageName
     * @param processOutputHandler
     * @param mainSymbolFile
     */
public void processAwbResources(AaptPackageProcessBuilder aaptCommand, boolean enforceUniquePackageName, ProcessOutputHandler processOutputHandler, File mainSymbolFile) throws IOException, InterruptedException, ProcessException {
    if (!useCustomAapt) {
        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());
    // 打印日志
    //        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);
}
Also used : StopExecutionException(org.gradle.api.tasks.StopExecutionException) ProcessResult(com.android.ide.common.process.ProcessResult) ProcessInfo(com.android.ide.common.process.ProcessInfo)

Example 2 with StopExecutionException

use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.

the class AwbDexTask method taskAction.

/**
     * 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);
}
Also used : StopExecutionException(org.gradle.api.tasks.StopExecutionException) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 3 with StopExecutionException

use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.

the class ClassInjectTransform method initClassPool.

private ClassPool initClassPool(List<JarInput> jarInputs, List<DirectoryInput> directoryInputs) {
    if (((VariantScopeImpl) this.appVariantContext.getScope()).getVariantData().getName().toLowerCase().contains("debug")) {
        try {
            FieldUtils.writeStaticField(ClassPool.class, "defaultPool", null, true);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    } else {
    // logger.warn(">>> Do not open daemon <<<<");
    }
    final ClassPool pool = ClassPool.getDefault();
    try {
        File verifyFile = PathUtil.getJarFile(com.taobao.verify.Verifier.class);
        pool.insertClassPath(verifyFile.getAbsolutePath());
        for (File file : scope.getJavaClasspath(AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, AndroidArtifacts.ArtifactType.CLASSES)) {
            if (file.isFile()) {
                pool.insertClassPath(file.getAbsolutePath());
            } else {
                pool.appendClassPath(file.getAbsolutePath());
            }
        }
        String path = Joiner.on(File.pathSeparator).join(scope.getGlobalScope().getAndroidBuilder().getBootClasspathAsStrings(false));
        pool.appendPathList(path);
        for (JarInput jarInput : jarInputs) {
            pool.insertClassPath(jarInput.getFile().getAbsolutePath());
        }
        for (DirectoryInput directoryInput : directoryInputs) {
            pool.appendClassPath(directoryInput.getFile().getAbsolutePath());
        }
    } catch (NotFoundException e) {
        throw new StopExecutionException(e.getMessage());
    }
    return pool;
}
Also used : StopExecutionException(org.gradle.api.tasks.StopExecutionException) ClassPool(javassist.ClassPool) NotFoundException(javassist.NotFoundException) File(java.io.File)

Example 4 with StopExecutionException

use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.

the class InjectTransformManager method getTransformParam.

/**
 * 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;
}
Also used : Field(java.lang.reflect.Field) StopExecutionException(org.gradle.api.tasks.StopExecutionException)

Example 5 with StopExecutionException

use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.

the class AwoPropHandler method process.

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")));
}
Also used : StopExecutionException(org.gradle.api.tasks.StopExecutionException) FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

StopExecutionException (org.gradle.api.tasks.StopExecutionException)14 File (java.io.File)5 VariantScope (com.android.build.gradle.internal.scope.VariantScope)2 BaseVariantOutputData (com.android.build.gradle.internal.variant.BaseVariantOutputData)2 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 GradleException (org.gradle.api.GradleException)2 StopActionException (org.gradle.api.tasks.StopActionException)2 TaskAction (org.gradle.api.tasks.TaskAction)2 CompiledFile (android.aapt.pb.internal.ResourcesInternal.CompiledFile)1 ApkFiles (com.android.build.gradle.internal.api.ApkFiles)1 AppVariantOutputContext (com.android.build.gradle.internal.api.AppVariantOutputContext)1 GradleVariantConfiguration (com.android.build.gradle.internal.core.GradleVariantConfiguration)1 TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)1 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)1 DefaultAndroidTask (com.android.build.gradle.internal.tasks.DefaultAndroidTask)1 ProGuardTransform (com.android.build.gradle.internal.transforms.ProGuardTransform)1 ManifestProcessorTask (com.android.build.gradle.tasks.ManifestProcessorTask)1