Giter Club home page Giter Club logo

lock_jar's Introduction

LockJar

Build Status Code Climate

LockJar manages Java Jars for Ruby. Powered by Naether to create a frankenstein of Bundler and Maven. A Jarfile (example) is used to generate a Jarfile.lock that contains all the resolved jar dependencies. The Jarfile.lock can be used to populate the classpath.

LockJar can:

https://github.com/mguymon/lock_jar

RDoc

Install

gem install lock_jar

Ruby Usage

JRuby is natively supported. Ruby 2.x uses Rjb to proxy over JNI.

Jarfile

A Jarfile is a simple file using a Ruby DSL for defining a project's dependencies using the following methods:

  • local_repo(path): Set the local Maven repository, this were dependencies are downloaded to.
  • remote_repo(url): Add additional url of remote Maven repository.
  • group(groups): Set the group for nested jar or pom. A single or Array of groups can be set.
  • jar(notations, opts = {}): Add Jar dependency in artifact notation, artifact:group:version as the bare minimum. A single or Array of notations can be passed. Default group is default, can be specified by setting opts = { :group => ['group_name'] }
  • local(path): Add a local path to a Jar
  • pom(pom_path, opts = {}): Add a local Maven pom, default is to load dependencies for runtime and compile scopes. To select the scopes to be loaded from the pom, set the opts = { :scopes => ['test'] }
  • without_default_maven_repo: Do not use the default maven repo.

Example Jarfile

repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'

// Default group is default
jar "org.apache.mina:mina-core:2.0.4"
local 'spec/fixtures/naether-0.13.0.jar'

group 'runtime' do
  jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
end

group 'test' do
  jar 'junit:junit:jar:4.12', :group => 'test'
end

Resolving dependencies

LockJar.lock(*args): Using a Jarfile, creates a lock file. Depending on the type of arg, a different configuration is set.

  • [String] will set the Jarfile path, e.g. '/somewhere/Jarfile.different'. Default jarfile is 'Jarfile'
  • [Hash] will set the options, e.g. { :local_repo => 'path' }
    • :download [Boolean] if true, will download jars to local repo. Defaults to true.
    • :local_repo [String] sets the local repo path. Defaults to ENV['M2_REPO'] or '~/.m2/repository'
    • :lockfile [String] sets the Jarfile.lock path. Default lockfile is 'Jarfile.lock'.

When the Jarfile is locked, the transitive dependencies are resolved and saved to the Jarfile.lock file.

Example of locking a Jarfile to a Jarfile.lock

LockJar.lock

Default Remote Repository

LockJar uses Naether's default remote repository, http://repo1.maven.org/maven2/.

Jarfile.lock pior to 0.12.0 did not write the default remote repository. As of version 0.12.0, only repositories in the Jarfile.lock are used. This means older Jarfile.lock will need to be updated to include the default maven repo if they rely on it.

Jarfile.lock

The Jarfile.lock generated is a YAML file containing information on how to handle the classpath for grouped dependencies and their nested transitive dependencies.

The Jarfile.lock

---
version: 0.7.0
groups:
  default:
    dependencies:
    - ch.qos.logback:logback-classic:jar:0.9.24
    - ch.qos.logback:logback-core:jar:0.9.24
    - com.metapossum:metapossum-scanner:jar:1.0
    - com.tobedevoured.modelcitizen:core:jar:0.8.1
    - commons-beanutils:commons-beanutils:jar:1.8.3
    - commons-io:commons-io:jar:1.4
    - commons-lang:commons-lang:jar:2.6
    - commons-logging:commons-logging:jar:1.1.1
    - junit:junit:jar:4.7
    - org.apache.mina:mina-core:jar:2.0.4
    - org.slf4j:slf4j-api:jar:1.6.1
    artifacts:
    - jar:org.apache.mina:mina-core:jar:2.0.4:
        transitive:
          org.slf4j:slf4j-api:jar:1.6.1: {}
    - pom:spec/pom.xml:
        scopes:
        - runtime
        - compile
        transitive:
          com.metapossum:metapossum-scanner:jar:1.0:
            junit:junit:jar:4.7: {}
            commons-io:commons-io:jar:1.4: {}
          commons-beanutils:commons-beanutils:jar:1.8.3:
            commons-logging:commons-logging:jar:1.1.1: {}
          ch.qos.logback:logback-classic:jar:0.9.24:
            ch.qos.logback:logback-core:jar:0.9.24: {}
          commons-lang:commons-lang:jar:2.6: {}
  development:
    dependencies:
    - com.typesafe:config:jar:0.5.0
    artifacts:
    - jar:com.typesafe:config:jar:0.5.0:
        transitive: {}
  test:
    dependencies:
    - junit:junit:jar:4.12
    - org.hamcrest:hamcrest-core:jar:1.1
    artifacts:
    - jar:junit:junit:jar:4.12:
        transitive:
          org.hamcrest:hamcrest-core:jar:1.1: {}
...

Accessing Jars

LockJar.install(*args): Download Jars in the Jarfile.lock

  • [String] will set the Jarfile.lock path, e.g. 'Better.lock'. Default lock file is 'Jarfile.lock'.
  • [Array] will set the groups, e.g. ['compile','test']. 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'

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. Setting to false will list dependencies, excluding transitive dependencies.

LockJar.load(*args): Loads all dependencies to the classpath for groups from the Jarfile.lock. Default group is default. Default lock file is Jarfile.lock.

  • [String] will set the Jarfile.lock, e.g. 'Better.lock'
  • [Array] will set the groups, e.g. ['default', 'runtime']
  • [Hash] will set the options, e.g. { :local_repo => 'path' }
    • :local_repo [String] sets the local repo path
    • :resolve [Boolean] to true will make transitive dependences resolve before loading to classpath

Once a Jarfile.lock is generated, you can list all resolved jars by

jars = LockJar.list

or directly load all Jars into the classpath

jars = LockJar.load  

Do not forget, if you change your Jarfile, you have to re-generate the Jarfile.lock.

See also loading Jars into a custom ClassLoader.

Shortcuts

Skipping the Jarfile

You can skip the Jarfile and Jarfile.lock to directly play with dependencies by passing a block to LockJar.lock, LockJar.list, and LockJar.load

Lock without a Jarfile

LockJar.lock do
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
end

List without a Jarfile.lock

LockJar.list do
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
end

Load without a Jarfile.lock

LockJar.load do
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
end

Since you skipped the locking part, mostly likely you will need to resolve the dependences in the block, just pass the :resolve => true option to enable dependency resolution (also works for LockJar.list).

LockJar.load(:resolve => true) do
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
end

Command line

There is a simple command line helper. You can lock a Jarfile with the following command

lockjar lock

List jars in a Jarfile.lock with

lockjar list

Download all jars in a Jarfile.lock with

lockjar install

lockjar --help will give you list of all commands and their options.

Gem Integration

Installing Jars with a Gem

LockJar can be triggered when a Gem is installed by using a Gem extension of type Rakefile. The cavaet is the task to install the jars must be the default for the Rakefile.

A Gem spec with Rakefile extension:

Gem::Specification.new do |s|
  s.extensions = ["Rakefile"]
end

Rakefile with default to install Jars using LockJar:

task :default => :prepare

task :prepare do
  require 'lock_jar'

  # get jarfile relative the gem dir
  lockfile = File.expand_path("../Jarfile.lock", __FILE__)

  LockJar.install(lockfile)
end

Work around for Rakefile default

The downside of using the Gem extension Rakefile is it requires the default to point at the task to download the jars (from the example Rakefile, task :default => :prepare). To get around this, I used a Rakefile called PostInstallRakefile to handle the task :prepare. When packaging the gem, PostInstallRakefile is renamed to Rakefile.

Manually installing Jars

