diff --git a/build.gradle b/build.gradle index 68c19f2..aec721c 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ dependencies { group = 'net.idlestate' archivesBaseName = 'gradle-download-dependencies-plugin' // Please comply with the rules of Semantic Versioning (http://semver.org) and tag releases. -version = '1.1.2' +version = '1.1.3' task sourceJar( type: Jar ) { from sourceSets.main.allGroovy diff --git a/src/main/groovy/net/idlestate/gradle/downloaddependencies/DownloadDependenciesTask.groovy b/src/main/groovy/net/idlestate/gradle/downloaddependencies/DownloadDependenciesTask.groovy index 26be612..adb4945 100644 --- a/src/main/groovy/net/idlestate/gradle/downloaddependencies/DownloadDependenciesTask.groovy +++ b/src/main/groovy/net/idlestate/gradle/downloaddependencies/DownloadDependenciesTask.groovy @@ -61,9 +61,10 @@ class DownloadDependenciesTask extends DefaultTask { componentIds.each { component -> if ( component instanceof ModuleComponentIdentifier ) { - File library = findMatchingLibrary( libraryFiles, component ) - if ( library != null ) { - copyArtifactFileToRepository( component, library ) + findMatchingLibraries( libraryFiles, component ).each { library -> + if ( library != null ) { + copyArtifactFileToRepository( component, library ) + } } } } @@ -77,29 +78,22 @@ class DownloadDependenciesTask extends DefaultTask { } } - File findMatchingLibrary( libraryFiles, component ) { - - // Check for exact match - String fullFileName = "${component.module}-${component.version}.jar" - - if ( libraryFiles.containsKey( fullFileName ) ) { - return libraryFiles[ fullFileName ] - } + def findMatchingLibraries( libraryFiles, component ) { + def libraries = [] as Set - // Search for library with classifier String fileNameWithoutExtension = "${component.module}-${component.version}" - String key = libraryFiles.keySet().find { - it.startsWith( fileNameWithoutExtension ) + libraryFiles.each { key, value -> + if ( key.startsWith( fileNameWithoutExtension ) ) { + libraries << value + } } - if ( key != null ) { - return libraryFiles[ key ] + if ( libraries.isEmpty() ) { + logger.warn( "Library file ${component.module}-${component.version}.jar of dependency ${component.toString()} not found even when considering potential classifiers." ) } - logger.warn( "Library file ${fullFileName} of dependency ${component.toString()} not found even when considering potential classifiers." ) - - return null + return libraries } def resolveComponents( componentIds, module, artifactTypes ) {