Merge branch '2.5.x' into 2.6.x

See gh-28878
pull/28902/head
Andy Wilkinson 3 years ago
commit f0f0aa5c46

@ -38,6 +38,7 @@ import org.gradle.api.artifacts.VariantMetadata;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier; import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
import org.gradle.api.artifacts.result.ResolvedArtifactResult; import org.gradle.api.artifacts.result.ResolvedArtifactResult;
import org.gradle.api.attributes.DocsType; import org.gradle.api.attributes.DocsType;
import org.gradle.api.attributes.Usage;
import org.gradle.api.file.CopySpec; import org.gradle.api.file.CopySpec;
import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.model.ObjectFactory; import org.gradle.api.model.ObjectFactory;
@ -296,13 +297,16 @@ public class MavenPluginPlugin implements Plugin<Project> {
public void execute(ComponentMetadataContext context) { public void execute(ComponentMetadataContext context) {
context.getDetails().maybeAddVariant("compileWithMetadata", "compile", context.getDetails().maybeAddVariant("compileWithMetadata", "compile",
(variant) -> configureVariant(context, variant)); (variant) -> configureVariant(context, variant));
context.getDetails().maybeAddVariant("runtimeElementsWithMetadata", "runtimeElements", context.getDetails().maybeAddVariant("apiElementsWithMetadata", "apiElements",
(variant) -> configureVariant(context, variant)); (variant) -> configureVariant(context, variant));
} }
private void configureVariant(ComponentMetadataContext context, VariantMetadata variant) { private void configureVariant(ComponentMetadataContext context, VariantMetadata variant) {
variant.attributes((attributes) -> attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE, variant.attributes((attributes) -> {
this.objects.named(DocsType.class, "maven-repository"))); attributes.attribute(DocsType.DOCS_TYPE_ATTRIBUTE,
this.objects.named(DocsType.class, "maven-repository"));
attributes.attribute(Usage.USAGE_ATTRIBUTE, this.objects.named(Usage.class, "maven-repository"));
});
variant.withFiles((files) -> { variant.withFiles((files) -> {
ModuleVersionIdentifier id = context.getDetails().getId(); ModuleVersionIdentifier id = context.getDetails().getId();
files.addFile(id.getName() + "-" + id.getVersion() + ".pom"); files.addFile(id.getName() + "-" + id.getVersion() + ".pom");

Loading…
Cancel
Save