diff --git a/.gitignore b/.gitignore
index d3327c50..77956ff9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ node/
.idea/
*.iml
.vscode/
+docker/plugins/*.jar
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
new file mode 100644
index 00000000..3e50a283
--- /dev/null
+++ b/docker/docker-compose.yml
@@ -0,0 +1,31 @@
+version: "3"
+
+services:
+ sonarqube:
+ image: sonarqube:10.1.0-community
+ depends_on:
+ - db
+ environment:
+ SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
+ SONAR_JDBC_USERNAME: sonar
+ SONAR_JDBC_PASSWORD: sonar
+ volumes:
+ - sonarqube_data:/opt/sonarqube/data
+ - ./plugins:/opt/sonarqube/extensions/plugins
+ - sonarqube_logs:/opt/sonarqube/logs
+ ports:
+ - "9000:9000"
+ db:
+ image: postgres:12
+ environment:
+ POSTGRES_USER: sonar
+ POSTGRES_PASSWORD: sonar
+ volumes:
+ - postgresql:/var/lib/postgresql
+ - postgresql_data:/var/lib/postgresql/data
+
+volumes:
+ sonarqube_data:
+ sonarqube_logs:
+ postgresql:
+ postgresql_data:
\ No newline at end of file
diff --git a/docker/plugins/.gitkeep b/docker/plugins/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/jsonconfig.json b/jsonconfig.json
new file mode 100644
index 00000000..14f634e8
--- /dev/null
+++ b/jsonconfig.json
@@ -0,0 +1,5 @@
+{
+ "include": [
+ "./src/main/web/**/*"
+ ]
+}
diff --git a/package.json b/package.json
index 22d4a36d..70bf6afa 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"private": true,
"scripts": {
"build": "webpack --mode=production",
- "watch": "concurrently --kill-others \"webpack -w\" \"node test-server.js\"",
+ "watch": "concurrently --kill-others \"webpack --watch --mode development --devtool inline-source-map\" \"node test-server.js\"",
"generate-icons": "vsvg -s ./svg-icons -t ./src/compiled-icons"
},
"author": "Christian Köberl",
diff --git a/pom.xml b/pom.xml
index c8fcbf40..dec659c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,33 +117,6 @@
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 3.3.0
-
-
- unpack
- clean
-
- unpack
-
-
-
-
- org.sonarsource.sonarqube
- sonar-application
- ${sonarqube.version}
- zip
- ${project.build.directory}
- false
-
-
- sonarqube-*/lib/sonar-application*
-
-
-
-
org.sonarsource.sonar-packaging-maven-plugin
sonar-packaging-maven-plugin
@@ -232,6 +205,30 @@
8.11.0
+
+ maven-resources-plugin
+ 3.3.1
+
+
+ copy-resources
+ install
+
+ copy-resources
+
+
+ ${project.basedir}/docker/plugins
+
+
+ ${project.build.directory}
+
+ ${project.artifactId}-${project.version}.jar
+
+
+
+
+
+
+
diff --git a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java
index 83d34e27..00289ba0 100644
--- a/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java
+++ b/src/main/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensor.java
@@ -144,7 +144,7 @@ public void execute(SensorContext context)
AGGREGATED_DEPENDENCIES.addAll(validatedDependencies);
// root module?
- if (context.project().key().equals(context.project().key()))
+ if (context.project().key().equals(context.module().key()))
{
saveDependencies(context, AGGREGATED_DEPENDENCIES);
saveLicenses(context, AGGREGATED_LICENSES);
diff --git a/src/main/web/dashboard.js b/src/main/web/dashboard.js
index fb5f9764..802db64a 100644
--- a/src/main/web/dashboard.js
+++ b/src/main/web/dashboard.js
@@ -1,66 +1,18 @@
import Vue from 'vue';
-import Licenses from './dashboard/licenses.vue';
-import Dependencies from './dashboard/dependencies.vue';
-import saveAs from 'file-saverjs';
-import buildExcel from './dashboard/excel-builder';
+import Dashboard from './dashboard/dashboard.vue';
window.registerExtension('licensecheck/dashboard', function (options) {
const app = new Vue({
el: options.el,
- data: () => {
- return {
- licenses: [],
- dependencies: [],
- component: options.component
- }
- },
- created() {
- let params = new URLSearchParams(window.location.search);
- let request = {
- component : options.component.key,
- metricKeys : "licensecheck.license,licensecheck.dependency"
- };
- if (params.has("branch")) {
- request.branch = params.get("branch");
- } else if (params.has("pullRequest")) {
- request.pullRequest = params.get("pullRequest");
- }
- window.SonarRequest
- .getJSON("/api/measures/component", request)
- .then(response => {
- response.component.measures.forEach(measure => {
- if (measure.metric === 'licensecheck.license') {
- this.licenses = JSON.parse(measure.value);
- } else if (measure.metric === 'licensecheck.dependency') {
- this.dependencies = JSON.parse(measure.value);
- }
- });
- this.dependencies.forEach(dependency => {
- dependency.status = 'Unknown';
- this.licenses.forEach(license => {
- if (dependency.license === license.identifier) {
- dependency.status = license.status === 'true' ? 'Allowed' : 'Forbidden';
- }
- });
- });
- });
- },
- methods: {
- exportExcel() {
- const blob = new Blob([buildExcel(this.dependencies, this.licenses)], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
- saveAs(blob, `license-check-${this.component.key}.xls`);
- }
- },
- template: `
-
License Check
-
-
-
-
-
-
`,
- components: { Licenses, Dependencies },
+ // Cannot use `template`. Eval is blocked by CSP
+ render(createElement) {
+ return createElement(Dashboard, {
+ props: {
+ options
+ }
+ })
+ }
});
return function () {
diff --git a/src/main/web/dashboard/dashboard.vue b/src/main/web/dashboard/dashboard.vue
new file mode 100644
index 00000000..dc11478b
--- /dev/null
+++ b/src/main/web/dashboard/dashboard.vue
@@ -0,0 +1,67 @@
+
+
+
License Check
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensorTest.java b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensorTest.java
index e9f52d49..9d5da499 100644
--- a/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensorTest.java
+++ b/src/test/java/at/porscheinformatik/sonarqube/licensecheck/LicenseCheckSensorTest.java
@@ -14,6 +14,7 @@
import org.apache.commons.lang3.reflect.FieldUtils;
import org.junit.Test;
+import org.sonar.api.batch.fs.InputModule;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.batch.sensor.measure.NewMeasure;
@@ -58,6 +59,9 @@ public void execute() throws IllegalAccessException
FieldUtils.writeField(sensor, "scanners", scanners, true);
SensorContext context = mock(SensorContext.class);
InputProject project = mock(InputProject.class);
+ InputModule module = mock(InputModule.class);
+ when(module.key()).thenReturn("my-project");
+ when(context.module()).thenReturn(module);
when(project.key()).thenReturn("my-project");
when(context.project()).thenReturn(project);
NewMeasure measure = mock(NewMeasure.class);