Browse Source

add plugin template

pull/3/head
Tristan Sloughter 10 years ago
parent
commit
989a1bfe8d
5 changed files with 54 additions and 1 deletions
  1. +29
    -0
      priv/templates/plugin.erl.dtl
  2. +7
    -0
      priv/templates/plugin.template
  3. +14
    -0
      priv/templates/plugin_README.md.dtl
  4. +2
    -1
      src/rebar_core.erl
  5. +2
    -0
      src/rebar_templater.erl

+ 29
- 0
priv/templates/plugin.erl.dtl View File

@ -0,0 +1,29 @@
-module({{appid}}).
-behaviour(rebar_provider).
-export([init/1,
do/1]).
-define(PROVIDER, {{appid}}).
-define(DEPS, []).
%% ===================================================================
%% Public API
%% ===================================================================
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
State1 = rebar_state:(State, rebar_provider:create([{name, ?PROVIDER},
{provider_impl, ?MODULE},
{bare, false},
{deps, ?DEPS},
{example, "rebar {{appid}}"},
{short_desc, "{{appid}} plugin."},
{desc, ""},
{opts, []}])),
{ok, State1}.
-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(State) ->
{ok, State}.

+ 7
- 0
priv/templates/plugin.template View File

@ -0,0 +1,7 @@
{variables, []}.
{template, "plugin.erl", "src/{{appid}}.erl"}.
{template, "otp_lib.app.src", "src/{{appid}}.app.src"}.
{template, "rebar.config", "rebar.config"}.
{template, "gitignore", ".gitignore"}.
{template, "LICENSE", "LICENSE"}.
{template, "plugin_README.md", "README.md"}.

+ 14
- 0
priv/templates/plugin_README.md.dtl View File

@ -0,0 +1,14 @@
{{appid}}
=====
Rebar3 plugin
Build
-----
$ rebar3 compile
Use
---
$ rebar3 {{appid}}

+ 2
- 1
src/rebar_core.erl View File

@ -35,7 +35,8 @@ process_command(State, Command) ->
LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIRS),
_UpdatedCodePaths = update_code_path([DepsDir | LibDirs]),
rebar_prv_install_deps:setup_env(State),
%% ? rebar_prv_install_deps:setup_env(State),
TargetProviders = rebar_provider:get_target_providers(Command, State),

+ 2
- 0
src/rebar_templater.erl View File

@ -47,6 +47,8 @@ new(app, DirName, State) ->
create1(State, DirName, "otp_app");
new(lib, DirName, State) ->
create1(State, DirName, "otp_lib");
new(plugin, DirName, State) ->
create1(State, DirName, "plugin");
new(rel, DirName, State) ->
create1(State, DirName, "otp_rel").

Loading…
Cancel
Save