Instead of rely in a Rakefile to install Jars when the Gem is installed, Jars can be manually installed. The following Ruby needs to be called before calling LockJar.load. Only Jars that are missing are downloaded.

  #get jarfile relative the gem dir
  lockfile = File.expand_path("../Jarfile.lock", __FILE__)

  # Download any missing Jars
  LockJar.install(lockfile)

Loading

With the Jars installed, loading the classpath for the Gem is simple. As part of the load process for the Gem (an entry file that is required, etc) use the following:

  #get jarfile relative the gem dir
  lockfile = File.expand_path("../Jarfile.lock", __FILE__)

  # Loads the ClassPath with Jars from the lockfile
  LockJar.load(lockfile)

See also loading Jars into a custom ClassLoader.

Authentication

LockJar supports authentication to repository by passing in credentials from a .lockjar file. The YAML file contains a username and passwords per repository, for example:

repositories:
  'https://some.fancy.doman/maven':
    username: 'user1'
    password: 'the_pass'

The order of precedence for locating the .lockjar file is the ENV['LOCKJAR_CONFIG'], current working directory, and last the user's home directory.

Buildr Integration

LockJar integrates with Buildr using an Addon. This allows the Jarfile to be defined directly into a buildfile. A global LockJar definition can be set and is inherited to all projects. Each project may have its own LockJar definition. A lock file is generated per project based on the project name.

A new Buildr task is added to generate the lockfile for all projects

buildr lock_jar:lock

and a task per project to generate the lockfile for a single project

buildr <app>:<project>:lock_jar:lock

In a project, you can access an Array of notations using the lock_jars method, accepts same parameters as LockJar.list

lock_jars()

The default group dependencies are automatically added to the classpath for compiling. The test group dependencies are automatically added to the classpath for tests. Do not forget, if you change the LockJar definitions, you have to rerun the lock_jar:lock task.

Example

Sample buildfile with LockJar

require 'lock_jar/buildr'

# app definition, inherited into all projects
lock_jar do
  group 'test' do
    jar 'junit:junit:jar:4.12'
  end
end

define 'app' do
   define 'project1' do
     lock_jar do
       jar "org.apache.mina:mina-core:2.0.4"
     end
   end

   define 'project2' do
     lock_jar do
       pom 'pom.xml'
     end
   end
end

Generated the following lock files using lock_jar:lock

  • project1.lock - contains junit and mina jars.
  • project2.lock - contains junit and pom.xml jars.

Bundler Integration

LockJar patches Bundler to allow creation of a Jarfile.lock when Bundler calls install and update. To enable this support, add this exit callback your Gemfile

@@check ||= at_exit do
  require 'lock_jar/bundler'
  LockJar::Bundler.lock!
end

You can optionally create a Jarfile that will automatically be included when you bundle install or bundle update. Otherwise Gems with a Jarfile will be merge to generate a Jarfile.lock.

Bundler to LockJar groups

LockJar will merge the dependencies from the default and runtime group of a Gem's Jarfile. These will be placed in the lockfile under Gem's corresponding Bundler group. For example, the following Gemfile:

group :development do
  gem 'solr_sail', '~>0.1.0'
end

Would produce the follow Jarfile.lock excerpt:

---
version: 0.7.0
merged:
- gem:solr_sail:gems/solr_sail-0.1.0-java/Jarfile
groups:
  default:
    dependencies: []
    artifacts: []
  development:
    dependencies:
     - ch.qos.logback:logback-classic:jar:1.0.6
     - ch.qos.logback:logback-core:jar:1.0.6
     - com.google.guava:guava:jar:r05

Since solr_sail is defined in the Gemfile's development group, the corresponding Jarfile.lock dependencies are also under the development group.

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

lock_jar's People

Contributors

chetan avatar mguymon avatar paulgoetze avatar stewi2 avatar tobsch avatar yokolet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lock_jar's Issues

Add the target-artifact of pom.xml to load path with LockJar.load

