简体   繁体   中英

Java : Read sonar-project.properties

I have defined below properties in sonar-project.properties

sonar.directory=project/file

In my java application when I tried to read it gives null value any suggestion on how to read the property value?

public class MySensor implements Sensor {

public static String FOLDER = "sonar.directory"; 

public MySensor(FileSystem fs) {
    this.fs = fs;
    FOLDER = System.getProperty("sonar.directory");
    LOGGER.info("folder location {}", FOLDER);
}

EDIT- Below is my command to invoke

sonar-scanner -Dsonar.host.url="http://localhost:9000" -Dsonar.login=admin -Dsonar.password="admin" -Dsonar.directory=project/file

We can use context to read sonar properties.

Optional<String> result = context.config().get(sonar.directory);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM