MatrixTraceTransform transform process in the main logic

@Override
public void Transform (TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
Long Start = System.currentTimeMillis ()
// if incremental compilation
final boolean isIncremental = transformInvocation.isIncremental () && this.isIncremental ()
results // transform the redirect output to the directory
Final File rootOutput = new new File (project.matrix.output, "classes / $ {getName ()} /")
IF (! rootOutput.exists ()) {
rootOutput.mkdirs ()
}
Final TraceBuildConfig = initconfig traceConfig ()
Log.i ( "the Matrix." + getName (), "[Transform] isIncremental: rootOutput% S:% S", isIncremental, rootOutput.getAbsolutePath ())
// Get Class mapping information in confusion, memory in the mappingCollector
final MappingCollector mappingCollector = new MappingCollector()
File mappingFile = new File(traceConfig.getMappingPath());
if (mappingFile.exists() && mappingFile.isFile()) {
MappingReader mappingReader = new MappingReader(mappingFile);
mappingReader.read(mappingCollector)
}

Map<File, File> jarInputMap = new HashMap<>()
Map<File, File> scrInputMap = new HashMap<>()

transformInvocation.inputs.each { TransformInput input ->
input.directoryInputs.each { DirectoryInput dirInput ->
//收集、重定向目录中的class
collectAndIdentifyDir(scrInputMap, dirInput, rootOutput, isIncremental)
}
input.jarInputs.each { JarInput jarInput ->
if (jarInput.getStatus() != Status.REMOVED) {
// collection jar redirect packet class
collectAndIdentifyJar (jarInputMap, scrInputMap, jarInput, rootOutput, isIncremental)
}
}
}
The method of collecting the information needed // instrumented, the instrumentation information into each TraceMethod objects
MethodCollector methodCollector = new MethodCollector (traceConfig, mappingCollector)
the HashMap <String, TraceMethod> collectedMethodMap = methodCollector.collect (scrInputMap.keySet (). toList (), jarInputMap.keySet (). toList ())
// perform logic instrumented, the instrumentation required in the method inlet, outlet added MethodBeat i / o logic
methodTracer methodTracer = new new methodTracer (traceConfig, collectedMethodMap, methodCollector.getCollectedClassExtendMap (http://www.my516.com))
methodTracer.trace (scrInputMap, jarInputMap)
// execution logic of original transform ; default transformClassesWithDexBuilderForDebug this task will be converted into Class Dex
origTransform.transform(transformInvocation)
Log.i("Matrix." + getName(), "[transform] cost time: %dms", System.currentTimeMillis() - start)
}

Guess you like

Origin www.cnblogs.com/ly570/p/11291179.html