diff --git a/src/main/groovy/nebula/plugin/publishing/verification/PublishVerificationPlugin.groovy b/src/main/groovy/nebula/plugin/publishing/verification/PublishVerificationPlugin.groovy index 075511c..6e45259 100644 --- a/src/main/groovy/nebula/plugin/publishing/verification/PublishVerificationPlugin.groovy +++ b/src/main/groovy/nebula/plugin/publishing/verification/PublishVerificationPlugin.groovy @@ -57,7 +57,7 @@ class PublishVerificationPlugin implements Plugin { void execute(VerifyPublicationTask verifyPublicationTask) { verifyPublicationTask.projectName.set(project.name) verifyPublicationTask.targetStatus.set(project.status.toString()) - verifyPublicationTask.runtimeClasspath.set(project.configurations.named(sourceSet.getRuntimeClasspathConfigurationName())) + verifyPublicationTask.resolvedComponentResultProvider = project.configurations.named(sourceSet.getRuntimeClasspathConfigurationName()).get().incoming.resolutionResult.rootComponent verifyPublicationTask.ignore.set(extension.ignore) verifyPublicationTask.ignoreGroups.set(extension.ignoreGroups) verifyPublicationTask.verificationViolationsCollectorHolderExtension.set(verificationViolationsCollectorHolderExtension) diff --git a/src/main/groovy/nebula/plugin/publishing/verification/VerifyPublicationTask.groovy b/src/main/groovy/nebula/plugin/publishing/verification/VerifyPublicationTask.groovy index 889b1ea..d3642f9 100644 --- a/src/main/groovy/nebula/plugin/publishing/verification/VerifyPublicationTask.groovy +++ b/src/main/groovy/nebula/plugin/publishing/verification/VerifyPublicationTask.groovy @@ -4,10 +4,12 @@ import org.gradle.api.DefaultTask import org.gradle.api.artifacts.* import org.gradle.api.artifacts.component.ProjectComponentIdentifier import org.gradle.api.artifacts.result.DependencyResult +import org.gradle.api.artifacts.result.ResolvedComponentResult import org.gradle.api.artifacts.result.ResolvedDependencyResult import org.gradle.api.artifacts.result.UnresolvedDependencyResult import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Classpath import org.gradle.api.tasks.Input @@ -28,13 +30,12 @@ abstract class VerifyPublicationTask extends DefaultTask { @Input abstract Property getTargetStatus() - @InputFiles - @Classpath - abstract Property getRuntimeClasspath() - @Input abstract Property getProjectName() + @Internal + Provider resolvedComponentResultProvider + @Input abstract ListProperty getDefinedDependencies() @@ -47,7 +48,7 @@ abstract class VerifyPublicationTask extends DefaultTask { @TaskAction void verifyDependencies() { - Set firstLevel = getNonProjectDependencies(runtimeClasspath.get()) + Set firstLevel = getNonProjectDependencies(resolvedComponentResultProvider.get()) List violations = new StatusVerification(ignore.get(), ignoreGroups.get(), targetStatus.get()).verify(firstLevel) List versionViolations = new VersionSelectorVerification(ignore.get(), ignoreGroups.get()).verify(definedDependencies.get()) @@ -55,8 +56,8 @@ abstract class VerifyPublicationTask extends DefaultTask { verificationViolationsCollectorHolderExtension.get().collector.put(projectName.get(), new ViolationsContainer(statusViolations: violations, versionSelectorViolations: versionViolations)) } - private static Set getNonProjectDependencies(Configuration runtimeClasspath) { - Set firstLevelDependencies = runtimeClasspath.incoming.resolutionResult.root.getDependencies() + private static Set getNonProjectDependencies(ResolvedComponentResult resolvedComponentResult) { + Set firstLevelDependencies = resolvedComponentResult.dependencies .findAll { !it.constraint } List unresolvedDependencies = firstLevelDependencies.findAll { it instanceof UnresolvedDependencyResult } as List if (! unresolvedDependencies.isEmpty()) { diff --git a/src/test/groovy/nebula/plugin/publishing/verification/VerifyPublicationTaskSpec.groovy b/src/test/groovy/nebula/plugin/publishing/verification/VerifyPublicationTaskSpec.groovy index 4dbe4f9..d120362 100644 --- a/src/test/groovy/nebula/plugin/publishing/verification/VerifyPublicationTaskSpec.groovy +++ b/src/test/groovy/nebula/plugin/publishing/verification/VerifyPublicationTaskSpec.groovy @@ -130,7 +130,7 @@ class VerifyPublicationTaskSpec extends Specification { task.configure { ignore.set(Collections.emptySet()) ignoreGroups.set(Collections.emptySet()) - runtimeClasspath.set(project.configurations.getByName(project.sourceSets.main.getRuntimeClasspathConfigurationName())) + resolvedComponentResultProvider = project.configurations.named(project.sourceSets.main.getRuntimeClasspathConfigurationName()).get().incoming.resolutionResult.rootComponent definedDependencies.set(project.configurations.collect { Configuration configuration -> configuration.dependencies }.flatten() as List)