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);
}
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);
}
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;
}
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;
}
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")));
}
Aggregations