@@ -25,8 +25,7 @@ init_schemas(App, Config) ->
25
25
RabbitSchema = filename :join ([DepsDir , " rabbit" , " priv" , " schema" , " rabbitmq.schema" ]),
26
26
Schemas = case App of
27
27
rabbit -> [RabbitSchema ];
28
- _ -> [RabbitSchema ,
29
- filename :join ([DepsDir , App , " priv" , " schema" , atom_to_list (App ) ++ " .schema" ])]
28
+ _ -> [RabbitSchema , find_app_schema (App , DepsDir )]
30
29
end ,
31
30
ct :pal (" Schemas ~p~n " , [Schemas ]),
32
31
SchemaDir = filename :join (? config (data_dir , Config ), " schema" ),
@@ -45,6 +44,22 @@ init_schemas(App, Config) ->
45
44
{conf_snippets , Snippets }
46
45
]).
47
46
47
+ find_app_schema (App , DepsDir ) ->
48
+ Schema = get_schema_for ([DepsDir , App , " priv" ], App ),
49
+ does_schema_exist (filelib :is_regular (Schema ), App , DepsDir , Schema , cont ).
50
+
51
+ does_schema_exist (true , _App , _DepsDir , Schema , _ ) ->
52
+ Schema ;
53
+ does_schema_exist (false , App , _DepsDir , _Schema , stop ) ->
54
+ ct :fail (" Could not find schema for app: ~p~n " , [App ]);
55
+ does_schema_exist (false , App , DepsDir , _Schema , cont ) ->
56
+ % If not in umbrella, priv will be at ../priv
57
+ Schema = get_schema_for ([DepsDir , " .." , " priv" ], App ),
58
+ does_schema_exist (filelib :is_regular (Schema ), App , DepsDir , Schema , stop ).
59
+
60
+ get_schema_for (Prefix , App ) ->
61
+ filename :join (Prefix ++ [" schema" , atom_to_list (App ) ++ " .schema" ]).
62
+
48
63
copy_to (File , Dir ) ->
49
64
BaseName = filename :basename (File ),
50
65
{ok , _ } = file :copy (File , Dir ++ " /" ++ BaseName ).
0 commit comments