-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
602 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import java.util.* | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
`java-library` | ||
kotlin("jvm") version "2.0.0" | ||
id("io.github.goooler.shadow") version "8.1.7" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("com.github.johnrengelman:shadow:8.1.1") | ||
implementation(gradleApi()) | ||
} | ||
|
||
val properties = Properties().also { props -> | ||
project.projectDir.resolveSibling("gradle.properties").bufferedReader().use { | ||
props.load(it) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.sayandev | ||
|
||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.gradle.api.Project | ||
import org.gradle.api.file.DuplicatesStrategy | ||
|
||
fun getProjectRelocations(): List<BuildRelocation> { | ||
return repositories.map { it.dependencies } | ||
.flatten() | ||
.filter { it.relocation != null } | ||
.map { BuildRelocation(it.relocation!!.from, it.relocation.to, it.modules) } | ||
} | ||
|
||
fun Project.getRelocations(): List<BuildRelocation> = getProjectRelocations() | ||
|
||
fun getProjectRelocations(module: Module): List<BuildRelocation> { | ||
return getProjectRelocations().filter { it.relocateModules.contains(module) } | ||
} | ||
|
||
fun Project.getRelocations(module: Module): List<BuildRelocation> = getProjectRelocations(module) | ||
|
||
fun ShadowJar.applyShadowRelocation(module: Module) { | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
getProjectRelocations(module).forEach { relocate -> | ||
relocate(relocate.from, relocate.to) | ||
} | ||
} | ||
|
||
data class BuildRelocation( | ||
val from: String, | ||
val to: String, | ||
val relocateModules: List<Module> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.sayandev | ||
|
||
data class Dependency( | ||
val group: String, | ||
val artifact: String, | ||
val version: String, | ||
val relocation: Relocation?, | ||
val type: Type, | ||
val modules: List<Module>, | ||
val shadeMethod: ShadeMethod = ShadeMethod.DEFAULT, | ||
) { | ||
constructor(dependency: String, relocation: Relocation?, type: Type, modules: List<Module>) : this( | ||
dependency.substringBefore(':'), | ||
dependency.substringAfter(':').substringBefore(':'), | ||
dependency.substringAfterLast(':'), | ||
relocation, | ||
type, | ||
modules | ||
) | ||
|
||
enum class Type(val configurationName: String) { | ||
COMPILE_ONLY("compileOnly"), | ||
IMPLEMENTATION("implementation"), | ||
TEST_IMPLEMENTATION("testImplementation"), | ||
API("api"), | ||
COMPILE_ONLY_API("compileOnlyApi"), | ||
ANNOTATION_PROCESSOR("annotationProcessor"), | ||
} | ||
|
||
enum class ShadeMethod { | ||
DEFAULT, | ||
FORCE, | ||
EXCLUDE, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.sayandev | ||
|
||
enum class Module { | ||
API, | ||
BUKKIT, | ||
VELOCITY, | ||
BUNGEECORD | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.sayandev | ||
|
||
import org.gradle.kotlin.dsl.PluginDependenciesSpecScope | ||
import org.gradle.kotlin.dsl.version | ||
|
||
data class Plugin( | ||
val id: String, | ||
val version: String?, | ||
val modules: List<Module> | ||
) | ||
|
||
fun PluginDependenciesSpecScope.applyPlugins(module: Module) { | ||
plugins.filter { plugin -> plugin.modules.contains(module) }.forEach { plugin -> | ||
if (plugin.version != null) { | ||
id(plugin.id) version plugin.version | ||
} else { | ||
id(plugin.id) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sayandev | ||
|
||
val plugins = listOf( | ||
Plugin( | ||
"xyz.jpenilla.run-velocity", | ||
"2.3.0", | ||
listOf(Module.VELOCITY) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.sayandev | ||
|
||
data class Relocation( | ||
val from: String, | ||
val to: String | ||
) |
Oops, something went wrong.