Last active
February 1, 2016 14:35
-
-
Save Piasy/a1bb777a78169c1ec3d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (ResolvedDependency dependency : | |
project.configurations.getByName("compile").resolvedConfiguration.firstLevelModuleDependencies) { | |
// dependency是gradle api定义的依赖,可以获取moduleGroup,moduleName,moduleVersion信息, | |
// 包括maven依赖、本地子module依赖,间接依赖在dependency.children中, | |
// 而这个依赖的本地文件则在dependency.moduleArtifacts中 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (File dependency : project.configurations.getByName("compile").resolve()) { | |
// compile 是依赖选项(configuration), dependency 就是各类依赖解析完毕之后的本地文件,包括直接与间接 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project.extensions.getByName("android").metaPropertyValues.each { prop -> | |
if ("defaultConfig".equals(prop.name)) { | |
ProductFlavor defaultConfigs = (ProductFlavor) prop.value | |
if (defaultConfigs.minSdkVersion != null) { | |
minSdkVersion = defaultConfigs.minSdkVersion.apiLevel | |
} | |
} | |
if ("productFlavors".equals(prop.name)) { | |
if (!"default".equals(flavor)) { | |
for (ProductFlavor productFlavor : | |
((NamedDomainObjectContainer<ProductFlavor>) prop.value).asList()) { | |
if (productFlavor.name.equals(flavor)) { | |
if (productFlavor.minSdkVersion != null) { | |
minSdkVersion = productFlavor.minSdkVersion.apiLevel | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sourceSets { | |
main { | |
compileClasspath += configurations.provided | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment