メインロジックに変換処理をMatrixTraceTransform

@Override
公共ボイド(TransformInvocation transformInvocation)を変換TransformException、InterruptedExceptionあるは、IOException {スロー
ロングスタート=にSystem.currentTimeMillis()
//もしインクリメンタルコンパイル
最終ブールisIncremental = transformInvocation.isIncremental()&& this.isIncremental()
//変換結果をディレクトリに出力をリダイレクトし
、最終的なファイルrootOutputは=新しい新しいファイル(project.matrix.output、 "クラス/ $ {のgetName()} /")
IF(!rootOutput.exists()){
rootOutput.mkdirs()
}
最終TraceBuildConfig = initconfig traceConfig()
Log.i( "マトリックス。" +のgetName()は、 "isIncrementalを[変換]:rootOutput%S:%S"、isIncremental、rootOutput.getAbsolutePath())
//、混乱の中で、クラスのマッピング情報を取得するメモリmappingCollectorで
最終MappingCollector mappingCollector =新しいMappingCollector()
mappingFileファイル=新しいファイル(traceConfig.getMappingPath());
IF(mappingFile.exists()&& mappingFile.isFile()){
MappingReader mappingReader =新しいMappingReader(mappingFile)。
mappingReader.read(mappingCollector)
}

地図<ファイル、ファイル> jarInputMap =新規HashMapの<>()
地図<ファイル、ファイル> scrInputMap =新規HashMapの<>()

transformInvocation.inputs.each {TransformInput入力- >
input.directoryInputs.each {DirectoryInput dirInput - >
//收集、重定向目录中的クラス
collectAndIdentifyDir(scrInputMap、dirInput、rootOutput、isIncremental)
}
input.jarInputs.each {JarInput jarInput - >
IF(jarInput.getStatus()!
//収集ジャーリダイレクトパケットクラス
collectAndIdentifyJar(jarInputMap、scrInputMap、jarInput、rootOutput、isIncremental)
}
}
}
計装//必要な情報を収集する方法であって、各TraceMethodに計装情報は、オブジェクト
MethodCollector methodCollector =新しいMethodCollectorを(traceConfig、mappingCollector)
HashMapの<文字列、TraceMethod> collectedMethodMap = methodCollector.collect(scrInputMap.keySet()。ToListメソッド()、jarInputMap.keySet()。ToListメソッド())
//計装ロジック、方法に必要な計測を行います入口、出口はMethodBeatのI / Oロジック添加
MethodTracer methodTracer =新しい新しいMethodTracer(traceConfig、collectedMethodMap、methodCollector.getCollectedClassExtendMap(http://www.my516.com))
methodTracer.trace(scrInputMap、jarInputMap)
//元の実行ロジック変換を;デフォルトtransformClassesWithDexBuilderForDebugこのタスクは、クラスデックスに変換されます
origTransform.transform(transformInvocation)
Log.i( "マトリックス" +のgetName()は、 "コストの時間を[変換]:%のDMS"のSystem.currentTimeMillis() -開始します)
}

おすすめ

転載: www.cnblogs.com/ly570/p/11291179.html