We are using lock_jar in several mixed-language java-jruby-projects. In such a project we use the pom instruction in the Jarfile and lock_jar manages to add all the dependencies to the load path when we call Lockjar.load. Unfortunately the classes contained directly in the java-part of this project are not added to the load path and are thus not available from the ruby code.

Are we missing something or is this a conceptual limitation of lock_jar we have to deal with manually?

--quiet flag ?

getting a lot of output from install, what do you think about adding a --quiet flag to reduce the noise level a bit ? :)

@mguymon

Buildr integration is broken

Buildr integration is broken since you restructured the project (lock_jar/dsl => lock_jar/domain/dsl)
and changed the API/DSL.

Transitive dependencies not resolved correctly?

I find that with the Jarfile containing only

Case 1

group :ingest, :cli do
jar 'org.apache.flume:flume-ng-core:1.5.0-cdh5.4.5'
end

The lock_file generated is <jarfile_case1.lock>
jarfile_case1.txt

Case 2

While when the groups are

group :cli do
jar 'com.google.guava:guava:jar:15.0'
end

group :ingest, :cli do
jar 'org.apache.flume:flume-ng-core:1.5.0-cdh5.4.5'
end

lock_file generated is <jarfile_case2.lock>
jarfile_case2.txt

I find that the dependency "com.google.guava:guava:jar:15.0” is not listed as a dependency for "ingest" group in case two. Is this expected behavior or a bug?

load jars by path

It would be great to load internal jars by setting it's path.
Example JarFile:
jar 'lib/library_name.jar'

Setting the groupid:artifactid:version nomenclature is nice for loading external jars located in maven repositories, but there is not a way to load jars developed by you.
Looking at naether I think path jars are supported.
At the moment I use Lockjar for loading external jars and manual require for locally stored jars. I'm using JRuby.

NoMethodError : private method `to_notation' called for #<Naether::Notation:0x5972a2aa>

I am getting the following error w/ lock_jar 0.12.3 and naether 0.14.1 on jruby-9000 pre2. Any ideas why?

NoMethodError : private method `to_notation' called for #<Naether::Notation:0x5972a2aa>
/Users/r6p/.rvm/gems/jruby-9.0.0.0.pre2/gems/lock_jar-0.12.3/lib/lock_jar/domain/artifact.rb:46:in `initialize'
/Users/r6p/.rvm/gems/jruby-9.0.0.0.pre2/gems/lock_jar-0.12.3/lib/lock_jar/domain/dsl.rb:85:in `jar'
/Users/r6p/Developer/myproj/Buildfile:25:in `block in (root)'
/Users/r6p/.rvm/gems/jruby-9.0.0.0.pre2/gems/lock_jar-0.12.3/lib/lock_jar/domain/dsl.rb:148:in `block in group'

cmd: gem list naether

*** LOCAL GEMS ***

naether (0.14.1 java)

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

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

LockJar breaks on simple usecase

I have the following Jarfile ...

jar "org.eclipse.jetty:jetty-servlet:8.1.3.v20120416"

From IRB here's what I get:

