bibliothecary 8.3.9 → 8.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5447f8ff7067f7eb7c0f1bfbd13f0ba6da33335dd31cee7b319587a09260308a
4
- data.tar.gz: b23abc3e66340a26345db527803dcb7d7d8a3f9418297bff161deb72dd778aa5
3
+ metadata.gz: c21d1063a79efb1b133d650ba0d24754c26a9487341cc9e711f5387d22912602
4
+ data.tar.gz: f75fd37ef4c6262b3c23e908b6a044187ac048c96398eb8e7312b020e259ca6d
5
5
  SHA512:
6
- metadata.gz: 79159794155d5ea5c18978f4e6a57eba72bd78699fcee008e66fbf0bb83a5c737893ee369d7cb4d3f8afe2758b1029c4a87a526344ea8d7a2aa2ba38a2ab3729
7
- data.tar.gz: 01ec2a377345cc804c1fac8149f27fc40a7e34c45db27ae0f9b6eb0cea1ebdece6b64b23c5da6f96354d1440102bc3854dcf2b4297d9cf915e89c920d3de3f25
6
+ metadata.gz: d513694486a3af6bd68c654c022bf30e2ce601cf2f0150b41f824368ba5f826a47ec688c6a8e32adce516ac35bbe7baa234992d0d1cb24d4b630ba221ceaf92b
7
+ data.tar.gz: 63ae337f307b054c7b5c846c9847780a5a2f4a9d97502fd589ff35280acfd77f026a2abcb193dc2bb48ffb309c216561841d49b53cc985659ffbb72bc930dda1
@@ -9,9 +9,18 @@ module Bibliothecary
9
9
  # e.g. "annotationProcessor - Annotation processors and their dependencies for source set 'main'."
10
10
  GRADLE_TYPE_REGEX = /^(\w+)/
11
11
 
12
- # "| \\--- com.google.guava:guava:23.5-jre (*)"
12
+ # e.g. "| \\--- com.google.guava:guava:23.5-jre (*)"
13
13
  GRADLE_DEP_REGEX = /(\+---|\\---){1}/
14
14
 
15
+ # Project declaration lines so we know the current project name
16
+ # e.g. "Project ':submodules:test'" (this example is a project nested in submodules/test/ folder)
17
+ GRADLE_PROJECT_DECLARATION_REGEX = /Project '?:([^\s']+)'?/
18
+
19
+ # Dependencies that are on-disk projects, eg:
20
+ # e.g. "\--- project :api:my-internal-project"
21
+ # e.g. "+--- my-group:my-alias:1.2.3 -> project :client (*)"
22
+ GRADLE_PROJECT_REGEX = /project :(\S+)?/
23
+
15
24
  # Builtin methods: https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations
16
25
  # Deprecated methods: https://docs.gradle.org/current/userguide/upgrading_version_6.html#sec:configuration_removal
17
26
  GRADLE_DEPENDENCY_METHODS = %w(api compile compileClasspath compileOnly compileOnlyApi implementation runtime runtimeClasspath runtimeOnly testCompile testCompileOnly testImplementation testRuntime testRuntimeOnly)
@@ -138,21 +147,37 @@ module Bibliothecary
138
147
  end
139
148
 
140
149
  def self.parse_gradle_resolved(file_contents, options: {})
141
- type = nil
150
+ current_type = nil
151
+ current_project = nil
152
+
142
153
  file_contents.split("\n").map do |line|
143
- type_match = GRADLE_TYPE_REGEX.match(line)
144
- type = type_match.captures[0] if type_match
154
+ current_type_match = GRADLE_TYPE_REGEX.match(line)
155
+ current_type = current_type_match.captures[0] if current_type_match
156
+
157
+ current_project_match = GRADLE_PROJECT_DECLARATION_REGEX.match(line)
158
+ current_project = current_project_match.captures[0] if current_project_match
145
159
 
146
160
  gradle_dep_match = GRADLE_DEP_REGEX.match(line)
147
161
  next unless gradle_dep_match
148
162
 
149
163
  split = gradle_dep_match.captures[0]
150
164
 
165
+ # gradle can import on-disk projects and deps will be listed under them, e.g. `+--- project :test:integration`,
166
+ # so we treat these projects as "internal" deps with requirement of "1.0.0"
167
+ if (project_match = line.match(GRADLE_PROJECT_REGEX))
168
+ # project names can have colons (e.g. for gradle projects in subfolders), which breaks maven artifact naming assumptions, so just replace them with hyphens.
169
+ project_name = (project_match[1] || current_project).gsub(/:/, "-")
170
+ line = line.sub(GRADLE_PROJECT_REGEX, "internal:#{project_name}:1.0.0")
171
+ else
172
+ project_name = ""
173
+ end
174
+
151
175
  dep = line
152
176
  .split(split)[1].sub(/(\((c|n|\*)\))$/, "") # line ending legend: (c) means a dependency constraint, (n) means not resolved, or (*) means resolved previously, e.g. org.springframework.boot:spring-boot-starter-web:2.1.0.M3 (*)
153
177
  .sub(/ FAILED$/, "") # dependency could not be resolved (but still may have a version)
154
178
  .sub(" -> ", ":") # handle version arrow syntax
155
- .strip.split(":")
179
+ .strip
180
+ .split(":")
156
181
 
157
182
  # A testImplementation line can look like this so just skip those
158
183
  # \--- org.springframework.security:spring-security-test (n)
@@ -165,7 +190,7 @@ module Bibliothecary
165
190
  original_requirement: dep[2],
166
191
  name: dep[-3..-2].join(":"),
167
192
  requirement: dep[-1],
168
- type: type
193
+ type: current_type
169
194
  }
170
195
  elsif dep.count == 5
171
196
  # get name from renamed package resolution "org:name -> renamed_org:name:version"
@@ -174,14 +199,14 @@ module Bibliothecary
174
199
  original_requirement: "*",
175
200
  name: dep[-3..-2].join(":"),
176
201
  requirement: dep[-1],
177
- type: type
202
+ type: current_type
178
203
  }
179
204
  else
180
205
  # get name from version conflict resolution ("org:name:version -> version") and no-resolution ("org:name:version")
181
206
  {
182
207
  name: dep[0..1].join(":"),
183
208
  requirement: dep[-1],
184
- type: type
209
+ type: current_type
185
210
  }
186
211
  end
187
212
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.3.9"
2
+ VERSION = "8.4.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.3.9
4
+ version: 8.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-11 00:00:00.000000000 Z
11
+ date: 2022-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb