@@ -190,7 +190,11 @@ public static void main(String[] argv) {
190
190
exitWithHelp ();
191
191
}
192
192
193
- checkConfiguration ();
193
+ try {
194
+ checkConfiguration ();
195
+ } catch (ConfigurationException e ) {
196
+ die (e .getMessage ());
197
+ }
194
198
195
199
if (awaitProfiler ) {
196
200
pauseToAwaitProfiler ();
@@ -573,7 +577,20 @@ public static String[] parseOptions(String[] argv) throws ParseException {
573
577
"Assign commit tags to all entries in history for all repositories." ).execute (v ->
574
578
cfg .setTagsEnabled (true ));
575
579
576
- parser .on ("-H" , "--history" , "Enable history." ).execute (v -> cfg .setHistoryEnabled (true ));
580
+ // for backward compatibility
581
+ parser .on ("-H" , "Enable history." ).execute (v -> cfg .setHistoryEnabled (true ));
582
+
583
+ parser .on ("--historyBased" , "=on|off" , ON_OFF , Boolean .class ,
584
+ "If history based reindex is in effect, the set of files " ,
585
+ "changed/deleted since the last reindex is determined from history " ,
586
+ "of the repositories. This needs history, history cache and " ,
587
+ "projects to be enabled. This should be much faster than the " ,
588
+ "classic way of traversing the directory structure. " ,
589
+ "The default is on. If you need to e.g. index files untracked by " ,
590
+ "SCM, set this to off. Currently works only for Git." ,
591
+ "All repositories in a project need to support this in order " ,
592
+ "to be indexed using history." ).
593
+ execute (v -> cfg .setHistoryBasedReindex ((Boolean ) v ));
577
594
578
595
parser .on ("--historyThreads" , "=number" , Integer .class ,
579
596
"The number of threads to use for history cache generation on repository level. " +
@@ -801,18 +818,6 @@ public static String[] parseOptions(String[] argv) throws ParseException {
801
818
}
802
819
});
803
820
804
- parser .on ("--historyBased" , "=on|off" , ON_OFF , Boolean .class ,
805
- "If history based reindex is in effect, the set of files " ,
806
- "changed/deleted since the last reindex is determined from history " ,
807
- "of the repositories. This needs history, history cache and " ,
808
- "projects to be enabled. This should be much faster than the " ,
809
- "classic way of traversing the directory structure. " ,
810
- "The default is on. If you need to e.g. index files untracked by " ,
811
- "SCM, set this to off. Currently works only for Git." ,
812
- "All repositories in a project need to support this in order " ,
813
- "to be indexed using history." ).
814
- execute (v -> cfg .setHistoryBasedReindex ((Boolean ) v ));
815
-
816
821
parser .on ("-U" , "--uri" , "=SCHEME://webappURI:port/contextPath" ,
817
822
"Send the current configuration to the specified web application." ).execute (webAddr -> {
818
823
webappURI = (String ) webAddr ;
@@ -866,8 +871,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
866
871
execute (v -> cfg .setWebappCtags ((Boolean ) v ));
867
872
});
868
873
869
- // Need to read the configuration file first
870
- // so that options may be overwritten later.
874
+ // Need to read the configuration file first, so that options may be overwritten later.
871
875
configure .parse (argv );
872
876
873
877
LOGGER .log (Level .INFO , "Indexer options: {0}" , Arrays .toString (argv ));
@@ -883,38 +887,49 @@ public static String[] parseOptions(String[] argv) throws ParseException {
883
887
return argv ;
884
888
}
885
889
886
- private static void checkConfiguration () {
890
+ static class ConfigurationException extends Exception {
891
+ static final long serialVersionUID = -1 ;
892
+
893
+ public ConfigurationException (String message ) {
894
+ super (message );
895
+ }
896
+ }
897
+
898
+ // TODO: move this Configuration
899
+ private static void checkConfiguration () throws ConfigurationException {
887
900
env = RuntimeEnvironment .getInstance ();
888
901
889
902
if (bareConfig && (env .getConfigURI () == null || env .getConfigURI ().isEmpty ())) {
890
- die ("Missing webappURI setting" );
903
+ throw new ConfigurationException ("Missing webappURI setting" );
891
904
}
892
905
893
906
if (!repositories .isEmpty () && !cfg .isHistoryEnabled ()) {
894
- die ("Repositories were specified; history is off however" );
907
+ throw new ConfigurationException ("Repositories were specified; history is off however" );
895
908
}
896
909
897
910
if (cfg .getSourceRoot () == null ) {
898
- die ("Please specify a SRC_ROOT with option -s !" );
911
+ throw new ConfigurationException ("Please specify a SRC_ROOT with option -s !" );
899
912
}
900
913
if (cfg .getDataRoot () == null ) {
901
- die ("Please specify a DATA ROOT path" );
914
+ throw new ConfigurationException ("Please specify a DATA ROOT path" );
902
915
}
903
916
904
917
if (!new File (cfg .getSourceRoot ()).canRead ()) {
905
- die ("Source root '" + cfg .getSourceRoot () + "' must be readable" );
918
+ throw new ConfigurationException ("Source root '" + cfg .getSourceRoot () + "' must be readable" );
906
919
}
907
920
908
921
if (!new File (cfg .getDataRoot ()).canWrite ()) {
909
- die ("Data root '" + cfg .getDataRoot () + "' must be writable" );
922
+ throw new ConfigurationException ("Data root '" + cfg .getDataRoot () + "' must be writable" );
910
923
}
911
924
912
925
if (!cfg .isHistoryEnabled () && cfg .isHistoryBasedReindex ()) {
913
- die ("History has to be enabled for history based reindex" );
926
+ LOGGER .log (Level .INFO , "History based reindex is on, however history is off. " +
927
+ "History has to be enabled for history based reindex." );
914
928
}
915
929
916
930
if (!cfg .isHistoryCache () && cfg .isHistoryBasedReindex ()) {
917
- die ("History cache has to be enabled for history based reindex" );
931
+ LOGGER .log (Level .INFO , "History based reindex is on, however history cache is off. " +
932
+ "History cache has to be enabled for history based reindex." );
918
933
}
919
934
}
920
935
0 commit comments