Skip to content

Instantly share code, notes, and snippets.

@Piasy
Last active February 1, 2016 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piasy/a1bb777a78169c1ec3d2 to your computer and use it in GitHub Desktop.
Save Piasy/a1bb777a78169c1ec3d2 to your computer and use it in GitHub Desktop.
for (ResolvedDependency dependency :
project.configurations.getByName("compile").resolvedConfiguration.firstLevelModuleDependencies) {
// dependency是gradle api定义的依赖,可以获取moduleGroup,moduleName,moduleVersion信息,
// 包括maven依赖、本地子module依赖,间接依赖在dependency.children中,
// 而这个依赖的本地文件则在dependency.moduleArtifacts中
}
for (File dependency : project.configurations.getByName("compile").resolve()) {
// compile 是依赖选项(configuration), dependency 就是各类依赖解析完毕之后的本地文件,包括直接与间接
}
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
}
}
}
}
}
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment