Could not find method compile() for arguments [com.sparkjava:spark-core:2.9.3] on object of type org.gradle.api.internal.artifacts.dsl
Asked Answered
P

1

10

I am trying to learn spark java web framework. I am using Intellij and created a new project just added a HelloWorld class, but got this error,

Build file '/Users/mingwang/SourceCodes/spark-example/build.gradle' line: 17

A problem occurred evaluating root project 'spark-example'.
> Could not find method compile() for arguments [com.sparkjava:spark-core:2.9.3] 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.

My build.gradle is like

plugins {
    id 'java'
    id 'application'
    id 'com.github.johnrengelman.shadow' version '7.0.0'
}

group 'org.example'
version '1.0-SNAPSHOT'

mainClassName = "HelloWorld"

repositories {
    mavenCentral()
}

dependencies {
    compile "com.sparkjava:spark-core:2.9.3"
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}

test {
    useJUnitPlatform()
}

can anyone help me with it? Thanks.

Palazzo answered 3/5, 2021 at 9:8 Comment(1)
Does this answer your question? Could not find method compile() for arguments GradleDetrude
B
27

The compile statement is deprecated and has been removed in Gradle 7.0. You should use implementation or api instead. The differences are explained in this answer.

In your build.gradle, replace

compile "com.sparkjava:spark-core:2.9.3"

with

implementation "com.sparkjava:spark-core:2.9.3"
Bagpipe answered 5/5, 2021 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.