use of org.gradle.api.GradleException in project atlas by alibaba.
the class DiffBundleInfoTask method generate.
/**
* 生成这个文件
*/
@TaskAction
public void generate() throws IOException {
dependencyDiff = getDependencyDiff();
//如果是patch的话,得到diff的操作
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());
}
}
use of org.gradle.api.GradleException in project atlas by alibaba.
the class AtlasAapt method makePackageProcessBuilder.
@Override
protected ProcessInfoBuilder makePackageProcessBuilder(AaptPackageConfig config) throws AaptException {
ProcessInfoBuilder processInfoBuilder = super.makePackageProcessBuilder(config);
List<String> args = null;
try {
args = (List<String>) FieldUtils.readField(processInfoBuilder, "mArgs", true);
} catch (IllegalAccessException e) {
throw new GradleException("getargs exception", e);
}
args.remove("--no-version-vectors");
int indexD = args.indexOf("-D");
if (indexD > 0) {
args.remove(indexD);
args.remove(indexD);
}
//加入R.txt文件的生成
String sybolOutputDir = config.getSymbolOutputDir().getAbsolutePath();
if (!args.contains("--output-text-symbols") && null != sybolOutputDir) {
args.add("--output-text-symbols");
args.add(sybolOutputDir);
}
return processInfoBuilder;
}
use of org.gradle.api.GradleException in project byte-buddy by raphw.
the class TransformationAction method processClassFile.
/**
* Processes a class file.
*
* @param root The root directory to process.
* @param file The class file to process.
* @param byteBuddy The Byte Buddy instance to use.
* @param entryPoint The transformation's entry point.
* @param methodNameTransformer The method name transformer to use.
* @param classFileLocator The class file locator to use.
* @param typePool The type pool to query for type descriptions.
* @param plugins The plugins to apply.
*/
private void processClassFile(File root, String file, ByteBuddy byteBuddy, EntryPoint entryPoint, MethodNameTransformer methodNameTransformer, ClassFileLocator classFileLocator, TypePool typePool, List<Plugin> plugins) {
String typeName = file.replace('/', '.').substring(0, file.length() - CLASS_FILE_EXTENSION.length());
project.getLogger().debug("Processing class file: {}", typeName);
TypeDescription typeDescription = typePool.describe(typeName).resolve();
DynamicType.Builder<?> builder;
try {
builder = entryPoint.transform(typeDescription, byteBuddy, classFileLocator, methodNameTransformer);
} catch (Throwable throwable) {
throw new GradleException("Cannot transform type: " + typeName, throwable);
}
boolean transformed = false;
for (Plugin plugin : plugins) {
try {
if (plugin.matches(typeDescription)) {
builder = plugin.apply(builder, typeDescription);
transformed = true;
}
} catch (Throwable throwable) {
throw new GradleException("Cannot apply " + plugin + " on " + typeName, throwable);
}
}
if (transformed) {
project.getLogger().info("Transformed type: {}", typeName);
DynamicType dynamicType = builder.make();
for (Map.Entry<TypeDescription, LoadedTypeInitializer> entry : dynamicType.getLoadedTypeInitializers().entrySet()) {
if (byteBuddyExtension.isFailOnLiveInitializer() && entry.getValue().isAlive()) {
throw new GradleException("Cannot apply live initializer for " + entry.getKey());
}
}
try {
dynamicType.saveIn(root);
} catch (IOException exception) {
throw new GradleException("Cannot save " + typeName + " in " + root, exception);
}
} else {
project.getLogger().debug("Skipping non-transformed type: {}", typeName);
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class DefaultBuildOperationExecutor method executeInParallel.
private <O extends BuildOperation> void executeInParallel(BuildOperationQueue.QueueWorker<O> worker, Action<BuildOperationQueue<O>> queueAction) {
failIfInResourceLockTransform();
BuildOperationQueue<O> queue = buildOperationQueueFactory.create(fixedSizePool, worker);
List<GradleException> failures = Lists.newArrayList();
try {
queueAction.execute(queue);
} catch (Exception e) {
failures.add(new BuildOperationQueueFailure("There was a failure while populating the build operation queue: " + e.getMessage(), e));
queue.cancel();
}
try {
queue.waitForCompletion();
} catch (MultipleBuildOperationFailures e) {
failures.add(e);
}
if (failures.size() == 1) {
throw failures.get(0);
} else if (failures.size() > 1) {
throw new DefaultMultiCauseException(formatMultipleFailureMessage(failures), failures);
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class DefaultScriptCompilationHandler method serializeMetadata.
private <M> void serializeMetadata(ScriptSource scriptSource, CompileOperation<M> extractingTransformer, File metadataDir, boolean emptyScript, boolean hasMethods) {
File metadataFile = new File(metadataDir, METADATA_FILE_NAME);
try {
GFileUtils.mkdirs(metadataDir);
KryoBackedEncoder encoder = new KryoBackedEncoder(new FileOutputStream(metadataFile));
try {
byte flags = (byte) ((emptyScript ? EMPTY_FLAG : 0) | (hasMethods ? HAS_METHODS_FLAG : 0));
encoder.writeByte(flags);
if (extractingTransformer != null && extractingTransformer.getDataSerializer() != null) {
Serializer<M> serializer = extractingTransformer.getDataSerializer();
serializer.write(encoder, extractingTransformer.getExtractedData());
}
} finally {
encoder.close();
}
} catch (Exception e) {
throw new GradleException(String.format("Failed to serialize script metadata extracted for %s", scriptSource.getDisplayName()), e);
}
}
Aggregations