diff --git a/src/main/kotlin/net/woggioni/plugins/DependencyExportPlugin.kt b/src/main/kotlin/net/woggioni/plugins/DependencyExportPlugin.kt index 56563ff..119f114 100644 --- a/src/main/kotlin/net/woggioni/plugins/DependencyExportPlugin.kt +++ b/src/main/kotlin/net/woggioni/plugins/DependencyExportPlugin.kt @@ -27,7 +27,7 @@ open class RenderDependenciesPluginExtension(project: Project) { var graphvizExecutable: String = "dot" } -private class Overrider(private val properties : Map, private val prefix: String) { +private class Overrider(private val properties: Map, private val prefix: String) { inline fun identity(arg: T): T { return arg } @@ -58,10 +58,19 @@ object DependencyExporter { var sequence = 0 val map = HashMap() - val resolutionResult = project.configurations.single { + val requestedConfiguration = project.configurations.singleOrNull { it.name == ext.configurationName - }.incoming.resolutionResult - if(!ext.outputFile.isAbsolute) { + }?.takeIf { it.isCanBeResolved } ?: let { + val resolvableConfigurations = "[" + project.configurations.asSequence() + .filter { it.isCanBeResolved } + .map { "'${it.name}'" } + .joinToString(",") + "]" + throw GradleException("Configuration '${ext.configurationName}' doesn't exist or cannot be resolved, " + + "resolvable configurations in this project are " + resolvableConfigurations) + } + + val resolutionResult = requestedConfiguration.incoming.resolutionResult + if (!ext.outputFile.isAbsolute) { ext.outputFile = project.buildDir.toPath().resolve(ext.outputFile) } Files.createDirectories(ext.outputFile.parent) @@ -119,13 +128,13 @@ object DependencyExporter { } object DependencyRenderer { - fun render(project: Project, ext: RenderDependenciesPluginExtension, sourceFile : Path) { + fun render(project: Project, ext: RenderDependenciesPluginExtension, sourceFile: Path) { val overrider = Overrider(project.properties, "renderDependencies") overrider.overrideProperty(ext::format) overrider.overrideProperty(ext::graphvizExecutable) overrider.overrideProperty(ext::outputFile) { value -> Paths.get(value) } - if(!ext.outputFile.isAbsolute) { + if (!ext.outputFile.isAbsolute) { ext.outputFile = project.buildDir.toPath().resolve(ext.outputFile) } val cmd: List = listOf( @@ -161,4 +170,4 @@ class DependencyExportPlugin : Plugin { } }.get() } -} \ No newline at end of file +}