Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

Commit

Permalink
use built in artifact getType() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Maybaum committed Jul 17, 2017
1 parent cd191a0 commit 363d51e
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ class CollectProjectInfoTask extends DefaultTask {

def getDependencyInfo(ResolvedDependency dependency) {
def dependencyInfo = new DependencyInfo()
def file = dependency.allModuleArtifacts[0].getFile()
def artifact = dependency.getModuleArtifacts()[0]
def file = artifact.getFile()
def sha1 = ChecksumUtils.calculateSHA1(file)
if (!addedSha1s.contains(sha1)) {
dependencyInfo.setGroupId(dependency.getModuleGroup())
dependencyInfo.setArtifactId(file.getName())
dependencyInfo.setVersion(dependency.getModuleVersion())
dependencyInfo.setSystemPath(file.getAbsolutePath())
dependencyInfo.setType(getFileExtension(file.getName()))
dependencyInfo.setType(artifact.getType())
dependencyInfo.setSha1(sha1)
addedSha1s.add(sha1)
dependency.getChildren().each {
Expand All @@ -81,11 +82,4 @@ class CollectProjectInfoTask extends DefaultTask {
}
return dependencyInfo
}

private static String getFileExtension(String filename) {
if (StringUtils.isNotBlank(filename)) {
return filename.substring(filename.lastIndexOf(".") + 1).toLowerCase()
}
return null
}
}

0 comments on commit 363d51e

Please sign in to comment.