Dependencies cannot be applied

Hi, I have little problem with IntelliJ. I cannot get my project working. When I paste code from docs to my Gradle file. It just says: " ‘dependencies’ cannot be applied to ‘(groovy.lang.Closure)’ " I really want to start make plugins to Sponge when it’s released. And sorry for my bad english. =(

  • ArtsiX

can you share what’s in your build.gradle file

Oh, sorry. I didn’t remember =P

    repositories {
    mavenCentral()
    maven {
        name 'Sponge maven repo'
        url 'http://repo.spongepowered.org/maven'
    }
}

dependencies {
    compile "org.spongepowered:spongeapi:2.1-SNAPSHOT"
}

ok, I’m going to give this a test then get back to you.

Okay, thanks :smile:

ok, so I wasn’t able to recreate the error. When you started you were in intellij then went to
File --> New --> Project ----> Then selected gradle correct. then went into the build.gradle. did you edit any thing in there

I just edited build.gradle to that code what I just sent.

group 'com.azewilous.spongegradle'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
    mavenCentral()
    maven {
        name 'Sponge maven repo'
        url 'http://repo.spongepowered.org/maven'
    }
}

dependencies {
    compile "org.spongepowered:spongeapi:2.1-SNAPSHOT"
}

try making it look like this except the group is a group you want, and the version is the version of your plugin

This is just a bug in IntelliJ. Ignore, continue as normal.

Ok, thanks for the reply. :smile:

Is it bug too that IntelliJ says that it could not import “org.spongepowered.api.plugin.Plugin”?

No, that sounds like a problem. Could you screenshot the error?

There. When I hover my mouse top of “Plugin” it says: "Cannot resolve symbol ‘Plugin’ "

Post your entire build.gradle?

I already did. :smiley:

repositories {
    mavenCentral()
    maven {
        name 'Sponge maven repo'
        url 'http://repo.spongepowered.org/maven'
    }
}

dependencies {
    compile "org.spongepowered:spongeapi:2.1-SNAPSHOT"
}

Looking at it, your directory setup is odd. It should look like this:

Delete your module from the IDE.

Make sure you are importing your module using the build.gradle file (File -> New -> Module from existing sources). It will cache the build script and generate the dependencies.

Add apply plugin: 'java' to the top. This is what will actually allow your build to compile your project.

In addition, move your source folders to src/main/java instead of src. If you don’t want that folder you can configure it, but sources are required to live there by default

Sorry, I didn’t remember that i updated it. Here is my code now:

group 'fi.artsix.SpongePlugin'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
    mavenCentral()
    maven {
        name 'Sponge maven repo'
        url 'http://repo.spongepowered.org/maven'
    }
}

dependencies {
    compile "org.spongepowered:spongeapi:2.1-SNAPSHOT"
}

Ok, I got it working after remaking project 5 times. :smiley: Thanks for the help.