Could not find method api() for arguments "some:dependency" w Gradle

0

Struktura mojego projektu wygląda tak: https://zapodaj.net/d96c686a2cabe.png.html. Istnieją 4 pliki build.gradle. Jeden ogólny w projekcie i po jednym dla każdego modułu. Główny plik build.gradle wygląda tak Web REST -> build.gradle

buildscript {
    ext {
        springBootVersion = '2.0.0.RELEASE'
    }
    repositories {
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

def javaProjects = subprojects.findAll {
    it.name == "common" & it.name == "core" && it.name == "web"
}

allprojects {
    apply plugin: 'idea'
    apply plugin: 'eclipse'

    repositories {
        jcenter()
    }
}

idea {
    project {
        jdkName = "1.8"
        languageLevel = "1.8"
        vcs = "Git"
    }
}

configure(javaProjects) {
    apply plugin: 'java'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    dependencies {
        ...
    }
}

Plik build.gradle w module common wygląda tak: REST-Web-Service -> common -> build.gradle

group = 'com.common'


dependencies {
    /*******************************
     * API Dependencies
     *******************************/

    api("com.fasterxml.jackson.core:jackson-databind")
    api("org.hibernate:hibernate-validator")

    /*******************************
     * Implementation Dependencies
     *******************************/

    implementation("com.google.guava:guava")

    /*******************************
     * Compile Dependencies
     *******************************/

    compile group: 'commons-validator', name: 'commons-validator', version: '1.6'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.6'

    // Swagger Libs
    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
    //
}

Podczas budowania projektu za pomocą narzędzia Gradle pojawia się błąd

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\common\build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':common'.
> Could not find method api() for arguments [com.fasterxml.jackson.core:jackson-databind] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
Could not find method api() for arguments [com.fasterxml.jackson.core:jackson-databind] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
0

Jeśli chcesz używać konfiguracji api oraz implementation, musisz użyć bardziej wyspecjalizowanej wtyczki do Javy: java-library zamiast java.

https://docs.gradle.org/current/userguide/java_library_plugin.html

1 użytkowników online, w tym zalogowanych: 0, gości: 1