Repository: porscheinformatik/sonarqube-licensecheck
Pull request #84 (2019-07-26 12:18:40)

Switch to SonarQube API 7.x / remove deprecated API usage


Patch:
diff --git a/pom.xml b/pom.xml
index 8b94a9e..fadeed1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,11 @@
   </properties>
 
   <dependencies>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.7.26</version>
+    </dependency>
     <dependency>
       <groupId>org.glassfish</groupId>
       <artifactId>javax.json</artifactId>
@@ -78,18 +83,18 @@
     <dependency>
       <groupId>org.sonarsource.sonarqube</groupId>
       <artifactId>sonar-plugin-api</artifactId>
-      <version>6.7</version>
+      <version>7.9</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.sonarsource.sonarqube</groupId>
       <artifactId>sonar-server</artifactId>
-      <version>6.7</version>
+      <version>7.2.1</version>
       <scope>provided</scope>
       <exclusions>
         <exclusion>
-          <groupId>org.sonarsource.sonarqube</groupId>
-          <artifactId>sonar-views-bridge</artifactId>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
         </exclusion>
       </exclusions>
     </dependency>
@@ -200,8 +205,8 @@
           </execution>
         </executions>
         <configuration>
-          <nodeVersion>v10.15.1</nodeVersion>
-          <npmVersion>6.4.1</npmVersion>
+          <nodeVersion>v10.16.0</nodeVersion>
+          <npmVersion>6.9.0</npmVersion>
         </configuration>
       </plugin>
     </plugins>
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java
index 83d37c4..fc14a08 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java
@@ -14,7 +14,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.sensor.Sensor;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 
 import at.porscheinformatik.sonarqube.licensecheck.interfaces.Scanner;
 import at.porscheinformatik.sonarqube.licensecheck.license.License;
