diff --git a/lib/bibliothecary/analyser/matchers.rb b/lib/bibliothecary/analyser/matchers.rb index 94c67ab4..d9b44bbb 100644 --- a/lib/bibliothecary/analyser/matchers.rb +++ b/lib/bibliothecary/analyser/matchers.rb @@ -5,7 +5,11 @@ def match_filename(filename, case_insensitive: false) if case_insensitive lambda { |path| path.downcase == filename.downcase || path.downcase.end_with?("/" + filename.downcase) } else - lambda { |path| path == filename || path.end_with?("/" + filename) } + lambda do |path| + puts "Path is #{path}" + puts "File name is #{filename}" + path == filename || path.end_with?("/" + filename) + end end end @@ -25,6 +29,11 @@ def match_extension(filename, case_insensitive: false) end def mapping_entry_match?(matcher, details, info) + puts "========" + puts matcher + puts details + puts info + puts "+++++++" if matcher.call(info.relative_path) # we only want to load contents if we don't have them already # and there's a content_matcher method to use diff --git a/lib/bibliothecary/parsers/maven.rb b/lib/bibliothecary/parsers/maven.rb index 60d9bde6..f0199809 100644 --- a/lib/bibliothecary/parsers/maven.rb +++ b/lib/bibliothecary/parsers/maven.rb @@ -34,6 +34,7 @@ class Maven GRADLE_GAV_REGEX = /([\w.-]+)\:([\w.-]+)(?:\:(#{GRADLE_VERSION_REGEX}|#{GRADLE_VAR_INTERPOLATION_REGEX}|#{GRADLE_CODE_INTERPOLATION_REGEX}))?/ # e.g. "group:artifactId:1.2.3" GRADLE_GROOVY_SIMPLE_REGEX = /(#{GRADLE_DEPENDENCY_METHODS.join('|')})\s*\(?\s*['"]#{GRADLE_GAV_REGEX}['"]/m GRADLE_KOTLIN_SIMPLE_REGEX = /(#{GRADLE_DEPENDENCY_METHODS.join('|')})\s*\(\s*"#{GRADLE_GAV_REGEX}"/m + GRADLE_KOTLIN_CUSTOM_REGEX = /implementation\(group = "(.*?)".*?(?:version = "(.*?)".*?)?\)/ MAVEN_PROPERTY_REGEX = /\$\{(.+?)\}/ MAX_DEPTH = 5 @@ -296,16 +297,24 @@ def self.parse_gradle(file_contents, options: {}) end def self.parse_gradle_kts(file_contents, options: {}) - file_contents - .scan(GRADLE_KOTLIN_SIMPLE_REGEX) # match 'implementation("group:artifactId:version")' - .reject { |(_type, group, artifactId, _version)| group.nil? || artifactId.nil? } # remove any matches with missing group/artifactId - .map { |(type, group, artifactId, version)| - { - name: [group, artifactId].join(":"), - requirement: version || "*", - type: type - } - } + bibliothecary_list = + file_contents + .scan(GRADLE_KOTLIN_SIMPLE_REGEX) # match 'implementation("group:artifactId:version")' + .reject do |(_type, group, artifactId, _version)| + group.nil? || artifactId.nil? + end + .map do |(type, group, artifactId, version)| + { name: [group, artifactId].join(':'), requirement: version || '*', type: type } + end + + custom_list_for_allegro = + file_contents + .scan(GRADLE_KOTLIN_CUSTOM_REGEX) + .map do |(name, version)| + { name: name, requirement: version || '*', type: 'implementation' } + end + + bibliothecary_list + custom_list_for_allegro end def self.gradle_dependency_name(group, name) diff --git a/spec/fixtures/build.gradle.kts b/spec/fixtures/build.gradle.kts index a5816641..5f80774b 100644 --- a/spec/fixtures/build.gradle.kts +++ b/spec/fixtures/build.gradle.kts @@ -22,6 +22,7 @@ repositories { dependencies { // Align versions of all Kotlin components implementation(platform("org.jetbrains.kotlin:kotlin-bom")) + implementation(group = "pl.allegro.bigdata.hadoop", name = "vault-gcp-java", version = "0.3.0") // Use the Kotlin JDK 8 standard library. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") diff --git a/spec/parsers/maven_spec.rb b/spec/parsers/maven_spec.rb index 50917786..e1c28dc2 100644 --- a/spec/parsers/maven_spec.rb +++ b/spec/parsers/maven_spec.rb @@ -229,7 +229,8 @@ { name: "com.google.guava:guava", requirement: "30.1.1-jre", type: "implementation" }, { name: "org.jetbrains.kotlin:kotlin-test", requirement: "*", type: "testImplementation" }, { name: "org.jetbrains.kotlin:kotlin-test-junit", requirement: "1.0.0", type: "testImplementation" }, - { name: "androidx.annotation:annotation", requirement: "${rootProject.extra[\"androidx_annotation_version\"]}", type: "implementation" } + { name: "androidx.annotation:annotation", requirement: "${rootProject.extra[\"androidx_annotation_version\"]}", type: "implementation" }, + { name: "pl.allegro.bigdata.hadoop", requirement: "0.3.0", type: "implementation"} ], kind: 'manifest', success: true