diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index abace72..394febb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip diff --git a/plugin/src/main/groovy/digital/wup/android_maven_publish/AndroidVariantLibrary.groovy b/plugin/src/main/groovy/digital/wup/android_maven_publish/AndroidVariantLibrary.groovy index f654688..53325c5 100644 --- a/plugin/src/main/groovy/digital/wup/android_maven_publish/AndroidVariantLibrary.groovy +++ b/plugin/src/main/groovy/digital/wup/android_maven_publish/AndroidVariantLibrary.groovy @@ -21,6 +21,7 @@ import com.google.common.collect.Sets import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ConfigurationContainer import org.gradle.api.artifacts.DependencyConstraint +import org.gradle.api.artifacts.ExcludeRule import org.gradle.api.artifacts.ModuleDependency import org.gradle.api.artifacts.PublishArtifact import org.gradle.api.attributes.AttributeContainer @@ -68,6 +69,7 @@ final class AndroidVariantLibrary implements SoftwareComponentInternal { private def dependencies private def dependencyConstraints private def capabilities + private def excludeRules CompileUsage(ConfigurationContainer configurations, ImmutableAttributesFactory attributesFactory, PublishConfiguration publishConfiguration, Usage usage) { super(configurations, attributesFactory, publishConfiguration, usage) @@ -91,16 +93,8 @@ final class AndroidVariantLibrary implements SoftwareComponentInternal { Set getDependencyConstraints() { if (dependencyConstraints == null) { def apiElements = publishConfiguration.publishConfig + JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME.capitalize() - def incoming = configurations.getByName(apiElements).getIncoming() - - if (incoming.metaClass.respondsTo(incoming, 'getDependencyConstraints')) { - // Gradle 4.6 - dependencyConstraints = incoming.getDependencyConstraints() - } else { - // Gradle 4.5 - dependencyConstraints = incoming.getDependencies().withType(DependencyConstraint) - } + dependencyConstraints = incoming.getDependencyConstraints() } return dependencyConstraints } @@ -115,6 +109,15 @@ final class AndroidVariantLibrary implements SoftwareComponentInternal { } return capabilities } + + @Override + Set getGlobalExcludes() { + if (excludeRules == null) { + def apiElements = publishConfiguration.publishConfig + JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME.capitalize() + excludeRules = ImmutableSet.copyOf(configurations.getByName(apiElements).getExcludeRules()) + } + return excludeRules + } } private static class RuntimeUsage extends BaseUsage { @@ -122,6 +125,7 @@ final class AndroidVariantLibrary implements SoftwareComponentInternal { private def dependencies private def dependencyConstraints private def capabilities + private def excludeRules RuntimeUsage(ConfigurationContainer configurations, ImmutableAttributesFactory attributesFactory, PublishConfiguration publishConfiguration, Usage usage) { super(configurations, attributesFactory, publishConfiguration, usage) @@ -146,14 +150,7 @@ final class AndroidVariantLibrary implements SoftwareComponentInternal { if (dependencyConstraints == null) { def runtimeElements = publishConfiguration.publishConfig + JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME.capitalize() def incoming = configurations.getByName(runtimeElements).getIncoming() - - if (incoming.metaClass.respondsTo(incoming, 'getDependencyConstraints')) { - // Gradle 4.6+ - dependencyConstraints = incoming.getDependencyConstraints() - } else { - // Gradle 4.5 - dependencyConstraints = incoming.getDependencies().withType(DependencyConstraint) - } + dependencyConstraints = incoming.getDependencyConstraints() } return dependencyConstraints } @@ -168,6 +165,15 @@ final class AndroidVariantLibrary implements SoftwareComponentInternal { } return capabilities } + + @Override + Set getGlobalExcludes() { + if (excludeRules == null) { + def runtimeElements = publishConfiguration.publishConfig + JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME.capitalize() + excludeRules = ImmutableSet.copyOf(configurations.getByName(runtimeElements).getExcludeRules()) + } + return excludeRules + } } private static abstract class BaseUsage implements UsageContext {