mguymon / lock_jar

LockJar manages Java Jars for Ruby

Home Page:http://mguymon.github.io/lock_jar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lock_jars([:runtime], { :resolve => false }) is returning transitive dependencies

bigsur0 opened this issue · comments

I don't think this should be happening per:

LockJar.list(*args): Lists all dependencies as notations for groups from the Jarfile.lock. Depending on the type of arg, a different configuration is set.

[String] will set the Jarfile.lock path, e.g. 'Better.lock'. Default lock file is 'Jarfile.lock'.
[Array] will set the groups, e.g. ['default', 'runtime']. Defaults group is default.
[Hash] will set the options, e.g. { :local_repo => 'path' }
:local_repo [String] sets the local repo path. Defaults to ENV['M2_REPO'] or '~/.m2/repository'
:local_paths [Boolean] converts the notations to paths of jars in the local repo
:resolve [Boolean] to true will make transitive dependences resolve before returning list of jars

Could this be due to the buildr dsl using the dependency list from the local lock file?

Yup, it seems that once the "dependencies" are added to the respective lockfile, this DSL method always returns the transitive dependencies.

Correct, by default it always reads the Jarfile.lock. The resolve parameter is only useful when inlining jar dependencies with a block:

LockJar.list(resolve: true) do 
     jar 'org.apache.tinkerpop:gremlin-core:3.1.0-incubating'
 end

Are you attempting to just read the jars in the Jarfile?

Reading Jars in the Jarfile might work. It is a bit of a hack, but I can workaround it with this snippet of code. I would prefer having a way to access only the top-level/non-transitive dependencies for packaging purposes. Any simple way to add functionality to support resolve => false for non-inlining cases?

  # Only return the direct/non-transitive dependencies
  lockfile            = LockJar::Domain::Lockfile.read(lockfile_name)
  direct_dependencies = lockfile.groups[group.to_s]['artifacts'].collect{ |ar| ar.keys}.flatten
  direct_dependencies.collect {|dep| dep.gsub(/^jar:/, '')}

Sorry for the slow reply, I was under the weather last week. 💊

Checkout this PR that should address the issue.

I think it looks ok, with quick pass through the one commit. Do you want me to do a more detailed review?

@r6p what ever you feel comfortable with

Released version 0.14.6