目录
1、transforms路径下首先是各个Transform Task的名字所代表的路径
2、${productFlavor}/${buildType}
1)自定的 Transform Task (StripAarTransform)
2)对于 Proguard Transform Task 来说
4、folders|jars 后面是 ${OutputTypes}
1)自定的 Transform Task (StripAarTransform)
2)对于 Proguard Transform Task 来说
1)自定的 Transform Task (StripAarTransform)
2)对于 Proguard Transform Task 来说
无意中注意到,Transform task 的输出路径,好奇,这么奇怪的路径是怎么生成的?
比如:
Proguard (task 为:transformClassesAndResourcesWithProguardForDebug、transformClassesAndResourcesWithProguardForRelease)的输出路径:
build/intermediates/transforms/proguard/debug/jars/3/1f/main.jar
build/intermediates/transforms/proguard/release/jars/3/1f/main.jar
先给个结论吧:
主要是由 TransformOutputProvider#getContentLocation(name, types, scopes, format) 中的参数决定的!
源码定义在:com.android.build.api.transform.TransformOutputProvider.java:
/**
* The output of a transform.
* <p>
* There is no direct access to a location to write. Instead, Transforms can ask to get the
* location for given scopes, content-types and a format.
*/
public interface TransformOutputProvider {
/**
* Delete all content. This is useful when running in non-incremental mode
* @throws IOException
*/
void deleteAll() throws IOException;
/**
* Returns the location of content for a given set of Scopes, Content Types, and Format.
* <p>
* If the format is {@link Format#DIRECTORY} then the result is the file location of the
* directory.<br>
* If the format is {@link Format#JAR} then the result is a file representing the jar to create.
* <p>
* Non of the directories or files are created by querying this method, and there is
* no checks regarding the existence of content in this location.
* <p>
* In case of incremental processing of removed files, it is safe to query the method to get
* the location of the files to removed.
*
* @param name a unique name for the content. For a given set of scopes/types/format it must
* be unique.
* @param types the content types associated with this content.
* @param scopes the scopes associated with this content.
* @param format the format of the content.
* @return the location of the content.
*/
@NonNull
File getContentLocation(@NonNull String name,
@NonNull Set<QualifiedContent.ContentType> types,
@NonNull Set<? super QualifiedContent.Scope> scopes,
@NonNull Format format);
}
1、transforms路径下首先是各个Transform Task的名字所代表的路径
如:
transforms/dex
transforms/proguard
2、${productFlavor}/${buildType}
proguard下下面,紧接着的路径是:${productFlavor}/${buildType},没有productFlavor就省略,如:
transforms/proguard/qihoo/release/jars/3/1f/main.jar
transforms/proguard/qihoo/debug/jars/3/1f/main.jar
transforms/proguard/xiaomi/release/jars/3/1f/main.jar
transforms/proguard/xiaomi/debug/jars/3/1f/main.jar
3、release后面是 jars 或 folders
如:
release/folders
release/jars
如何确定是 jars 还是 folders?
先给结论:
jars 或 folders 是由 TransformOutputProvider#getContentLocation(name, types, scopes,