Skip to content

Commit

Permalink
Add project description setter
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Jun 21, 2023
1 parent f386849 commit 591c976
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import xyz.srnyx.gradlegalaxy.enums.mavenQuick
fun Project.spigotAPI(versionString: String): String {
check(hasJavaPlugin()) { "Java plugin is not applied!" }
// Java version
getJavaVersionForMC(versionString)?.let { setJavaVersion(it) }
getJavaVersionForMC(versionString)?.let(::setJavaVersion)
// Repositories
val version = SemanticVersion(versionString)
if (version.major <= 1 && version.minor <= 15) repositories.mavenQuick(Repository.SONATYPE_SNAPSHOTS_OLD)
Expand All @@ -42,7 +42,7 @@ fun Project.spigotAPI(versionString: String): String {
fun Project.spigotNMS(versionString: String): String {
check(hasJavaPlugin()) { "Java plugin is not applied!" }
// Java version
getJavaVersionForMC(versionString)?.let { setJavaVersion(it) }
getJavaVersionForMC(versionString)?.let(::setJavaVersion)
// Repositories
repositories.mavenQuick(Repository.MAVEN_CENTRAL, Repository.SPIGOT)
repositories.mavenLocal()
Expand All @@ -58,7 +58,7 @@ fun Project.spigotNMS(versionString: String): String {
fun Project.paper(version: String): String {
check(hasJavaPlugin()) { "Java plugin is not applied!" }
// Java version
getJavaVersionForMC(version)?.let { setJavaVersion(it) }
getJavaVersionForMC(version)?.let(::setJavaVersion)
// Repositories
repositories.mavenQuick(Repository.MAVEN_CENTRAL, Repository.SONATYPE_SNAPSHOTS_OLD, Repository.PAPER)
// Dependency
Expand Down
12 changes: 9 additions & 3 deletions src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun Project.getDefaultReplacements(): Map<String, String> = mapOf(
"group" to group.toString(),
"name" to name,
"version" to version.toString(),
"description" to (description ?: "")
"description" to description.toString(),
)

/**
Expand Down Expand Up @@ -170,6 +170,7 @@ fun Project.relocate(
*
* @param group The group of the project (example: `xyz.srnyx`)
* @param version The version of the project (example: `1.0.0`)
* @param description The description of the project
* @param javaVersion The java version of the project (example: [JavaVersion.VERSION_1_8])
* @param textEncoding The text encoding for the [text encoding task][setTextEncoding]
* @param archiveClassifier The archive classifier for the [shadow jar][setShadowArchiveClassifier]
Expand All @@ -178,12 +179,14 @@ fun Project.relocate(
fun Project.setupJava(
group: String = project.group.toString(),
version: String = project.version.toString(),
description: String? = project.description,
javaVersion: JavaVersion? = null,
textEncoding: String? = "UTF-8",
archiveClassifier: String? = "",
) {
this.group = group
this.version = version
this.description = description
javaVersion?.let(::setJavaVersion)
textEncoding?.let(::setTextEncoding)
if (hasShadowPlugin()) {
Expand All @@ -199,6 +202,7 @@ fun Project.setupJava(
*
* @param group The group of the project (example: `xyz.srnyx`)
* @param version The version of the project (example: `1.0.0`)
* @param description The description of the project
* @param dependency The dependency to add to the project (using `compileOnly`)
* @param javaVersion The java version of the project (example: [JavaVersion.VERSION_1_8])
* @param replacements The replacements for the [replacements task][addReplacementsTask]
Expand All @@ -209,13 +213,14 @@ fun Project.setupJava(
fun Project.setupMC(
group: String = project.group.toString(),
version: String = project.version.toString(),
description: String? = project.description,
dependency: String? = null,
javaVersion: JavaVersion? = null,
replacements: Map<String, String>? = getSentinelReplacements(),
textEncoding: String? = "UTF-8",
archiveClassifier: String? = "",
) {
setupJava(group, version, javaVersion, textEncoding, archiveClassifier)
setupJava(group, version, description, javaVersion, textEncoding, archiveClassifier)
dependency?.let { dependencies.add("compileOnly", it) }
replacements?.let(::addReplacementsTask)
}
Expand Down Expand Up @@ -243,14 +248,15 @@ fun Project.setupAnnoyingAPI(
annoyingAPIVersion: String,
group: String = project.group.toString(),
version: String = project.version.toString(),
description: String? = project.description,
dependency: String? = null,
javaVersion: JavaVersion? = null,
replacements: Map<String, String>? = getSentinelReplacements(),
textEncoding: String? = "UTF-8",
artifactClassifier: String? = "",
) {
check(hasShadowPlugin()) { "Shadow plugin is required for Annoying API!" }
setupMC(group, version, dependency, javaVersion, replacements, textEncoding, artifactClassifier)
setupMC(group, version, dependency, description, javaVersion, replacements, textEncoding, artifactClassifier)
repositories { mavenQuick(Repository.JITPACK) }
dependencies { add("implementation", "xyz.srnyx:annoying-api:$annoyingAPIVersion") }
relocate("xyz.srnyx.annoyingapi")
Expand Down

0 comments on commit 591c976

Please sign in to comment.