Skip to content
Permalink
Browse files

Merge pull request #415 from EngineHub/kotlin-dsl

Migrate gradle to kotlin dsl.
  • Loading branch information...
wizjany committed Jul 30, 2019
2 parents 556b638 + cc3f4d4 commit 070f6e005faadbddaddbcfa29d303d63d66c7920
Showing with 477 additions and 283 deletions.
  1. +16 −0 HEADER.txt
  2. +0 −136 build.gradle
  3. +26 −0 build.gradle.kts
  4. +19 −0 buildSrc/build.gradle.kts
  5. +40 −0 buildSrc/src/main/kotlin/ArtifactoryConfig.kt
  6. +18 −0 buildSrc/src/main/kotlin/CommonConfig.kt
  7. +12 −0 buildSrc/src/main/kotlin/GradleExtras.kt
  8. +96 −0 buildSrc/src/main/kotlin/LibsConfig.kt
  9. +119 −0 buildSrc/src/main/kotlin/PlatformConfig.kt
  10. +6 −0 buildSrc/src/main/kotlin/Versions.kt
  11. +0 −6 config/checkstyle/checkstyle.xml
  12. +0 −18 config/checkstyle/header.txt
  13. +2 −0 gradle.properties
  14. +1 −1 gradle/wrapper/gradle-wrapper.properties
  15. +0 −3 settings.gradle
  16. +7 −0 settings.gradle.kts
  17. +0 −55 worldguard-bukkit/build.gradle
  18. +54 −0 worldguard-bukkit/build.gradle.kts
  19. +1 −1 worldguard-bukkit/src/main/resources/plugin.yml
  20. +0 −30 worldguard-core/build.gradle
  21. +31 −0 worldguard-core/build.gradle.kts
  22. +8 −8 worldguard-core/src/main/java/com/sk89q/worldguard/WorldGuard.java
  23. +1 −1 worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionPrintoutBuilder.java
  24. +1 −1 worldguard-core/src/main/java/com/sk89q/worldguard/commands/task/RegionLister.java
  25. +2 −2 worldguard-core/src/main/java/com/sk89q/worldguard/domains/DefaultDomain.java
  26. +2 −2 worldguard-core/src/main/java/com/sk89q/worldguard/protection/managers/migration/UUIDMigration.java
  27. +3 −3 worldguard-core/src/main/java/com/sk89q/worldguard/protection/util/DomainInputResolver.java
  28. +1 −0 worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/BlacklistNotify.java
  29. +1 −0 worldguard-core/src/main/java/com/sk89q/worldguard/util/formatting/component/Notify.java
  30. +3 −0 worldguard-libs/build.gradle.kts
  31. +1 −0 worldguard-libs/bukkit/build.gradle.kts
  32. +6 −0 worldguard-libs/core/build.gradle.kts
  33. +0 −16 worldguard-sponge/build.gradle
@@ -0,0 +1,16 @@
WorldGuard, a suite of tools for Minecraft
Copyright (C) sk89q <http://www.sk89q.com>
Copyright (C) WorldGuard team and contributors

This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

This file was deleted.

@@ -0,0 +1,26 @@
import org.ajoberstar.grgit.Grgit

logger.lifecycle("""
*******************************************
You are building WorldGuard!
If you encounter trouble:
1) Try running 'build' in a separate Gradle run
2) Use gradlew and not gradle
3) If you still need help, ask on Discord! https://discord.gg/enginehub
Output files will be in [subproject]/build/libs
*******************************************
""")

applyRootArtifactoryConfig()

if (!project.hasProperty("gitCommitHash")) {
apply(plugin = "org.ajoberstar.grgit")
ext["gitCommitHash"] = try {
(ext["grgit"] as Grgit?)?.head()?.abbreviatedId
} catch (e: Exception) {
logger.warn("Error getting commit hash", e)

"no_git_id"
}
}
@@ -0,0 +1,19 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version embeddedKotlinVersion
}

repositories {
jcenter()
gradlePluginPortal()
}

dependencies {
implementation(gradleApi())
implementation("gradle.plugin.net.minecrell:licenser:0.4.1")
implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1")
implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0")
implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21")
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
}
@@ -0,0 +1,40 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.named
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask

