use of org.gradle.api.tasks.StopExecutionException in project gradle by gradle.
the class ExecuteActionsTaskExecuter method executeActions.
private GradleException executeActions(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
LOGGER.debug("Executing actions for {}.", task);
final List<ContextAwareTaskAction> actions = new ArrayList<ContextAwareTaskAction>(task.getTaskActions());
for (ContextAwareTaskAction action : actions) {
state.setDidWork(true);
task.getStandardOutputCapture().start();
try {
executeAction(action.getDisplayName(), task, action, context);
} catch (StopActionException e) {
// Ignore
LOGGER.debug("Action stopped by some action with message: {}", e.getMessage());
} catch (StopExecutionException e) {
LOGGER.info("Execution stopped by some action with message: {}", e.getMessage());
break;
} catch (Throwable t) {
return new TaskExecutionException(task, t);
} finally {
task.getStandardOutputCapture().stop();
}
}
return null;
}
use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.
the class ApkFileListUtils method recordApkFileInfos.
/**
* 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;
}
use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.
the class InjectTransformManager method updateTransformTaskConfig.
/**
* 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);
}
use of org.gradle.api.tasks.StopExecutionException in project atlas by alibaba.
the class InjectTransformManager method addInjectTransformBeforeTransform.
/**
* Add a Transform operation before some Transform
*
* @param transformClazz
* @param injectTransform
* @param scope
* @param <T>
* @return
*/
public <T extends InjectTransform> TransformTask addInjectTransformBeforeTransform(Class<? extends Transform> transformClazz, T injectTransform, @NonNull VariantScope scope) {
TaskCollection<DefaultAndroidTask> androidTasks = project.getTasks().withType(DefaultAndroidTask.class);
SortedMap<String, DefaultAndroidTask> androidTaskSortedMap = androidTasks.getAsMap();
// The task to be inserted
TransformTask oprTransformTask = null;
for (String taskName : androidTaskSortedMap.keySet()) {
DefaultAndroidTask androidTask = androidTaskSortedMap.get(taskName);
if (variantName.equals(androidTask.getVariantName())) {
if (androidTask instanceof TransformTask && ((TransformTask) androidTask).getTransform().getClass().equals(transformClazz)) {
oprTransformTask = (TransformTask) androidTask;
break;
}
}
}
if (null == oprTransformTask) {
throw new StopExecutionException("TransformTask with transfrom type:" + transformClazz.getName() + " can not found!");
}
transforms.add(injectTransform);
// Determines whether the two Transform dependencies are correct, that is, the output type is consistent with the next input type
checkTransformConfig(oprTransformTask.getTransform(), injectTransform);
String taskName = scope.getTaskName(getTaskNamePrefix(injectTransform));
try {
IntermediateStream outputStream = getOutputStream(injectTransform, scope, taskName);
// Configuration TransformTask
TransformTaskParam transformTaskParam = getTransformParam(oprTransformTask);
TransformTask.ConfigAction<T> configAction = new TransformTask.ConfigAction<T>(variantName, taskName, injectTransform, transformTaskParam.consumedInputStreams, transformTaskParam.referencedInputStreams, outputStream, ThreadRecorder.get(), null);
TransformTask injectTransformTask = project.getTasks().create(configAction.getName(), configAction.getType());
oprTransformTask.dependsOn(injectTransformTask);
for (TransformStream transformStream : transformTaskParam.consumedInputStreams) {
if (null != transformStream.getFileCollection()) {
injectTransformTask.dependsOn(transformStream.getFileCollection());
}
}
if (transformTaskList.size() > 0) {
injectTransformTask.dependsOn(transformTaskList.get(transformTaskList.size() - 1));
}
transformTaskList.add(taskName);
configAction.execute(injectTransformTask);
// Modify the input of the oprTransformTask
if (injectTransform.updateNextTransformInput()) {
Collection<TransformStream> newInputStream = Lists.newArrayList();
newInputStream.add(outputStream);
updateTransformTaskConfig(oprTransformTask, newInputStream, transformTaskParam.referencedInputStreams, transformTaskParam.outputStream);
}
return injectTransformTask;
} catch (IllegalAccessException e) {
throw new StopExecutionException(e.getMessage());
}
}
Aggregations