Assistance with Gradle Multi-Project Setup

I’d like to start off by stating that I’m a Gradle noob, so I know almost nothing about it. I’m trying to make a plugin semi-dependent on another plugin that I’m developing, however, I cannot seem to make gradle’s build task cooperate with this.

After hours of research, I have come up with somewhat of a solution, to have [Project1] semi-dependent on [Project2]. It does not work, however, and gives me the following error message:

Plugin ‘org.spongepowered.plugin’ is already on the script classpath. Plugins on the script classpath cannot be applied in the plugins {} block. Add “apply plugin: ‘org.spongepowered.plugin’” to the body of the script to use the plugin.

I have replaced my project names with [Project1] and [Project2] to generalize them. My current gradle files are shown below:

[Project1] Build.Gradle

plugins {
    id 'org.spongepowered.plugin' version '0.8.1'
}

group = 'com.risingcolonies'
version = '1.0-SNAPSHOT'
description = 'Project 1'

dependencies {
    compile 'org.spongepowered:spongeapi:7.0.0'
   	compile project(':[Project 2]')
}

[Project1] settings.gradle

rootProject.name = '[Project1]'
include ':[Project2]'
project(':[Project2]').projectDir = new File(settingsDir, '../[Project2]')

[Project2] build.gradle

plugins {
id ‘org.spongepowered.plugin’ version ‘0.8.1’
}

group = ‘net.worldofclucky’
version = ‘1.0-SNAPSHOT’
description = ‘A region selection resource focusing on using tools, but also allowing for commands’

dependencies {
compile ‘org.spongepowered:spongeapi:7.0.0’
}

1 Like