Skip to content

Commit

Permalink
Update to v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd authored Dec 4, 2017
2 parents 34817e0 + 00bcf57 commit 36c0ae1
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 143 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "idea"

id "java-gradle-plugin"
id "com.gradle.plugin-publish" version "0.9.7"
id "com.gradle.plugin-publish" version "0.9.9"
}

apply from: "jacoco.gradle"
Expand Down Expand Up @@ -36,4 +36,4 @@ pluginBundle {
description = "Gradle plugin providing integration for plugins made for the Bukkit platform"
}
}
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group=ru.endlesscode
description=Bukkit Gradle integration plugins
version=0.6.9
version=0.7.0
org.gradle.jvmargs=-Xmx3G
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.caching=true
org.gradle.caching=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package ru.endlesscode.bukkitgradle
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.DependencyResolutionListener
import org.gradle.api.artifacts.ResolvableDependencies
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.compile.JavaCompile
import ru.endlesscode.bukkitgradle.util.Dependencies

class BukkitGradlePlugin implements Plugin<Project> {
final static String GROUP = "Bukkit"
final static String GROUP = 'Bukkit'

Project project

Expand Down Expand Up @@ -39,9 +38,9 @@ class BukkitGradlePlugin implements Plugin<Project> {
void addPlugins() {
project.with {
plugins.with {
apply("java")
apply("eclipse")
apply("idea")
apply('java')
apply('eclipse')
apply('idea')
apply(PluginMetaPlugin)
apply(DevServerPlugin)
}
Expand All @@ -57,7 +56,7 @@ class BukkitGradlePlugin implements Plugin<Project> {
*/
void configureEncoding() {
project.tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.encoding = 'UTF-8'
}
}

Expand All @@ -71,13 +70,13 @@ class BukkitGradlePlugin implements Plugin<Project> {
mavenCentral()

maven {
name = "sk89q"
url = "http://maven.sk89q.com/repo/"
name = 'sk89q'
url = 'http://maven.sk89q.com/repo/'
}

maven {
name = "spigot"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
name = 'spigot'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
}
}
Expand All @@ -87,30 +86,6 @@ class BukkitGradlePlugin implements Plugin<Project> {
* Adds needed dependencies
*/
void addDependencies() {
project.gradle.addListener(new DependencyResolutionListener() {
@Override
void beforeResolve(ResolvableDependencies resolvableDependencies) {
addBukkitApi(project)
project.gradle.removeListener(this)
}

@Override
void afterResolve(ResolvableDependencies resolvableDependencies) {}
})
}

/**
* Adds Bukkit API to project dependencies
* @param project The project
*/
static void addBukkitApi(Project project) {
project.with {
def compileOnlyDeps = configurations.compileOnly.dependencies
def testCompileDeps = configurations.testCompile.dependencies
def bukkitDep = dependencies.create("org.bukkit:bukkit:$bukkit.version")

compileOnlyDeps.add(bukkitDep)
testCompileDeps.add(bukkitDep)
}
Dependencies.configureProject(project)
}
}
22 changes: 12 additions & 10 deletions src/main/groovy/ru/endlesscode/bukkitgradle/DevServerPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,33 @@ class DevServerPlugin implements Plugin<Project> {
void apply(Project project) {
this.project = project
ServerCore serverCore = new ServerCore(project)
project.task("runServer", type: RunServer, dependsOn: "prepareServer") {
core serverCore
}.configure {
project.task('runServer', type: RunServer, dependsOn: 'prepareServer') {
group = BukkitGradlePlugin.GROUP
description = 'Run dev server'
core serverCore
}

PrepareServer prepareServer = project.task("prepareServer", type: PrepareServer, dependsOn: ["build", "copyServerCore"]) {
core serverCore
}.configure {
PrepareServer prepareServer = project.task(
'prepareServer',
type: PrepareServer,
dependsOn: ['build', 'buildServerCore', 'copyServerCore']
) {
group = BukkitGradlePlugin.GROUP
description = 'Prepare server ro run. Configure server and copy compiled plugin to plugins dir'
core serverCore
} as PrepareServer

Path runConfigurationsDir = project.projectDir.toPath().resolve(".idea/runConfigurations")
project.task("buildIdeaRun", dependsOn: "prepareServer").doLast {
project.task('buildIdeaRun', dependsOn: 'prepareServer') {
group = BukkitGradlePlugin.GROUP
description = 'Configure IDEA server run configuration'
}.doLast {
if (Files.notExists(runConfigurationsDir.parent)) {
throw new LifecycleExecutionException("This task only for IntelliJ IDEA.")
}

Files.createDirectories(runConfigurationsDir)
prepareServer.run.buildIdeaConfiguration(runConfigurationsDir)
}.configure {
group = BukkitGradlePlugin.GROUP
description = 'Configure IDEA server run configuration'
}

project.afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import ru.endlesscode.bukkitgradle.meta.PluginMeta

class Bukkit {
public static final String NAME = "bukkit"
public static final String DYNAMIC_LATEST = "+"
public static final String LATEST = "+"
public static final String REVISION_SUFFIX = "-R0.1-SNAPSHOT"

private final Project project

String version
String buildtools = ''

final PluginMeta meta
final RunConfiguration run

Expand All @@ -28,7 +30,7 @@ class Bukkit {
* @return Chosen Bukkit version
*/
String getVersion() {
return version ? "$version$REVISION_SUFFIX" : DYNAMIC_LATEST
return version ? "$version$REVISION_SUFFIX" : LATEST
}

void meta(@DelegatesTo(PluginMeta) Closure<?> closure) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import java.nio.file.Files
import java.nio.file.Path

class RunConfiguration {
private static final String DEBUG_ARGS = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
private static
final String DEBUG_ARGS = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"

private Project project

Expand All @@ -27,11 +28,11 @@ class RunConfiguration {
this.eula = false
this.onlineMode = false
this.debug = true
this.encoding = "UTF-8"
this.dir = "server"
this.encoding = 'UTF-8'
this.dir = 'server'

this.javaArgs = "-Xmx1G"
this.bukkitArgs = ""
this.javaArgs = '-Xmx1G'
this.bukkitArgs = ''
}

/**
Expand All @@ -40,7 +41,7 @@ class RunConfiguration {
* @return Java arguments
*/
String getJavaArgs() {
return "${this.debug ? "$DEBUG_ARGS " : ""}-Dfile.encoding=$encoding ${this.javaArgs}"
return "${this.debug ? "$DEBUG_ARGS " : ''}-Dfile.encoding=$encoding ${this.javaArgs}"
}

/**
Expand All @@ -49,7 +50,7 @@ class RunConfiguration {
* @return Bukkit arguments
*/
String getBukkitArgs() {
return bukkitArgs ?: ""
return bukkitArgs ?: ''
}

/**
Expand All @@ -71,7 +72,7 @@ class RunConfiguration {
return
}

def taskName = "Run Server"
def taskName = 'Run Server'
def serverDir = (project.tasks.prepareServer as PrepareServer).serverDir.toRealPath()
def args = this.bukkitArgs

Expand All @@ -80,17 +81,29 @@ class RunConfiguration {
def props = this.getJavaArgs()
this.debug = realDebug

def runConfiguration = configurationDir.resolve("${taskName.replace(" ", "_")}.xml")
def runConfiguration = configurationDir.resolve("${taskName.replace(' ', '_')}.xml")
def xml = new MarkupBuilder(runConfiguration.newWriter())
xml.component(name: "ProjectRunConfigurationManager") {
configuration(default: 'false', name: taskName, type: "JarApplication", factoryName: "JAR Application", singleton: "true") {
xml.component(name: 'ProjectRunConfigurationManager') {
configuration(
default: 'false',
name: taskName,
type: 'JarApplication',
factoryName: 'JAR Application',
singleton: 'true'
) {
option(name: 'JAR_PATH', value: "${serverDir.resolve(ServerCore.CORE_NAME)}")
option(name: 'VM_PARAMETERS', value: props)
option(name: 'PROGRAM_PARAMETERS', value: args)
option(name: 'WORKING_DIRECTORY', value: serverDir)
envs()
method {
option(name: "Gradle.BeforeRunTask", enabled: "true", tasks: "prepareServer", externalProjectPath: '$PROJECT_DIR$', vmOptions: "", scriptParameters: "")
option(
name: 'Gradle.BeforeRunTask',
enabled: 'true',
tasks: 'prepareServer',
externalProjectPath: '$PROJECT_DIR$',
vmOptions: '',
scriptParameters: '')
}
}
}
Expand Down
Loading

0 comments on commit 36c0ae1

Please sign in to comment.