Skip to content

Commit

Permalink
Added ability to handle multiple libraries per component
Browse files Browse the repository at this point in the history
  • Loading branch information
tehlers committed May 26, 2016
1 parent e9e6633 commit 85759f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
}
}
}
}
Expand All @@ -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 ) {
Expand Down

0 comments on commit 85759f2

Please sign in to comment.