简体   繁体   中英

Common code from build.gradle(Module) extract into top-level build.gradle(Project)

my IDE is android studio 2.2

i want to extract the common code from build.gradle(Module) into top-level build.gradle(Project) for common use.

i tried subprojects block as below, but it not work:

subprojects {

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'org.aspectj:aspectjtools:1.8.9'
            classpath 'org.aspectj:aspectjweaver:1.8.9'
        }
    }
    dependencies {
        compile 'org.aspectj:aspectjrt:1.8.9'
    }
}

i get this error:

Could not find method compile() for arguments [org.aspectj:aspectjrt:1.8.9] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

my finally solution:

create a gradle plugin to do this work, just like this . tanks JakeWharton, thanks Hugo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM