Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/bibliothecary/analyser/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
29 changes: 19 additions & 10 deletions lib/bibliothecary/parsers/maven.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion spec/parsers/maven_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down