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?
Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.
#1 Use 'apply' to structure the script content In Gradle apply command can be used to apply not only plugins, but also script files (*). In this way you can divide your main build. gradle file into smaller parts, and move extra tasks like jacoco report and findbugs to the separate files.
A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive. You can obtain a FileTree instance using Project.
Try to move the buildscript
block into gradle/foo.gradle
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With