Add Gradle test for KT-51913
This commit is contained in:
+11
@@ -785,4 +785,15 @@ class KotlinGradleIT : KGPBaseTest() {
|
||||
build("tasks")
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-51913: KGP should not add attributes to 'legacy' configurations")
|
||||
@GradleTest
|
||||
fun noAttributesLegacyConfigurations(gradleVersion: GradleVersion) {
|
||||
project(
|
||||
"legacyConfigurationConsumer",
|
||||
gradleVersion
|
||||
) {
|
||||
build(":consumer:aggregate")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
subprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
plugins {
|
||||
id("base")
|
||||
}
|
||||
|
||||
val aggregation by configurations.creating {
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named("custom-aggregation-for-reporting"))
|
||||
attribute(Attribute.of("custom-attribute-type", String::class.java), "custom-attribute-value")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val projectPath = path
|
||||
rootProject.subprojects {
|
||||
if (path != projectPath) {
|
||||
aggregation(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val matches = aggregation.incoming.artifactView { lenient(true) }
|
||||
|
||||
tasks.register("aggregate") {
|
||||
inputs.files(matches.files).withPropertyName("matches")
|
||||
doFirst {
|
||||
matches.files.forEach {
|
||||
if (it.extension != "txt") {
|
||||
throw GradleException("Not a text file: $it")
|
||||
}
|
||||
println("$it: ${it.readText()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("java-library")
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.example.utilities;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
id("base")
|
||||
}
|
||||
|
||||
val publishedFile = layout.buildDirectory.file("publication/output.txt")
|
||||
|
||||
val producerTask by tasks.registering {
|
||||
outputs.file(publishedFile)
|
||||
doLast {
|
||||
publishedFile.get().asFile.writeText("Hello World from ${project.name}")
|
||||
}
|
||||
}
|
||||
|
||||
configurations.create("publication") {
|
||||
isCanBeConsumed = true
|
||||
isCanBeResolved = false
|
||||
outgoing.artifact(producerTask) {
|
||||
builtBy(producerTask)
|
||||
}
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named("custom-aggregation-for-reporting"))
|
||||
attribute(Attribute.of("custom-attribute-type", String::class.java), "custom-attribute-value")
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
rootProject.name = "kotlin-plugin-attributes"
|
||||
|
||||
include("producer")
|
||||
include("consumer")
|
||||
include("kotlin-module")
|
||||
Reference in New Issue
Block a user