From 9d68cd8380fd08bbf4fabcaf8651a08b6dc7d010 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 19 Sep 2021 22:50:34 +0200 Subject: [PATCH] Automatic deployment (#1298) * Fixes #992 * Address asterisk imports * Deploy sources jar & javador jar as well * Merge branch 'main' into feature/main/automaticDeployment --- .editorconfig | 4 +- buildSrc/src/main/kotlin/LibsConfig.kt | 77 +++++++++++++- buildSrc/src/main/kotlin/PlatformConfig.kt | 114 +++++++++++++++++---- gradle.properties | 2 +- 4 files changed, 172 insertions(+), 25 deletions(-) diff --git a/.editorconfig b/.editorconfig index f72383ca5..e584ea6f5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -932,8 +932,8 @@ ij_kotlin_method_call_chain_wrap = off ij_kotlin_method_parameters_new_line_after_left_paren = false ij_kotlin_method_parameters_right_paren_on_new_line = false ij_kotlin_method_parameters_wrap = off -ij_kotlin_name_count_to_use_star_import = 5 -ij_kotlin_name_count_to_use_star_import_for_members = 3 +ij_kotlin_name_count_to_use_star_import = 500 +ij_kotlin_name_count_to_use_star_import_for_members = 300 ij_kotlin_parameter_annotation_wrap = off ij_kotlin_space_after_comma = true ij_kotlin_space_after_extend_colon = true diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt index d8ba77c59..09d5d3c66 100644 --- a/buildSrc/src/main/kotlin/LibsConfig.kt +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -17,9 +17,9 @@ import org.gradle.api.tasks.bundling.Jar import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.getPlugin import org.gradle.kotlin.dsl.invoke import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.register import javax.inject.Inject @@ -162,6 +162,81 @@ fun Project.applyLibrariesConfiguration() { publications { register("maven") { from(libsComponent) + + group = "com.fastasyncworldedit" + artifactId = "${rootProject.name}-Libs" + version = version + + pom { + name.set("${rootProject.name}-Libs" + " " + project.version) + description.set("Blazingly fast Minecraft world manipulation for artists, builders and everyone else.") + url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit") + + licenses { + license { + name.set("GNU General Public License, Version 3.0") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") + } + } + + developers { + developer { + id.set("NotMyFault") + name.set("NotMyFault") + email.set("contact@notmyfault.dev") + organization.set("IntellectualSites") + } + developer { + id.set("SirYwell") + name.set("Hannes Greule") + organization.set("IntellectualSites") + } + developer { + id.set("dordsor21") + name.set("dordsor21") + organization.set("IntellectualSites") + } + } + + scm { + url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit") + connection.set("scm:https://IntellectualSites@github.com/IntellectualSites/FastAsyncWorldEdit.git") + developerConnection.set("scm:git://github.com/IntellectualSites/FastAsyncWorldEdit.git") + } + + issueManagement { + system.set("GitHub") + url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit/issues") + } + } + } + } + + repositories { + mavenLocal() + val nexusUsername: String? by project + val nexusPassword: String? by project + if (nexusUsername != null && nexusPassword != null) { + maven { + val releasesRepositoryUrl = "https://mvn.intellectualsites.com/content/repositories/releases/" + val snapshotRepositoryUrl = "https://mvn.intellectualsites.com/content/repositories/snapshots/" + /* Commenting this out for now - Fawe currently does not user semver or any sort of versioning that + differentiates between snapshots and releases, API & (past) deployment wise, this will come with a next major release. + url = uri( + if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl + else releasesRepositoryUrl + ) + */ + url = uri(releasesRepositoryUrl) + + credentials { + username = nexusUsername + password = nexusPassword + } + } + } else { + logger.warn("No nexus repository is added; nexusUsername or nexusPassword is null.") } } } diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 743f34347..609572380 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -1,17 +1,24 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.Project import org.gradle.api.attributes.java.TargetJvmVersion +import org.gradle.api.component.AdhocComponentWithVariants +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.api.tasks.testing.Test import org.gradle.external.javadoc.StandardJavadocDocletOptions import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.getByName import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.the import org.gradle.kotlin.dsl.withType fun Project.applyPlatformAndCoreConfiguration() { @@ -84,35 +91,100 @@ fun Project.applyPlatformAndCoreConfiguration() { } } - tasks.register("javadocJar") { - dependsOn("javadoc") - archiveClassifier.set(null as String?) - archiveFileName.set("${rootProject.name}-${project.description}-${project.version}-javadoc.${archiveExtension.getOrElse("jar")}") - from(tasks.getByName("javadoc").destinationDir) + configure { + disableAutoTargetJvm() + withJavadocJar() } - tasks.named("assemble").configure { - dependsOn("javadocJar") + if (name in setOf("worldedit-core", "worldedit-bukkit", "worldedit-cli")) { + the().withSourcesJar() } - artifacts { - add("archives", tasks.named("jar")) - add("archives", tasks.named("javadocJar")) + val javaComponent = components["java"] as AdhocComponentWithVariants + javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { + skip() } - if (name == "worldedit-core" || name == "worldedit-bukkit") { - tasks.register("sourcesJar") { - dependsOn("classes") - archiveClassifier.set(null as String?) - archiveFileName.set("${rootProject.name}-${project.description}-${project.version}-sources.${archiveExtension.getOrElse("jar")}") - from(sourceSets["main"].allSource) + configure { + publications { + register("maven") { + from(javaComponent) + + group = "com.fastasyncworldedit" + artifactId = "${rootProject.name}-${project.description}" + version = version + + pom { + name.set("${rootProject.name}-${project.description}" + " " + project.version) + description.set("Blazingly fast Minecraft world manipulation for artists, builders and everyone else.") + url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit") + + licenses { + license { + name.set("GNU General Public License, Version 3.0") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") + } + } + + developers { + developer { + id.set("NotMyFault") + name.set("NotMyFault") + email.set("contact@notmyfault.dev") + organization.set("IntellectualSites") + } + developer { + id.set("SirYwell") + name.set("Hannes Greule") + organization.set("IntellectualSites") + } + developer { + id.set("dordsor21") + name.set("dordsor21") + organization.set("IntellectualSites") + } + } + + scm { + url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit") + connection.set("scm:https://IntellectualSites@github.com/IntellectualSites/FastAsyncWorldEdit.git") + developerConnection.set("scm:git://github.com/IntellectualSites/FastAsyncWorldEdit.git") + } + + issueManagement{ + system.set("GitHub") + url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit/issues") + } + } + } } - artifacts { - add("archives", tasks.named("sourcesJar")) - } - tasks.named("assemble").configure { - dependsOn("sourcesJar") + repositories { + mavenLocal() + val nexusUsername: String? by project + val nexusPassword: String? by project + if (nexusUsername != null && nexusPassword != null) { + maven { + val releasesRepositoryUrl = "https://mvn.intellectualsites.com/content/repositories/releases/" + val snapshotRepositoryUrl = "https://mvn.intellectualsites.com/content/repositories/snapshots/" + /* Commenting this out for now - Fawe currently does not user semver or any sort of versioning that + differentiates between snapshots and releases, API & (past) deployment wise, this will come with a next major release. + url = uri( + if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl + else releasesRepositoryUrl + ) + */ + url = uri(releasesRepositoryUrl) + + credentials { + username = nexusUsername + password = nexusPassword + } + } + } else { + logger.warn("No nexus repository is added; nexusUsername or nexusPassword is null.") + } } } diff --git a/gradle.properties b/gradle.properties index ddafaabb0..38b892464 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -group=com.sk89q.worldedit +group=com.fastasyncworldedit org.gradle.jvmargs=-Xmx1512M org.gradle.daemon=true