For anyone writing a plugin, I recently discovered that you can make use of
the 'add_development_dependency' feature of a gemspec as long as you
include the plugin in Foreman a particular way.
Gemspec comes with three ways to declare a dependency: add_dependency,
add_development_dependency, and add_runtime dependency. The typical way to
include an external gem is to do the following:
gem 'katello'
or
gem 'katello', :path => '…/katello'
If you declare your dependencies using 'add_dependency' for production and
'add_development_dependency' for development gems, when you run bundle
install from your Foreman checkout the gems marked with
'add_development_dependency' will not be included. You have to install them
individually using 'gem install'. Now, you may think to just declare all
gems using 'add_dependency', but not all of your gems, including those not
needed for production are required.
The trick is to tell Bundler to treat your gem special using a gemspec
declaration in the bundler file. For example,
gemspec :path => '…/katello'
This tells Bundler to treat your gem declaration as a gemspec and parse the
dependency declarations as what they are. Bundler will automatically add
all gems declared with 'add_development_dependency' into a 'development'
bundler group. Thus, in development, when running 'bundle install' all
dependencies needed for development are included in your gemset. For
production, the development gems can be excluded via:
We are using bundler_ext for RPM deployment. Does this work well with
bundler_ext?
LZ
···
On Fri, Dec 06, 2013 at 06:07:49PM -0500, Eric D Helms wrote:
> Howdy,
>
> For anyone writing a plugin, I recently discovered that you can make use of
> the 'add_development_dependency' feature of a gemspec as long as you
> include the plugin in Foreman a particular way.
>
> Gemspec comes with three ways to declare a dependency: add_dependency,
> add_development_dependency, and add_runtime dependency. The typical way to
> include an external gem is to do the following:
>
> gem 'katello'
> or
> gem 'katello', :path => '../katello'
>
> If you declare your dependencies using 'add_dependency' for production and
> 'add_development_dependency' for development gems, when you run bundle
> install from your Foreman checkout the gems marked with
> 'add_development_dependency' will not be included. You have to install them
> individually using 'gem install'. Now, you may think to just declare all
> gems using 'add_dependency', but not all of your gems, including those not
> needed for production are required.
>
> The trick is to tell Bundler to treat your gem special using a gemspec
> declaration in the bundler file. For example,
>
> gemspec :path => '../katello'
>
> This tells Bundler to treat your gem declaration as a gemspec and parse the
> dependency declarations as what they are. Bundler will automatically add
> all gems declared with 'add_development_dependency' into a 'development'
> bundler group. Thus, in development, when running 'bundle install' all
> dependencies needed for development are included in your gemset. For
> production, the development gems can be excluded via:
>
> bundle install --without development
>
> For Katello, as an example, this update to our gemspec and deployment is
> being done here - https://github.com/Katello/katello/pull/3469
>
> Hope this helps plugin writers.
>
> Cheers,
> Eric
>
> --
> You received this message because you are subscribed to the Google Groups "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Good question. I would assume so since bundler_ext uses Bundler to parse
gemfiles. For production, you can still fallback to using the 'gem'
declaration, and the add_development_dependency declaration would be
ignored.
···
On Mon, Dec 9, 2013 at 6:14 AM, Lukas Zapletal wrote:
We are using bundler_ext for RPM deployment. Does this work well with
bundler_ext?
LZ
On Fri, Dec 06, 2013 at 06:07:49PM -0500, Eric D Helms wrote:
Howdy,
For anyone writing a plugin, I recently discovered that you can make use
of
the ‘add_development_dependency’ feature of a gemspec as long as you
include the plugin in Foreman a particular way.
Gemspec comes with three ways to declare a dependency: add_dependency,
add_development_dependency, and add_runtime dependency. The typical way
to
include an external gem is to do the following:
gem 'katello’
or
gem ‘katello’, :path => ‘…/katello’
If you declare your dependencies using ‘add_dependency’ for production
and
’add_development_dependency’ for development gems, when you run bundle
install from your Foreman checkout the gems marked with
’add_development_dependency’ will not be included. You have to install
them
individually using ‘gem install’. Now, you may think to just declare all
gems using ‘add_dependency’, but not all of your gems, including those
not
needed for production are required.
The trick is to tell Bundler to treat your gem special using a gemspec
declaration in the bundler file. For example,
gemspec :path => ‘…/katello’
This tells Bundler to treat your gem declaration as a gemspec and parse
the
dependency declarations as what they are. Bundler will automatically add
all gems declared with ‘add_development_dependency’ into a 'development’
bundler group. Thus, in development, when running ‘bundle install’ all
dependencies needed for development are included in your gemset. For
production, the development gems can be excluded via: