Dependencies classpath works in eclipse but not in Intellij

Hi all,

I am moving from eclipse to Intellij.

Intellij raises the message

Error:(53, 0) Gradle DSL method not found: ‘classpath()’
Possible causes:

I am using this plugins:
apply plugin: ‘java’
apply plugin: ‘maven’
apply plugin: org.springframework.boot.gradle.SpringBootPlugin
apply plugin: ‘idea’

The error line in the build.gradle file is this one:
classpath(“org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE”)

Here is the related source code:

dependencies {
compile (“org.springframework.boot:spring-boot-starter-web”)

classpath(“org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE”)

compile "com.google.guava:guava:18.0"
compile ("org.ethereum:ethereumj-core:1.0.0-SNAPSHOT"){
    changing=true
    exclude group: "log4j"
    exclude group: "org.slf4j", module: "log4j-over-slf4j"
    exclude group: "org.slf4j", module: "slf4j-log4j12"
}
testCompile group: 'junit', name: 'junit', version: '4.11'

}

Please let me know if you have some suggestion to resolve the error message related with the classpath.

Regards
Skydog

I am using
distributionUrl=https://services.gradle.org/distributions/gradle-2.7-all.zip

There are 2 dependencies in build script.

  • One for project dependency which is required by the project.
  • Another is for build dependency which is required by the build script.

In your case, classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE") is the dependency for build script, and it should be declared in buildscript{} block.

for example…

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE")
  }
}

For more detail the information is available at document ch.62 Organizing Build Logic.

Hi Shinya,

thanks a lot for your reply, but If I put the classpath in the buildsript, I get the same message.

Error:(19, 0) Gradle DSL method not found: ‘classpath()’
Possible causes:

Here is the full build.gradle file:

group 'grpFS001'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: org.springframework.boot.gradle.SpringBootPlugin
apply plugin: 'idea'


sourceCompatibility = 1.5



buildscript {
    repositories {
        mavenCentral()
    }
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE")
}

repositories {

    mavenLocal()
    mavenCentral()
//  maven { url "https://oss.jfrog.org/libs-snapshot/" }
    maven {
        url "https://oss.jfrog.org/libs-snapshot/"
        //    url "http://dl.bintray.com/ethereum/maven"
    }
}

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

configurations.all {
    // check for updates every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
    compile ("org.springframework.boot:spring-boot-starter-web")


//classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE")

    compile "com.google.guava:guava:18.0"
    compile ("org.ethereum:ethereumj-core:1.0.0-SNAPSHOT"){
        changing=true
        exclude group: "log4j"
        exclude group: "org.slf4j", module: "log4j-over-slf4j"
        exclude group: "org.slf4j", module: "slf4j-log4j12"

    }

    testCompile group: 'junit', name: 'junit', version: '4.11'

}

/*
task wrapper(type: Wrapper) {
    gradleVersion = '2.2.1'
}
*/

task stage {
    dependsOn bootRepackage
}

springBoot {
    mainClass = "src.FSBP005"
}

task copyToLib(type: Copy) {
    into "$buildDir/output/lib"
    from configurations.runtime
}
build.dependsOn copyToLib

bootRun {
    jvmArgs = ["-server", "-Xms3g",
               "-Dorg.gradle.debug=true",
               "-Dethereumj.conf.file=/home/FS0006/ethereumj.conf",
               "-Dlogback.configurationFile=/home//FS0006/logback.xml"]
}

dependencies {} block is missing in buildscript{} block.

classpath should be declared at dependencies {} block in buildscript{} block.

Thanks a lot Shinya!