@@ -884,6 +884,40 @@ public void prepareIndexer(RuntimeEnvironment env,
884
884
throw new IndexerException ("Internal error, zapCache shouldn't be null" );
885
885
}
886
886
887
+ if (addProjects ) {
888
+ File files [] = env .getSourceRootFile ().listFiles ();
889
+ Map <String ,Project > projects = env .getProjects ();
890
+
891
+ // Keep a copy of the old project list so that we can preserve
892
+ // the customization of existing projects.
893
+ Map <String , Project > oldProjects = new HashMap <>();
894
+ for (Project p : projects .values ()) {
895
+ oldProjects .put (p .getName (), p );
896
+ }
897
+
898
+ projects .clear ();
899
+
900
+ // Add a project for each top-level directory in source root.
901
+ for (File file : files ) {
902
+ String name = file .getName ();
903
+ String path = "/" + name ;
904
+ if (oldProjects .containsKey (name )) {
905
+ // This is an existing object. Reuse the old project,
906
+ // possibly with customizations, instead of creating a
907
+ // new with default values.
908
+ Project p = oldProjects .get (name );
909
+ p .setPath (path );
910
+ p .setName (name );
911
+ p .completeWithDefaults (env .getConfiguration ());
912
+ projects .put (name , p );
913
+ } else if (!name .startsWith ("." ) && file .isDirectory ()) {
914
+ // Found a new directory with no matching project, so
915
+ // create a new project with default properties.
916
+ projects .put (name , new Project (name , path , env .getConfiguration ()));
917
+ }
918
+ }
919
+ }
920
+
887
921
if (searchRepositories || listRepoPaths || !zapCache .isEmpty ()) {
888
922
LOGGER .log (Level .INFO , "Scanning for repositories..." );
889
923
long start = System .currentTimeMillis ();
@@ -937,40 +971,6 @@ public void prepareIndexer(RuntimeEnvironment env,
937
971
}
938
972
}
939
973
940
- if (addProjects ) {
941
- File files [] = env .getSourceRootFile ().listFiles ();
942
- Map <String ,Project > projects = env .getProjects ();
943
-
944
- // Keep a copy of the old project list so that we can preserve
945
- // the customization of existing projects.
946
- Map <String , Project > oldProjects = new HashMap <>();
947
- for (Project p : projects .values ()) {
948
- oldProjects .put (p .getName (), p );
949
- }
950
-
951
- projects .clear ();
952
-
953
- // Add a project for each top-level directory in source root.
954
- for (File file : files ) {
955
- String name = file .getName ();
956
- String path = "/" + name ;
957
- if (oldProjects .containsKey (name )) {
958
- // This is an existing object. Reuse the old project,
959
- // possibly with customizations, instead of creating a
960
- // new with default values.
961
- Project p = oldProjects .get (name );
962
- p .setPath (path );
963
- p .setName (name );
964
- p .completeWithDefaults (env .getConfiguration ());
965
- projects .put (name , p );
966
- } else if (!name .startsWith ("." ) && file .isDirectory ()) {
967
- // Found a new directory with no matching project, so
968
- // create a new project with default properties.
969
- projects .put (name , new Project (name , path , env .getConfiguration ()));
970
- }
971
- }
972
- }
973
-
974
974
if (defaultProjects != null && !defaultProjects .isEmpty ()) {
975
975
Set <Project > projects = new TreeSet <>();
976
976
for (String projectPath : defaultProjects ) {
0 commit comments