gradle-dependency-export icon indicating copy to clipboard operation
gradle-dependency-export copied to clipboard

Access to file of DefaultUnresolvedArtifactResult in MavenDependencyExport

Open stefanleh opened this issue 5 years ago • 4 comments

There is an access to the file property of an unresolvable artifact in MavenDependencyExport.groovy: https://github.com/uklance/gradle-dependency-export/blob/master/src/main/groovy/com/lazan/dependency/export/MavenDependencyExport.groovy#L154

Caused by: groovy.lang.MissingPropertyException: No such property: file for class: org.gradle.api.internal.artifacts.result.DefaultUnresolvedArtifactResult
Possible solutions: type, id, failure
		at com.lazan.dependency.export.MavenDependencyExport$_copyPoms_closure10.doCall(MavenDependencyExport.groovy:154)

I think the component.getArtifacts(MavenPomArtifact). should be extended by filtering of the artifacts so we only use resolvable ones. If i find some time i will look into that myself but currently im very busy.

Best regards, Stefan

stefanleh avatar Aug 27 '19 06:08 stefanleh

Is there an artifact on Maven Central which will show the error? Or are you seeing the issue with an artifact from an internal repo?

I think a flag to control the behaviour might be best. Eg

mavenDependencyExport {
   filterResolvable = true
} 

This would allow the build to fail for unresolvable depencies, I'm not sure if that's desirable behaviour (I need to understand what an unresolvable dependency is)

uklance avatar Aug 27 '19 07:08 uklance

Also, have you seen this?

https://github.com/uklance/gradle-dependency-export/blob/master/src/main/groovy/com/lazan/dependency/export/MavenDependencyExport.groovy#L42-L43

	protected Collection<Configuration> prepareConfigurations() {
		if (!configurations.empty) {
			return configurations
		}
		Collection<Configuration> defaultConfigurations = new LinkedHashSet<>()
		defaultConfigurations.addAll(project.buildscript.configurations.findAll { it.canBeResolved })
		defaultConfigurations.addAll(project.configurations.findAll { it.canBeResolved })
		return defaultConfigurations
	}

uklance avatar Aug 27 '19 07:08 uklance

Yes, the same check is done here too: https://github.com/uklance/gradle-dependency-export/blob/master/src/main/groovy/com/lazan/dependency/export/MavenDependencyExport.groovy#L54

But it doesnt matter if the configuration is resolvable when the artifacts in them might not be.

stefanleh avatar Aug 27 '19 08:08 stefanleh

Please see the PR.

stefanleh avatar Sep 16 '19 07:09 stefanleh