bibliothecary 8.4.0 → 8.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65f4910198d30819544a51adff24b14ce2214631dc0adf958d264dd89800f1ab
4
- data.tar.gz: 362bea1f8f48122e28253491c281e2a25bdf6d14c831e988435da4bc02b3da52
3
+ metadata.gz: 88bb227529774df01fff8b890d9a2ef3d4c211ff8cf7ddb012c0b0da83e867ad
4
+ data.tar.gz: 596d991826e48b1b42f00f795a8ab2e8da831b3dabf358c00c47fcd0e55a9daa
5
5
  SHA512:
6
- metadata.gz: 51e6c14e963753db57341b241356a323dcc55e31b9593444aca6d2cc5882af26fe52d06b36b1382f11367f301bd817f82a35ab7ff8dd5d7d1e065ec52775e06f
7
- data.tar.gz: bdfcc8fbb046095031c39619955eef933bfe4a59e7d59558e621e7bd6ab391fda2559b10a85640abf181505dfce0bd21ec7103325595a2dfa0cbeb2da828e437
6
+ metadata.gz: c126388716f2676a601f6b59119f15471bc4c124cccebf15cde1149d25604d45abc9a338ada17785ac572a31871f495567e2a71b8ac7363f383b2f8ee05e2e76
7
+ data.tar.gz: 2bf471a522a8822646c28f481ad61dd805b682756ae8cf7017138cb0cd086157bec0aaa6885e349c60979d3d9ced4c6734e0e9e97c3c3fe52675246c2db2e344
@@ -9,13 +9,17 @@ 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
+
15
19
  # Dependencies that are on-disk projects, eg:
16
- # \--- project :api:my-internal-project
17
- # +--- my-group:my-alias:1.2.3 -> project :client (*)
18
- GRADLE_PROJECT_REGEX = /project :(\S+)/
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+)?/
19
23
 
20
24
  # Builtin methods: https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations
21
25
  # Deprecated methods: https://docs.gradle.org/current/userguide/upgrading_version_6.html#sec:configuration_removal
@@ -143,10 +147,15 @@ module Bibliothecary
143
147
  end
144
148
 
145
149
  def self.parse_gradle_resolved(file_contents, options: {})
146
- type = nil
150
+ current_type = nil
151
+ current_project = nil
152
+
147
153
  file_contents.split("\n").map do |line|
148
- type_match = GRADLE_TYPE_REGEX.match(line)
149
- 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
150
159
 
151
160
  gradle_dep_match = GRADLE_DEP_REGEX.match(line)
152
161
  next unless gradle_dep_match
@@ -156,7 +165,7 @@ module Bibliothecary
156
165
  # gradle can import on-disk projects and deps will be listed under them, e.g. `+--- project :pie2-testing`,
157
166
  # so we treat these projects as internal deps themselves (["internal:foo","0.0.0"])
158
167
  if (project_match = line.match(GRADLE_PROJECT_REGEX))
159
- project_name = project_match[1]
168
+ project_name = project_match[1] || current_project
160
169
  line = line.sub(GRADLE_PROJECT_REGEX, "__PROJECT_GROUP__:__PROJECT_NAME__:__PROJECT_REQUIREMENT__") # project names can have colons, which breaks our split(":") below, so sub it out until after we've parsed the line.
161
170
  else
162
171
  project_name = ""
@@ -170,9 +179,9 @@ module Bibliothecary
170
179
  .split(":")
171
180
  .map do |part|
172
181
  part
173
- .sub(/__PROJECT_GROUP__/, "internal")# give all projects a group namespace of "internal"
182
+ .sub(/__PROJECT_GROUP__/, "internal") # give all projects a group namespace of "internal"
174
183
  .sub(/__PROJECT_NAME__/, project_name)
175
- .sub(/__PROJECT_REQUIREMENT__/, "1.0.0") # give all projects a requirement of "1.0.0".
184
+ .sub(/__PROJECT_REQUIREMENT__/, "1.0.0") # give all projects a requirement of "1.0.0".
176
185
  end # replace placeholders after we've parsed the line
177
186
 
178
187
  # A testImplementation line can look like this so just skip those
@@ -186,7 +195,7 @@ module Bibliothecary
186
195
  original_requirement: dep[2],
187
196
  name: dep[-3..-2].join(":"),
188
197
  requirement: dep[-1],
189
- type: type
198
+ type: current_type
190
199
  }
191
200
  elsif dep.count == 5
192
201
  # get name from renamed package resolution "org:name -> renamed_org:name:version"
@@ -195,14 +204,14 @@ module Bibliothecary
195
204
  original_requirement: "*",
196
205
  name: dep[-3..-2].join(":"),
197
206
  requirement: dep[-1],
198
- type: type
207
+ type: current_type
199
208
  }
200
209
  else
201
210
  # get name from version conflict resolution ("org:name:version -> version") and no-resolution ("org:name:version")
202
211
  {
203
212
  name: dep[0..1].join(":"),
204
213
  requirement: dep[-1],
205
- type: type
214
+ type: current_type
206
215
  }
207
216
  end
208
217
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.4.0"
2
+ VERSION = "8.4.1"
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.4.0
4
+ version: 8.4.1
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-18 00:00:00.000000000 Z
11
+ date: 2022-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb