Skip to content

Commit ba8a4aa

Browse files
committed
Fix error with multiplatform projects
1 parent ca82b70 commit ba8a4aa

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed

build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "dev.arbjerg"
8-
version = "1.1.1"
8+
version = "1.1.2"
99

1010
repositories {
1111
mavenCentral()
@@ -15,6 +15,10 @@ kotlin {
1515
jvmToolchain(17)
1616
}
1717

18+
dependencies {
19+
compileOnly(kotlin("gradle-plugin"))
20+
}
21+
1822
gradlePlugin {
1923
plugins {
2024
create("lavalink-gradle-plugin") {

src/main/kotlin/LavalinkGradlePlugin.kt

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import dev.arbjerg.lavalink.gradle.tasks.*
44
import org.gradle.api.Plugin
55
import org.gradle.api.Project
66
import org.gradle.api.artifacts.Dependency
7-
import org.gradle.api.artifacts.ProjectDependency
8-
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
97
import org.gradle.api.provider.Provider
108
import org.gradle.api.publish.PublishingExtension
119
import org.gradle.api.publish.maven.MavenPublication
@@ -101,38 +99,44 @@ private fun Project.configureTasks(serverDependency: Provider<Dependency>) {
10199
dependsOn(generatePluginProperties)
102100
}
103101

104-
val jar = named<Jar>("jar") {
102+
val jar by named<Jar>("jar") {
105103
configurations.getByName("runtimeClasspath")
106104
.incoming
107105
.artifactView {
108-
componentFilter { it is ProjectComponentIdentifier }
106+
// componentFilter { it !is ProjectComponentIdentifier }
109107
}.artifacts
110108
.forEach {
111-
from(zipTree(it)) {
109+
from(zipTree(it.file)) {
112110
exclude("META-INF/**")
113111
}
114112
}
115113

116-
configurations.getByName("runtimeClasspath")
117-
.allDependencies
118-
.filterIsInstance<ProjectDependency>()
119-
.forEach { dependency ->
120-
val project = dependency.dependencyProject
121-
if (project.plugins.hasPlugin("org.jetbrains.kotlin.multiplatform") && project.tasks.findByName("jvmMainClasses") != null) {
122-
dependsOn(project.tasks.named("jvmMainClasses"))
123-
from(project.layout.buildDirectory.file("classes/kotlin/jvm/main")) {
124-
include("**/*.class")
125-
}
126-
} else {
127-
dependsOn(project.tasks.named("classes"))
128-
from(project.layout.buildDirectory.dir("classes")) {
129-
include("**/main/**/*.class")
130-
eachFile {
131-
path = path.substringAfter("main/")
132-
}
133-
}
134-
}
135-
}
114+
// configurations.getByName("runtimeClasspath")
115+
// .allDependencies
116+
// .filterIsInstance<ProjectDependency>()
117+
// .forEach { dependency ->
118+
// val project = dependency.dependencyProject
119+
// if (project.plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
120+
// val compilationName = provider {
121+
// project.extensions.getByType<KotlinMultiplatformExtension>()
122+
// .targets
123+
// .first { it is KotlinJvmTarget }
124+
// .name
125+
// }
126+
// dependsOn(compilationName.flatMap { project.tasks.named("${it}MainClasses") })
127+
// from(compilationName.flatMap { targetName -> project.layout.buildDirectory.file("classes/kotlin/$targetName/main") }) {
128+
// include("**/*.class")
129+
// }
130+
// } else {
131+
// dependsOn(project.tasks.named("classes"))
132+
// from(project.layout.buildDirectory.dir("classes")) {
133+
// include("**/main/**/*.class")
134+
// eachFile {
135+
// path = path.substringAfter("main/")
136+
// }
137+
// }
138+
// }
139+
// }
136140
}
137141

138142
val installPlugin by registering(Copy::class) {

0 commit comments

Comments
 (0)