private const val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
private const val ARTIFACTORY_USER = "artifactory_user"
private const val ARTIFACTORY_PASSWORD = "artifactory_password"

fun Project.applyRootArtifactoryConfig() {
if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""

apply(plugin = "com.jfrog.artifactory")
configure<ArtifactoryPluginConvention> {
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
clientConfig.publisher.run {
repoKey = when {
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
else -> "libs-release-local"
}
username = "${project.property(ARTIFACTORY_USER)}"
password = "${project.property(ARTIFACTORY_PASSWORD)}"
isMaven = true
isIvy = false
}
}
tasks.named<ArtifactoryTask>("artifactoryPublish") {
isSkip = true
}
}

fun Project.applyCommonArtifactoryConfig() {
val named = tasks.named<ArtifactoryTask>("artifactoryPublish") {
publishConfigs("archives")
}
}
@@ -0,0 +1,18 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.repositories

fun Project.applyCommonConfiguration() {
group = rootProject.group
version = rootProject.version

repositories {
mavenCentral()
maven { url = uri("https://maven.sk89q.com/repo/") }
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor(5, "minutes")
}
}
}
@@ -0,0 +1,12 @@
import org.gradle.api.Project
import org.gradle.api.plugins.ExtraPropertiesExtension
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.the

val Project.ext: ExtraPropertiesExtension
get() = extensions.getByType()

val Project.sourceSets: SourceSetContainer
get() = the<JavaPluginConvention>().sourceSets
@@ -0,0 +1,96 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.Project
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.internal.HasConvention
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
import org.gradle.api.tasks.Upload
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getPlugin
import org.gradle.kotlin.dsl.invoke
import org.gradle.kotlin.dsl.register

fun Project.applyLibrariesConfiguration() {
applyCommonConfiguration()
apply(plugin = "java-base")
apply(plugin = "maven")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "com.jfrog.artifactory")

configurations {
create("shade")
getByName("archives").extendsFrom(getByName("default"))
}

group = "${rootProject.group}.worldguard-libs"

tasks.register<ShadowJar>("jar") {
configurations = listOf(project.configurations["shade"])
archiveClassifier.set("")

dependencies {
exclude(dependency("com.google.code.findbugs:jsr305:1.3.9"))
}

relocate("com.sk89q.squirrelid", "com.sk89q.worldguard.util.profile")
}
val altConfigFiles = { artifactType: String ->
val deps = configurations["shade"].incoming.dependencies
.filterIsInstance<ModuleDependency>()
.map { it.copy() }
.map { dependency ->
dependency.artifact {
name = dependency.name
type = artifactType
extension = "jar"
classifier = artifactType
}
dependency
}

files(configurations.detachedConfiguration(*deps.toTypedArray())
.resolvedConfiguration.lenientConfiguration.artifacts
.filter { it.classifier == artifactType }
.map { zipTree(it.file) })
}
tasks.register<Jar>("sourcesJar") {
from({
altConfigFiles("sources")
})
val filePattern = Regex("(.*)com/sk89q/squirrelid((?:/|$).*)")
val textPattern = Regex("com\\.sk89q\\.squirrelid")
eachFile {
filter {
it.replaceFirst(textPattern, "com.sk89q.worldguard.util.profile")
}
path = path.replaceFirst(filePattern, "$1com/sk89q/worldguard/util/profile$2")
}
archiveClassifier.set("sources")
}

tasks.named("assemble").configure {
dependsOn("jar", "sourcesJar")
}

artifacts {
val jar = tasks.named("jar")
add("default", jar) {
builtBy(jar)
}
val sourcesJar = tasks.named("sourcesJar")
add("archives", sourcesJar) {
builtBy(sourcesJar)
}
}

tasks.register<Upload>("install") {
configuration = configurations["archives"]
(repositories as HasConvention).convention.getPlugin<MavenRepositoryHandlerConvention>().mavenInstaller {
pom.version = project.version.toString()
pom.artifactId = project.name
}
}

applyCommonArtifactoryConfig()
}

0 comments on commit 070f6e0

Please sign in to comment.
You can’t perform that action at this time.