Include all configuration when generating metadata

This commit is contained in:
Him188 2020-12-01 10:56:32 +08:00
parent eb7b4b8eb9
commit 22f22bf65c

View File

@ -13,6 +13,7 @@ import com.google.gson.Gson
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.Task import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.TaskContainer import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.bundling.Jar
@ -98,10 +99,15 @@ private fun Project.registerPublishPluginTasks(target: KotlinTarget, isSingleTar
val output = outputs.files.singleFile val output = outputs.files.singleFile
output.parentFile.mkdir() output.parentFile.mkdir()
val dependencies = configurations[target.compilations["main"].apiConfigurationName].allDependencies.map { fun getConfigurationsToInclude(): List<Configuration> {
"${it.group}:${it.name}:${it.version}" val compilation = target.compilations["main"]
return compilation.relatedConfigurationNames.map { configurations[it] }
} }
val dependencies = getConfigurationsToInclude().flatMap { it.allDependencies }.map {
"${it.group}:${it.name}:${it.version}"
}.distinct()
val json = Gson().toJson(PluginMetadata( val json = Gson().toJson(PluginMetadata(
groupId = mirai.publishing.groupId ?: project.group.toString(), groupId = mirai.publishing.groupId ?: project.group.toString(),
artifactId = mirai.publishing.artifactId ?: project.name, artifactId = mirai.publishing.artifactId ?: project.name,
@ -114,6 +120,8 @@ private fun Project.registerPublishPluginTasks(target: KotlinTarget, isSingleTar
output.writeText(json) output.writeText(json)
} }
Unit
} }
val bintrayUpload = tasks.getByName(BintrayUploadTask.getTASK_NAME()).dependsOn( val bintrayUpload = tasks.getByName(BintrayUploadTask.getTASK_NAME()).dependsOn(