简体   繁体   中英

How do I import a class in gradle outside of build.gradle in a apply from: file

I am having a wired issue I am using gradle 1.9

I cannot seem to import a class from outside build.gradle

The following works

build.gradle

buildscript {
    repositories {
        mavenLocal()
    }
    dependencies {
        classpath(group: 'com.foo', name: 'gradle-local-eureka', version: '1.0-SNAPSHOT')
    }
}
import com.foo.my.awesome.package.AwesomeService

The following errors out build.gradle

buildscript {
    repositories {
        mavenLocal()
    }
    dependencies {
        classpath(group: 'com.foo', name: 'gradle-local-eureka', version: '1.0-SNAPSHOT')
    }
}
apply from: file('gradle/foo.gradle')

foo.gradle

import com.foo.my.awesome.package.AwesomeService
// do stuff

I get an unable to resolve class error if I try to import a class outside of build.gradle, does anyone have any insight as to why that wouldn't work or what the proper way of doing this?

尝试将buildscript块移动到gradle/foo.gradle

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