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

Commit

Permalink
change artifactId to filename with extension. add systemPath and type…
Browse files Browse the repository at this point in the history
… to dependencyInfo.
  • Loading branch information
Alex Maybaum committed Jul 12, 2017
1 parent 9f0a8bb commit cd191a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'signing'
apply plugin: 'io.codearte.nexus-staging'

group = 'org.whitesource'
version = '0.7'
version = '0.8'

buildscript {
repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.whitesource.gradle.tasks

import org.apache.commons.lang.StringUtils
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.ResolvedDependency
import org.gradle.api.tasks.TaskAction
Expand Down Expand Up @@ -61,11 +62,14 @@ class CollectProjectInfoTask extends DefaultTask {

def getDependencyInfo(ResolvedDependency dependency) {
def dependencyInfo = new DependencyInfo()
def sha1 = ChecksumUtils.calculateSHA1(dependency.allModuleArtifacts[0].getFile())
def file = dependency.allModuleArtifacts[0].getFile()
def sha1 = ChecksumUtils.calculateSHA1(file)
if (!addedSha1s.contains(sha1)) {
dependencyInfo.setGroupId(dependency.getModuleGroup())
dependencyInfo.setArtifactId(dependency.getModuleName())
dependencyInfo.setArtifactId(file.getName())
dependencyInfo.setVersion(dependency.getModuleVersion())
dependencyInfo.setSystemPath(file.getAbsolutePath())
dependencyInfo.setType(getFileExtension(file.getName()))
dependencyInfo.setSha1(sha1)
addedSha1s.add(sha1)
dependency.getChildren().each {
Expand All @@ -77,4 +81,11 @@ 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 cd191a0

Please sign in to comment.