@@ -26,24 +26,22 @@ import at.porscheinformatik.sonarqube.licensecheck.npm.PackageJsonDependencyScan
 public class LicenseCheckSensor implements Sensor
 {
     private static final Logger LOGGER = LoggerFactory.getLogger(LicenseCheckSensor.class);
-
+    private final static Set<License> AGGREGATED_LICENSES = newSetFromMap(new ConcurrentHashMap<License, Boolean>());
+    private final static Set<Dependency> AGGREGATED_DEPENDENCIES = newSetFromMap(new ConcurrentHashMap<>());
     private final FileSystem fs;
-    private final Settings settings;
+    private final Configuration configuration;
     private final ValidateLicenses validateLicenses;
     private final Scanner[] scanners;
 
-    private final static Set<License> AGGREGATED_LICENSES = newSetFromMap(new ConcurrentHashMap<License, Boolean>());
-    private final static Set<Dependency> AGGREGATED_DEPENDENCIES =
-        newSetFromMap(new ConcurrentHashMap<Dependency, Boolean>());
-
-    public LicenseCheckSensor(FileSystem fs, Settings settings, ValidateLicenses validateLicenses,
+    public LicenseCheckSensor(FileSystem fs, Configuration configuration, ValidateLicenses validateLicenses,
         MavenLicenseService mavenLicenseService, MavenDependencyService mavenDependencyService)
     {
         this.fs = fs;
-        this.settings = settings;
+        this.configuration = configuration;
         this.validateLicenses = validateLicenses;
         this.scanners = new Scanner[]{
-            new PackageJsonDependencyScanner(settings.getBoolean(LicenseCheckPropertyKeys.NPM_RESOLVE_TRANSITVE_DEPS)),
+            new PackageJsonDependencyScanner(
+                configuration.getBoolean(LicenseCheckPropertyKeys.NPM_RESOLVE_TRANSITVE_DEPS).orElse(false)),
             new MavenDependencyScanner(mavenLicenseService, mavenDependencyService)};
     }
 
@@ -87,7 +85,7 @@ public class LicenseCheckSensor implements Sensor
     @Override
     public void execute(SensorContext context)
     {
-        if (!settings.getBoolean(LicenseCheckPropertyKeys.ACTIVATION_KEY))
+        if (!configuration.getBoolean(LicenseCheckPropertyKeys.ACTIVATION_KEY).orElse(true))
         {
             LOGGER.info("Scanner is set to inactive. No scan possible.");
             return;
@@ -100,7 +98,8 @@ public class LicenseCheckSensor implements Sensor
             dependencies.addAll(scanner.scan(fs.baseDir()));
         }
 
-        ProjectDefinition project = LicenseCheckPlugin.getRootProject(((DefaultInputModule) context.module()).definition());
+        ProjectDefinition project =
+            LicenseCheckPlugin.getRootProject(((DefaultInputModule) context.module()).definition());
         Set<Dependency> validatedDependencies = validateLicenses.validateLicenses(dependencies, context);
         Set<License> usedLicenses = validateLicenses.getUsedLicenses(validatedDependencies, project);
 
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseService.java
index abcbfad..86f03b3 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseService.java
@@ -5,9 +5,9 @@ import static at.porscheinformatik.sonarqube.licensecheck.LicenseCheckPropertyKe
 import java.util.Collection;
 import java.util.List;
 
-import org.sonar.api.batch.ScannerSide;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.scanner.ScannerSide;
 import org.sonar.api.server.ServerSide;
 
 import at.porscheinformatik.sonarqube.licensecheck.projectLicense.ProjectLicense;
@@ -17,13 +17,13 @@ import at.porscheinformatik.sonarqube.licensecheck.projectLicense.ProjectLicense
 @ScannerSide
 public class LicenseService
 {
-    private final Settings settings;
+    private final Configuration configuration;
     private final ProjectLicenseService projectLicenseService;
 
-    public LicenseService(Settings settings, ProjectLicenseService projectLicenseService)
+    public LicenseService(Configuration configuration, ProjectLicenseService projectLicenseService)
     {
         super();
-        this.settings = settings;
+        this.configuration = configuration;
         this.projectLicenseService = projectLicenseService;
     }
 
@@ -54,7 +54,7 @@ public class LicenseService
 
     public List<License> getLicenses()
     {
-        String licenseString = settings.getString(LICENSE_KEY);
+        String licenseString = configuration.get(LICENSE_KEY).orElse(null);
         return License.fromString(licenseString);
     }
 }
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseSettingsService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseSettingsService.java
index 3fdbcd9..85061ee 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseSettingsService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/license/LicenseSettingsService.java
@@ -9,7 +9,7 @@ import java.util.List;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.server.ServerSide;
 import org.sonar.server.platform.PersistentSettings;
 
@@ -25,14 +25,14 @@ public class LicenseSettingsService
      */
     private final PersistentSettings persistentSettings;
 
-    private final Settings settings;
+    private final Configuration configuration;
     private final LicenseService licenseService;
 
-    public LicenseSettingsService(PersistentSettings persistentSettings, LicenseService licenseService)
+    public LicenseSettingsService(PersistentSettings persistentSettings, Configuration configuration, LicenseService licenseService)
     {
         super();
         this.persistentSettings = persistentSettings;
-        this.settings = persistentSettings.getSettings();
+        this.configuration = configuration;
         this.licenseService = licenseService;
 
         initSpdxLicences();
@@ -85,7 +85,7 @@ public class LicenseSettingsService
 
     public boolean deleteLicense(String id)
     {
-        List<License> licenses = License.fromString(settings.getString(LICENSE_KEY));
+        List<License> licenses = License.fromString(configuration.get(LICENSE_KEY).orElse(null));
         List<License> newLicenseList = new ArrayList<>();
         boolean found = false;
         for (License license : licenses)
@@ -129,23 +129,23 @@ public class LicenseSettingsService
     {
         Collections.sort(licenseList);
         String licenseJson = License.createString(licenseList);
-        settings.setProperty(LICENSE_KEY, licenseJson);
+        persistentSettings.getSettings().setProperty(LICENSE_KEY, licenseJson);
         persistentSettings.saveProperty(LICENSE_KEY, licenseJson);
     }
 
     private void initSpdxLicences()
     {
-        String licenseJson = settings.getString(LICENSE_KEY);
+        String licenseJson = configuration.get(LICENSE_KEY).orElse(null);
 
         if (licenseJson != null && !licenseJson.isEmpty())
         {
             return;
         }
 
-        try(InputStream inputStream = LicenseSettingsService.class.getResourceAsStream("spdx_license_list.json");)
+        try (InputStream inputStream = LicenseSettingsService.class.getResourceAsStream("spdx_license_list.json");)
         {
             String spdxLicenseListJson = IOUtils.readToString(inputStream);
-            settings.setProperty(LICENSE_KEY, spdxLicenseListJson);
+            persistentSettings.getSettings().setProperty(LICENSE_KEY, spdxLicenseListJson);
             persistentSettings.saveProperty(LICENSE_KEY, spdxLicenseListJson);
         }
         catch (Exception e)
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencyService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencyService.java
index a291783..7cc5907 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencyService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencyService.java
@@ -11,29 +11,28 @@ import javax.json.JsonArray;
 import javax.json.JsonObject;
 import javax.json.JsonReader;
 
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.server.ServerSide;
+import org.sonar.api.scanner.ScannerSide;
 
 @ServerSide
 @ScannerSide
 public class MavenDependencyService
 {
-    private final Settings settings;
+    private final Configuration configuration;
 
-    public MavenDependencyService(Settings settings)
+    public MavenDependencyService(Configuration configuration)
     {
         super();
-        this.settings = settings;
+        this.configuration = configuration;
     }
 
     public List<MavenDependency> getMavenDependencies()
     {
         final List<MavenDependency> mavenDependencies = new ArrayList<>();
-        String dependencyString = settings.getString(ALLOWED_DEPENDENCIES_KEY);
-        initMavenDependencyData(dependencyString);
+        String dependencyString = configuration.get(ALLOWED_DEPENDENCIES_KEY).orElse("[]");
 
-        JsonReader jsonReader = Json.createReader(new StringReader(settings.getString(ALLOWED_DEPENDENCIES_KEY)));
+        JsonReader jsonReader = Json.createReader(new StringReader(dependencyString));
         JsonArray jsonArray = jsonReader.readArray();
         jsonReader.close();
 
@@ -45,18 +44,4 @@ public class MavenDependencyService
         }
         return mavenDependencies;
     }
-
-    private void initMavenDependencyData(String mavenDependencyString)
-    {
-        if ((mavenDependencyString == null) || mavenDependencyString.isEmpty())
-        {
-            JsonArray jsonArray = Json
-                .createArrayBuilder()
-                .add(Json.createObjectBuilder().add("nameMatches", "org.apache..*").add("license", "Apache-2.0"))
-                .build();
-            String initValueMavenDepependencies = jsonArray.toString();
-
-            settings.setProperty(ALLOWED_DEPENDENCIES_KEY, initValueMavenDepependencies);
-        }
-    }
 }
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencySettingsService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencySettingsService.java
index e90a6cd..d0cd323 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencySettingsService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavendependency/MavenDependencySettingsService.java
@@ -13,7 +13,6 @@ import javax.json.JsonArrayBuilder;
 import javax.json.JsonObject;
 import javax.json.JsonReader;
 
-import org.sonar.api.config.Settings;
 import org.sonar.api.server.ServerSide;
 import org.sonar.server.platform.PersistentSettings;
 
@@ -25,7 +24,6 @@ public class MavenDependencySettingsService
      */
     private final PersistentSettings persistentSettings;
 
-    private final Settings settings;
     private final MavenDependencyService mavenDependencyService;
 
     public MavenDependencySettingsService(PersistentSettings persistentSettings,
@@ -33,7 +31,6 @@ public class MavenDependencySettingsService
     {
         super();
         this.persistentSettings = persistentSettings;
-        this.settings = persistentSettings.getSettings();
         this.mavenDependencyService = mavenDependencyService;
         initMavenDependencies();
     }
@@ -63,7 +60,8 @@ public class MavenDependencySettingsService
     public void deleteMavenDependency(final String key)
     {
         List<MavenDependency> newDependencyList = new ArrayList<>();
-        JsonReader jsonReader = Json.createReader(new StringReader(settings.getString(ALLOWED_DEPENDENCIES_KEY)));
+        JsonReader jsonReader =
+            Json.createReader(new StringReader(persistentSettings.getSettings().getString(ALLOWED_DEPENDENCIES_KEY)));
         JsonArray jsonArray = jsonReader.readArray();
         jsonReader.close();
 
@@ -92,7 +90,7 @@ public class MavenDependencySettingsService
             .forEach(jsonArray::add);
 
         String newJsonDependency = jsonArray.build().toString();
-        settings.setProperty(ALLOWED_DEPENDENCIES_KEY, newJsonDependency);
+        persistentSettings.getSettings().setProperty(ALLOWED_DEPENDENCIES_KEY, newJsonDependency);
         persistentSettings.saveProperty(ALLOWED_DEPENDENCIES_KEY, newJsonDependency);
     }
 
@@ -105,14 +103,14 @@ public class MavenDependencySettingsService
             .build();
         String initValueMavenDepependencies = jsonArray.toString();
 
-        String mavenDependencies = settings.getString(ALLOWED_DEPENDENCIES_KEY);
+        String mavenDependencies = persistentSettings.getSettings().getString(ALLOWED_DEPENDENCIES_KEY);
 
         if ((mavenDependencies != null) && !mavenDependencies.isEmpty())
         {
             return;
         }
 
-        settings.setProperty(ALLOWED_DEPENDENCIES_KEY, initValueMavenDepependencies);
+        persistentSettings.getSettings().setProperty(ALLOWED_DEPENDENCIES_KEY, initValueMavenDepependencies);
         persistentSettings.saveProperty(ALLOWED_DEPENDENCIES_KEY, initValueMavenDepependencies);
     }
 
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseService.java
index dd11d35..683a331 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseService.java
@@ -7,25 +7,25 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.scanner.ScannerSide;
 import org.sonar.api.server.ServerSide;
 
 @ServerSide
 @ScannerSide
 public class MavenLicenseService
 {
-    private final Settings settings;
+    private final Configuration configuration;
 
-    public MavenLicenseService(Settings settings)
+    public MavenLicenseService(Configuration configuration)
     {
         super();
-        this.settings = settings;
+        this.configuration = configuration;
     }
 
     public List<MavenLicense> getMavenLicenseList()
     {
-        return MavenLicense.fromString(settings.getString(LICENSE_REGEX));
+        return MavenLicense.fromString(configuration.get(LICENSE_REGEX).orElse(null));
     }
 
     public Map<Pattern, String> getLicenseMap()
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseSettingsService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseSettingsService.java
index 0f6b125..300642d 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseSettingsService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/mavenlicense/MavenLicenseSettingsService.java
@@ -9,7 +9,7 @@ import java.util.List;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
 import org.sonar.api.server.ServerSide;
 import org.sonar.server.platform.PersistentSettings;
 
@@ -20,37 +20,39 @@ public class MavenLicenseSettingsService
 {
     private static final Logger LOGGER = LoggerFactory.getLogger(MavenLicenseSettingsService.class);
 
-    /** This is not official API */
+    /**
+     * This is not official API
+     */
     private final PersistentSettings persistentSettings;
-    private final Settings settings;
+    private final Configuration configuration;
     private final MavenLicenseService mavenLicenseService;
 
-    public MavenLicenseSettingsService(PersistentSettings persistentSettings, Settings settings,
+    public MavenLicenseSettingsService(PersistentSettings persistentSettings, Configuration configuration,
         MavenLicenseService mavenLicenseService)
     {
         super();
         this.persistentSettings = persistentSettings;
-        this.settings = settings;
+        this.configuration = configuration;
         this.mavenLicenseService = mavenLicenseService;
         initMavenLicenses();
     }
 
     private void initMavenLicenses()
     {
-        String mavenLicenseListString = settings.getString(LICENSE_REGEX);
+        String mavenLicenseListString = configuration.get(LICENSE_REGEX).orElse(null);
 
         if (mavenLicenseListString != null && !mavenLicenseListString.isEmpty())
         {
             return;
         }
 
-        try(InputStream in = MavenLicenseSettingsService.class.getResourceAsStream("default_license_mapping.json"))
+        try (InputStream in = MavenLicenseSettingsService.class.getResourceAsStream("default_license_mapping.json"))
         {
             mavenLicenseListString = IOUtils.readToString(in);
-            settings.setProperty(LICENSE_REGEX, mavenLicenseListString);
+            persistentSettings.getSettings().setProperty(LICENSE_REGEX, mavenLicenseListString);
             persistentSettings.saveProperty(LICENSE_REGEX, mavenLicenseListString);
         }
-        catch(Exception e)
+        catch (Exception e)
         {
             LOGGER.error("Could not load default_license_mapping.json", e);
         }
@@ -113,7 +115,7 @@ public class MavenLicenseSettingsService
     {
         String mavenLicensesString = MavenLicense.createString(mavenLicenses);
 
-        settings.setProperty(LICENSE_REGEX, mavenLicensesString);
+        persistentSettings.getSettings().setProperty(LICENSE_REGEX, mavenLicensesString);
         persistentSettings.saveProperty(LICENSE_REGEX, mavenLicensesString);
     }
 
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseService.java
index bd4b5cf..d97550b 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseService.java
@@ -7,25 +7,25 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.scanner.ScannerSide;
 import org.sonar.api.server.ServerSide;
 
 @ServerSide
 @ScannerSide
 public class ProjectLicenseService
 {
-    private final Settings settings;
+    private final Configuration configuration;
 
-    public ProjectLicenseService(Settings settings)
+    public ProjectLicenseService(Configuration configuration)
     {
         super();
-        this.settings = settings;
+        this.configuration = configuration;
     }
 
     public List<ProjectLicense> getProjectLicenseList()
     {
-        String projectLicenseString = settings.getString(PROJECT_LICENSE_KEY);
+        String projectLicenseString = configuration.get(PROJECT_LICENSE_KEY).orElse(null);
 
         if (StringUtils.isNotEmpty(projectLicenseString))
         {
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseSettingsService.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseSettingsService.java
index de1c86f..e6a71e5 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseSettingsService.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/projectLicense/ProjectLicenseSettingsService.java
@@ -6,24 +6,23 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
-import org.sonar.api.config.Settings;
 import org.sonar.api.server.ServerSide;
 import org.sonar.server.platform.PersistentSettings;
 
 @ServerSide
 public class ProjectLicenseSettingsService
 {
-    /** This is not official API */
+    /**
+     * This is not official API
+     */
     private final PersistentSettings persistentSettings;
-    private final Settings settings;
     private final ProjectLicenseService projectLicenseService;
 
-    public ProjectLicenseSettingsService(PersistentSettings persistentSettings, Settings settings,
+    public ProjectLicenseSettingsService(PersistentSettings persistentSettings,
         ProjectLicenseService projectLicenseService)
     {
         super();
         this.persistentSettings = persistentSettings;
-        this.settings = settings;
         this.projectLicenseService = projectLicenseService;
     }
 
@@ -43,12 +42,6 @@ public class ProjectLicenseSettingsService
         }
     }
 
-    public boolean checkIfListContains(ProjectLicense projectLicense)
-    {
-        List<ProjectLicense> projectLicenses = projectLicenseService.getProjectLicenseList();
-        return projectLicenses.contains(projectLicense);
-    }
-
     public void deleteProjectLicense(String projectKey, String license)
     {
         List<ProjectLicense> projectLicenses = projectLicenseService.getProjectLicenseList();
@@ -71,7 +64,7 @@ public class ProjectLicenseSettingsService
     {
         Collections.sort(projectLicenses);
         String projectLicensesString = ProjectLicense.createString(projectLicenses);
-        settings.setProperty(PROJECT_LICENSE_KEY, projectLicensesString);
+        persistentSettings.getSettings().setProperty(PROJECT_LICENSE_KEY, projectLicensesString);
         persistentSettings.saveProperty(PROJECT_LICENSE_KEY, projectLicensesString);
     }
 


Test patch:
diff --git a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java
index c0a6d5d..6be92af 100644
--- a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java
+++ b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/ValidateLicensesTest.java
@@ -19,8 +19,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
+import org.sonar.api.batch.fs.internal.DefaultInputProject;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
+import org.sonar.api.batch.sensor.issue.NewIssue;
 import org.sonar.api.batch.sensor.issue.internal.DefaultIssue;
 
 import at.porscheinformatik.sonarqube.licensecheck.license.License;
@@ -58,7 +60,7 @@ public class ValidateLicensesTest
     public void licenseNotAllowed()
     {
         SensorContext context = createContext();
-        DefaultIssue issue = new DefaultIssue(mock(SensorStorage.class));
+        NewIssue issue = new DefaultIssue(mock(DefaultInputProject.class), mock(SensorStorage.class));
         when(context.newIssue()).thenReturn(issue);
 
         validateLicenses.validateLicenses(deps(new Dependency("thing", "1.0", "MIT")), context);
@@ -116,7 +118,7 @@ public class ValidateLicensesTest
     public void checkSpdxAndCombinationNotAllowed()
     {
         SensorContext context = createContext();
-        DefaultIssue issue = new DefaultIssue(mock(SensorStorage.class));
+        NewIssue issue = new DefaultIssue(mock(DefaultInputProject.class), mock(SensorStorage.class));
         when(context.newIssue()).thenReturn(issue);
 
         validateLicenses.validateLicenses(
@@ -131,7 +133,7 @@ public class ValidateLicensesTest
     public void checkSpdxAndCombinationNotFound()
     {
         SensorContext context = createContext();
-        DefaultIssue issue = new DefaultIssue(mock(SensorStorage.class));
+        NewIssue issue = new DefaultIssue(mock(DefaultInputProject.class), mock(SensorStorage.class));
         when(context.newIssue()).thenReturn(issue);
 
         validateLicenses.validateLicenses(deps(new Dependency("thing", "1.0", "(Apache-2.0 AND Apache-1.1)")), context);
@@ -156,7 +158,7 @@ public class ValidateLicensesTest
     public void licenseNull()
     {
         SensorContext context = createContext();
-        DefaultIssue issue = new DefaultIssue(mock(SensorStorage.class));
+        NewIssue issue = new DefaultIssue(mock(DefaultInputProject.class), mock(SensorStorage.class));
         when(context.newIssue()).thenReturn(issue);
 
         validateLicenses.validateLicenses(deps(new Dependency("thing", "1.0", null)), context);
@@ -169,7 +171,7 @@ public class ValidateLicensesTest
     public void licenseUnknown()
     {
         SensorContext context = createContext();
-        DefaultIssue issue = new DefaultIssue(mock(SensorStorage.class));
+        NewIssue issue = new DefaultIssue(mock(DefaultInputProject.class), mock(SensorStorage.class));
         when(context.newIssue()).thenReturn(issue);
 
         validateLicenses.validateLicenses(deps(new Dependency("thing", "1.0", "Mamamia")), context);