@@ -57,19 +57,34 @@ do_(InitState) ->
57
57
RootDir = rebar_dir :root_dir (InitState ),
58
58
VendorDir = filename :join (RootDir , " vendor" ),
59
59
VendorBak = filename :join (RootDir , " _vendor" ),
60
- catch rebar_file_utils :rm_rf (VendorBak ),
61
- catch rebar_file_utils :mv (VendorDir , VendorBak ),
60
+ PluginVDir = filename :join (RootDir , " vendor_plugins" ),
61
+ PluginVBak = filename :join (RootDir , " _vendor_plugins" ),
62
+ filelib :is_dir (VendorBak ) andalso rebar_file_utils :rm_rf (VendorBak ),
63
+ filelib :is_dir (VendorDir ) andalso rebar_file_utils :mv (VendorDir , VendorBak ),
64
+ filelib :is_dir (PluginVBak ) andalso rebar_file_utils :rm_rf (PluginVBak ),
65
+ filelib :is_dir (PluginVDir ) andalso rebar_file_utils :mv (PluginVDir , PluginVBak ),
62
66
filelib :ensure_dir (filename :join (VendorDir , " .touch" )),
67
+ filelib :ensure_dir (filename :join (PluginVDir , " .touch" )),
63
68
% % remove the src_dirs option for vendored files
64
69
CleanDirs = rebar_dir :lib_dirs (InitState ) -- [" vendor/*" ],
65
- CleanState = rebar_state :set (InitState , project_app_dirs , CleanDirs ),
70
+ CleanStateTmp = rebar_state :set (InitState , project_app_dirs , CleanDirs ),
71
+ CleanPlugins = rebar_dir :project_plugin_dirs (InitState ) -- [" vendor_plugins/*" ],
72
+ CleanState = rebar_state :set (CleanStateTmp , project_plugin_dirs , CleanPlugins ),
73
+ % % re-install non-local plugins, assume the already-loaded project plugins
74
+ % % we dropped are fine in memory
75
+ TmpState1 = rebar_plugins :top_level_install (CleanState ),
66
76
% % re-run discovery
67
- {ok , TmpState1 } = rebar_prv_app_discovery :do (CleanState ),
77
+ {ok , TmpState2 } = rebar_prv_app_discovery :do (TmpState1 ),
68
78
% % run a full fetch (which implicitly upgrades, since the lock file
69
79
% % should be unset for any vendored app)
70
- {ok , TmpState2 } = rebar_prv_install_deps :do (TmpState1 ),
80
+ {ok , TmpState3 } = rebar_prv_install_deps :do (TmpState2 ),
81
+ % % move the plugins to the vendor path
82
+ % % The plugins aren't tracked as nicely as the deps (no lock file) and
83
+ % % there isn't a preset function to grab them all, so we'll instead
84
+ % % copy everything that was in the plugin directory.
85
+ vendor_plugins (TmpState3 , PluginVDir ),
71
86
% % move the libs to the vendor path
72
- AllDeps = rebar_state :lock (TmpState2 ),
87
+ AllDeps = rebar_state :lock (TmpState3 ),
73
88
[begin
74
89
AppDir = rebar_app_info :dir (Dep ),
75
90
NewAppDir = filename :join (VendorDir , filename :basename (AppDir )),
@@ -79,12 +94,15 @@ do_(InitState) ->
79
94
% % -- we don't actually want to mess with the user's file so we have to
80
95
% % let them know what it should be:
81
96
NewAppDirs = CleanDirs ++ [" vendor/*" ],
97
+ NewPluginDirs = CleanPlugins ++ [" vendor_plugins/*" ],
82
98
? CONSOLE (" Vendoring in place. To use the vendored libraries, configure "
83
99
" the source application directories for your project with:~n~n "
84
- " {project_app_dirs, ~p }.~n~n "
100
+ " {project_app_dirs, ~p }.~n "
101
+ " {project_plugin_dirs, ~p }.~n "
102
+ " ~n "
85
103
" and move the {deps, ...} tuple to the rebar.config files "
86
104
" of the proper top-level applications rather than the project root." ,
87
- [NewAppDirs ]),
105
+ [NewAppDirs , NewPluginDirs ]),
88
106
State1 = rebar_state :set (InitState , project_app_dirs , NewAppDirs ),
89
107
{ok , State1 }.
90
108
@@ -117,3 +135,11 @@ check_project_layout(State) ->
117
135
end
118
136
end .
119
137
138
+ vendor_plugins (State , PluginVDir ) ->
139
+ PluginDir = rebar_dir :plugins_dir (State ),
140
+ {ok , Files } = file :list_dir_all (PluginDir ),
141
+ [rebar_file_utils :mv (Path , filename :join (PluginVDir , PathPart ))
142
+ || PathPart <- Files ,
143
+ Path <- [filename :join (PluginDir , PathPart )],
144
+ filelib :is_dir (Path )],
145
+ ok .
0 commit comments