1.9.3p125 :006 > LockJar.lock('Jarfile', :local_repo => BASEDIR.join('lib').to_path)
...
16:35:34 INFO  NaetherTransfer - Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet/8.1.3.v20120416/jetty-servlet-8.1.3.v20120416.pom
IllegalStateException: The super POM /org/apache/maven/model/pom-4.0.0.xml was not found, please verify the integrity of your Maven installation
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/naether-0.7.1/lib/naether.rb:244:in `method_missing'
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/naether-0.7.1/lib/naether.rb:244:in `resolve_dependencies'
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/lock_jar-0.2.2/lib/lock_jar/resolver.rb:62:in `resolve'
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/lock_jar-0.2.2/lib/lock_jar/runtime.rb:105:in `block in lock'
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/lock_jar-0.2.2/lib/lock_jar/runtime.rb:93:in `each'
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/lock_jar-0.2.2/lib/lock_jar/runtime.rb:93:in `lock'
    from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/lock_jar-0.2.2/lib/lock_jar.rb:32:in `lock'
    from (irb):6
    from /home/alex/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'

This keeps repeating itself if I run that command in the same session. I noticed that if I exit IRB and then I go back and retry, it works. But the issue is reproducible by deleting my local repo of downloaded libraries. As I see it, LockJar downloads Naether dependencies the first time I do a lock(), as Naether has a bootstrap process.

For the moment, I can't find a workaround. To make matters worse, I want to install "lock_file" straight from my build file, to not require users to install it manually and after that I want to lock(). This means I have something like this:

    begin
      require 'lock_jar'
    rescue LoadError
      sh "gem install lock_jar"
      Gem.clear_paths
      require 'lock_jar'      
    end

     # later ...
     LockJar.lock('Jarfile', ...)

Thanks,

Gem install fails

Building native extensions.  This could take a while...
ERROR:  Error installing lock_jar:
    ERROR: Failed to build gem native extension.

    jrake RUBYARCHDIR=/Users/cameron/.rbenv/versions/jruby-1.7.20/lib/ruby/gems/shared/gems/naether-0.15.0-java/lib RUBYLIBDIR=/Users/cameron/.rbenv/versions/jruby-1.7.20/lib/ruby/gems/shared/gems/naether-0.15.0-java/lib
/bin/sh: jrake: command not found


Gem files will remain installed in /Users/cameron/.rbenv/versions/jruby-1.7.20/lib/ruby/gems/shared/gems/naether-0.15.0-java for inspection.
Results logged to /Users/cameron/.rbenv/versions/jruby-1.7.20/lib/ruby/gems/shared/gems/naether-0.15.0-java/./gem_make.out

Using JRuby v1.7.20, JDK 8

Buildr integration is broken when reading the lock_jar data from the global_lockjar_dsl variable

@mguymon this issue is blocking us from updating some of our dependencies. It looks like the bug was introduced here:

40bf494#diff-4557cafd10bd227f714d502e29c4bc7eR21

It might also be nice to include some specs for the buildr integration so that regressions can be detected automatically.

lib/lock_jar/buildr.rb
 16 require 'lock_jar'
 17 require 'lock_jar/domain/dsl'
 18
 19 #
 20 module Buildr
 21   attr_reader :global_lockjar_dsl
 22
 23   class << self
 24     def project_to_lockfile(project)
 25       "#{project.name.tr(':', '-')}.lock"
 26     end
 27   end
 28
 29   def lock_jar(&blk)
 30     @global_lockjar_dsl = ::LockJar::Domain::Dsl.create(&blk)
 31   end

Notice that this idiom doesn't work for modules:

$ cat /tmp/foo.rb
module Foo
  attr_reader :bar

  def init_bar
    @bar = 'bar'
  end
end

$ irb
>> require '/tmp/foo.rb'
=> true
>> include Foo
=> Object
>> init_bar
=> "bar"
>> Foo.bar
=> nil

I'm not exactly sure what level of visibility you require during initialization, but this might work. But, it might also expose you to mutability, which may not be desirable:

$ cat /tmp/foo.rb
module Foo
  class << self
    attr_accessor :bar
  end

  def init_bar
    Foo.bar = 'bar'
  end
end

$ irb
>> require '/tmp/foo.rb'
=> true
>> Foo.bar
=> nil
>> include Foo
=> Object
>> init_bar
=> "bar"
>> Foo.bar
=> "bar"

Chatty startup with multiple logback.xml

I just switched from using require 'some.jar' to using lock_jar, but I am now seeing this chatty output because of multiple logback.xml on the class path

15:12:20,966 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
15:12:20,966 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
15:12:20,966 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/Users/ramarnat/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/naether-0.10.1-java/core-0.10.1.jar!/logback.xml]
15:12:20,967 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
15:12:20,967 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/Users/ramarnat/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/naether-0.10.1-java/core-0.10.1.jar!/logback.xml]
15:12:20,967 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/Users/ramarnat/.m2/repository/org/drools/drools-examples/5.5.0.Final/drools-examples-5.5.0.Final.jar!/logback.xml]
15:12:20,967 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/Users/ramarnat/.m2/repository/org/drools/drools-examples/5.5.0.Final/drools-examples-5.5.0.Final-sources.jar!/logback.x

Is there a way to exclude these from getting loaded?

When setting/overriding custom repository in Buildfile, http://repo1.maven.org/maven2 is still used.

I still see lockjar/naether trying to use that public maven repo even after overriding the repository in my Buildfile.

cmd:  bundle exec lockjar install -v -l my.lock -s default
Installing Jars from my.lock for ["default"]
[pool-1-thread-1] INFO NaetherTransfer - Downloading: http://repo1.maven.org/maven2/org/mortbay/....
[pool-2-thread-1] INFO NaetherTransfer - Downloading: https://my.artifactory.foobar/artifactory/....

Bundler integration only working if Jarfile exists?

I am building a gem using the buildr integration which generates a "memento.lock" (name of the gem).
When I now require the gem using bundler, it just does not recognize the memento.lock as file we're depending on but searches for "Jarfile".
There seems to be a conceptional issue about this or am I getting this all wrong?

Merging transitive jar-dependencies of several gem-dependencies without using lock_jar-bundler integration

Using the bundler integration lock_jar very helpfully scans all gems in the current bundle to find Jarfiles in order to merge transitive dependencies. Because of several issues we decided to abandon the bundler integration of lock_jar. Unfortunately there does not seem to be a way to specify gem-dependencies in the Jarfile to achieve the same effect as when using the bundler integration.

Are we missing something?

running lock_jar failing on travis

hi,

it would be super nice if someone could have a look at the travis build here: https://travis-ci.org/tyro89/Viking/builds/20711247#L346-L349

it's πŸ’₯ing while resolving dependencies with lock_jar: Could not find artifact jdk.tools:jdk.tools:jar:1.6 in central (http://repo1.maven.org/maven2/)

afaik, tools.jar should be included within the jdk and not downloaded from anywhere...

if you have any direction to point me to, that would be pretty much appreciated πŸ˜‚

cheers

How to load Java classes from *.jar

I have following Jarfile:
repository 'file:///Users/$USER/.m2/repository'
local_repo 'lib/java'
jar 'com.company.app:my-artifact:0.0.1-SNAPSHOT'

I run lockjar lock and all dependencies are downloaded to lib/java. When I build gem, all .jar dependencies are in lib/java.

How should I load .jars so that any class would be available through java_import ?

Provide a means for passing user/password credentials for a repository that don't get added to the *.lock files

When doing local development, we have to pass through an authenticated artifactory instance, currently there is no way to make this work unless we do the following in our Buildfile:

repository 'https://user:[email protected]'

Which then includes this full URL in the generated *.lock files that we check into our version control. It would be best if there was a mechanism for authentication that was more robust and didn't end-up with user credentials in a lock file.

Since naether supports passing Auth credentials it should be possible for lock_jar to pass down auth credentials for the user that may be supplied via some type of .lock_jar_auth hidden archive file in the users CWD or similar.

src/main/ruby/naether/runtime.rb
44-    # @param [String] username optional
45:    # @param [String] password optioanl
46:    def add_remote_repository( url, username = nil, password = nil )
47-      if username
48:        @resolver.addRemoteRepositoryByUrl( url, username, password )
49-      else
--
360-    # @option opts [String] :username for optional auth
361:    # @option opts [String] :password for optional auth
362-    # @option opts [String] :pub_key for optional auth
363:    # @option opts [String] :pub_key_passphrase for optional auth
364-    def deploy_artifact( notation, file_path, url, opts = {} )
--
374-      if opts[:username] || opts[:pub_key]
375:        artifact.setAuth(opts[:username], opts[:password], opts[:pub_key], opts[:pub_key_passphrase] )
376-      end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.