From cd191a0f5bb522a25af4743fbd306525a3d9e4af Mon Sep 17 00:00:00 2001 From: Alex Maybaum Date: Wed, 12 Jul 2017 17:57:19 +0300 Subject: [PATCH] change artifactId to filename with extension. add systemPath and type to dependencyInfo. --- build.gradle | 2 +- .../gradle/tasks/CollectProjectInfoTask.groovy | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b4c3801..e1415a5 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'signing' apply plugin: 'io.codearte.nexus-staging' group = 'org.whitesource' -version = '0.7' +version = '0.8' buildscript { repositories { diff --git a/src/main/groovy/org/whitesource/gradle/tasks/CollectProjectInfoTask.groovy b/src/main/groovy/org/whitesource/gradle/tasks/CollectProjectInfoTask.groovy index d5c65ce..f87d047 100644 --- a/src/main/groovy/org/whitesource/gradle/tasks/CollectProjectInfoTask.groovy +++ b/src/main/groovy/org/whitesource/gradle/tasks/CollectProjectInfoTask.groovy @@ -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 @@ -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 { @@ -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 + } }