Skip to content

Commit

Permalink
Don't check for specific Shadow plugin id (fixes #36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Mar 10, 2024
1 parent 4ea08c9 commit b59f071
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
21 changes: 12 additions & 9 deletions plugin/src/main/kotlin/xyz/jpenilla/runtask/RunPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,20 @@ public abstract class RunPlugin : Plugin<Project> {
}
}

protected open fun findPluginJar(project: Project): Provider<RegularFile>? = when {
project.plugins.hasPlugin(Constants.Plugins.SHADOW_PLUGIN_ID) -> {
project.tasks.named<AbstractArchiveTask>(Constants.Plugins.SHADOW_JAR_TASK_NAME).flatMap { it.archiveFile }
}

else -> {
protected open fun findPluginJar(project: Project): Provider<RegularFile>? {
if (Constants.Plugins.SHADOW_JAR_TASK_NAME in project.tasks.names) {
try {
project.tasks.named<AbstractArchiveTask>(JavaPlugin.JAR_TASK_NAME).flatMap { it.archiveFile }
} catch (ex: UnknownTaskException) {
null
return project.tasks.named<AbstractArchiveTask>(Constants.Plugins.SHADOW_JAR_TASK_NAME).flatMap { it.archiveFile }
} catch (ignore: Exception) {
}
}

return project.defaultJar()
}

private fun Project.defaultJar() = try {
project.tasks.named<AbstractArchiveTask>(JavaPlugin.JAR_TASK_NAME).flatMap { it.archiveFile }
} catch (ex: UnknownTaskException) {
null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ internal object Constants {
const val USER_AGENT = "run-task"

object Plugins {
const val SHADOW_PLUGIN_ID = "com.github.johnrengelman.shadow"
const val SHADOW_JAR_TASK_NAME = "shadowJar"

const val PAPERWEIGHT_USERDEV_PLUGIN_ID = "io.papermc.paperweight.userdev"
Expand Down

0 comments on commit b59f071

Please sign in to comment.