@@ -47,7 +47,7 @@ public class EmbeddedScanner {
4747 private final IsolatedLauncherFactory launcherFactory ;
4848 private IsolatedLauncher launcher ;
4949 private final LogOutput logOutput ;
50- private final Map <String , String > globalProperties = new HashMap <>();
50+ private final Map <String , String > bootstrapProperties = new HashMap <>();
5151 private final Logger logger ;
5252 private final System2 system ;
5353
@@ -61,51 +61,51 @@ public class EmbeddedScanner {
6161 public static EmbeddedScanner create (String app , String version , final LogOutput logOutput , System2 system2 ) {
6262 Logger logger = new LoggerAdapter (logOutput );
6363 return new EmbeddedScanner (new IsolatedLauncherFactory (logger ), logger , logOutput , system2 )
64- .setGlobalProperty (InternalProperties .SCANNER_APP , app )
65- .setGlobalProperty (InternalProperties .SCANNER_APP_VERSION , version );
64+ .setBootstrapProperty (InternalProperties .SCANNER_APP , app )
65+ .setBootstrapProperty (InternalProperties .SCANNER_APP_VERSION , version );
6666 }
6767
6868 public static EmbeddedScanner create (String app , String version , final LogOutput logOutput ) {
6969 return create (app , version , logOutput , new System2 ());
7070 }
7171
72- public Map <String , String > globalProperties () {
73- return globalProperties ;
72+ public Map <String , String > getBootstrapProperties () {
73+ return bootstrapProperties ;
7474 }
7575
7676 /**
7777 * Declare technical properties needed to bootstrap (sonar.host.url, credentials, proxy, ...).
7878 */
79- public EmbeddedScanner addGlobalProperties (Map <String , String > p ) {
80- globalProperties .putAll (p );
79+ public EmbeddedScanner addBootstrapProperties (Map <String , String > p ) {
80+ bootstrapProperties .putAll (p );
8181 return this ;
8282 }
8383
8484 /**
8585 * Declare a technical property needed to bootstrap (sonar.host.url, credentials, proxy, ...).
8686 */
87- public EmbeddedScanner setGlobalProperty (String key , String value ) {
88- globalProperties .put (key , value );
87+ public EmbeddedScanner setBootstrapProperty (String key , String value ) {
88+ bootstrapProperties .put (key , value );
8989 return this ;
9090 }
9191
92- public String globalProperty (String key , @ Nullable String defaultValue ) {
93- return Optional . ofNullable ( globalProperties . get ( key )). orElse ( defaultValue );
92+ public String getBootstrapProperty (String key , @ Nullable String defaultValue ) {
93+ return bootstrapProperties . getOrDefault ( key , defaultValue );
9494 }
9595
9696 public String app () {
97- return globalProperty (InternalProperties .SCANNER_APP , null );
97+ return getBootstrapProperty (InternalProperties .SCANNER_APP , null );
9898 }
9999
100100 public String appVersion () {
101- return globalProperty (InternalProperties .SCANNER_APP_VERSION , null );
101+ return getBootstrapProperty (InternalProperties .SCANNER_APP_VERSION , null );
102102 }
103103
104104 /**
105- * Download scanner-engine JAR and start bootstrapping classloader . After that it is possible to call {@link #serverVersion()}
105+ * Bootstrap the scanner-engine. After that it is possible to call {@link #serverVersion()}
106106 */
107107 public void start () {
108- initGlobalDefaultValues ();
108+ initBootstrapDefaultValues ();
109109 doStart ();
110110 }
111111
@@ -118,7 +118,7 @@ public void execute(Map<String, String> analysisProps) {
118118 checkLauncherExists ();
119119 try (IsolatedLauncherFactory launcherFactoryToBeClosed = launcherFactory ) {
120120 Map <String , String > allProps = new HashMap <>();
121- allProps .putAll (globalProperties );
121+ allProps .putAll (bootstrapProperties );
122122 allProps .putAll (analysisProps );
123123 initAnalysisProperties (allProps );
124124 doExecute (allProps );
@@ -127,15 +127,15 @@ public void execute(Map<String, String> analysisProps) {
127127 }
128128 }
129129
130- private void initGlobalDefaultValues () {
130+ private void initBootstrapDefaultValues () {
131131 String sonarHostUrl = system .getEnvironmentVariable (SONAR_HOST_URL_ENV_VAR );
132132 if (sonarHostUrl != null ) {
133- setGlobalDefaultValue (ScannerProperties .HOST_URL , sonarHostUrl );
133+ setBootstrapPropertyIfNotAlreadySet (ScannerProperties .HOST_URL , sonarHostUrl );
134134 } else if (system .getEnvironmentVariable (BITBUCKET_CLOUD_ENV_VAR ) != null ) {
135- setGlobalDefaultValue (ScannerProperties .HOST_URL , SONARCLOUD_HOST );
135+ setBootstrapPropertyIfNotAlreadySet (ScannerProperties .HOST_URL , SONARCLOUD_HOST );
136136 logger .info ("Bitbucket Cloud Pipelines detected, no host variable set. Defaulting to sonarcloud.io." );
137137 } else {
138- setGlobalDefaultValue (ScannerProperties .HOST_URL , "http://localhost:9000" );
138+ setBootstrapPropertyIfNotAlreadySet (ScannerProperties .HOST_URL , "http://localhost:9000" );
139139 }
140140 }
141141
@@ -156,9 +156,9 @@ void initSourceEncoding(Map<String, String> p) {
156156 + (platformDependent ? " (analysis is platform dependent)" : "" ));
157157 }
158158
159- private void setGlobalDefaultValue (String key , String value ) {
160- if (!globalProperties .containsKey (key )) {
161- setGlobalProperty (key , value );
159+ private void setBootstrapPropertyIfNotAlreadySet (String key , String value ) {
160+ if (!bootstrapProperties .containsKey (key )) {
161+ setBootstrapProperty (key , value );
162162 }
163163 }
164164
@@ -167,7 +167,7 @@ protected void doStart() {
167167 Set <String > unmaskRules = new HashSet <>();
168168 unmaskRules .add ("org.sonarsource.scanner.lib.internal.batch." );
169169 ClassloadRules rules = new ClassloadRules (Collections .emptySet (), unmaskRules );
170- launcher = launcherFactory .createLauncher (globalProperties (), rules );
170+ launcher = launcherFactory .createLauncher (getBootstrapProperties (), rules );
171171 }
172172
173173 protected void doExecute (Map <String , String > properties ) {
0 commit comments