aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/build.gradle
blob: 2ee42455291de7ea77966fa59dd8def91e45aa34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
sonarqube {
  properties {
    property "sonar.projectName", "${projectTitle} :: Web"
    property "sonar.sources", "src/main/js"
    property "sonar.tests", "src/main/js"
    property "sonar.test.inclusions", "src/main/js/**/__tests__/**"
    property "sonar.exclusions", "src/main/js/**/__tests__/**"
    property "sonar.eslint.reportPaths", "eslint-report.json"
    property "sonar.javascript.lcov.reportPaths", "coverage/lcov.info"
  }
}

def webappDir = "${buildDir}/webapp"

task yarn_run(type: Exec) {
  ['config', 'public', 'scripts', 'src', '../sonar-docs/src'].each {
    inputs.dir(it).withPathSensitivity(PathSensitivity.RELATIVE)
  }
  ['babel.config.js', 'package.json', 'tsconfig.json', 'yarn.lock'].each {
    inputs.file(it).withPathSensitivity(PathSensitivity.RELATIVE)
  }
  outputs.dir(webappDir)
  outputs.cacheIf { true }

  commandLine osAdaptiveCommand(['npm', 'run', 'build-release'])
}
build.dependsOn(yarn_run)

tasks.register("yarn_validate-ci", Exec) {
  // Note that outputs are not relocatable, because contain absolute paths, and that's why inputs are not relativized
  ['config', 'src/main/js'].each {
    inputs.dir(it)
  }
  ['package.json', 'yarn.lock', 'tsconfig.json', '.eslintrc'].each {
    inputs.file(it)
  }
  outputs.file('eslint-report.json')
  outputs.dir('coverage')
  outputs.cacheIf { true }

  commandLine osAdaptiveCommand(['npm', 'run', 'validate-ci'])
}

tasks.register("yarn_check-ci", Exec) {
  // Note that outputs are not relocatable, because contain absolute paths, and that's why inputs are not relativized
  ['config', 'src'].each {
    inputs.dir(it)
  }
  ['package.json', 'yarn.lock', 'tsconfig.json'].each {
    inputs.file(it)
  }

  commandLine osAdaptiveCommand(['npm', 'run', 'check-ci'])
}

// Check for known vulnerabilities
task dependency_audit(type: Exec) {
  inputs.file('package.json')
  outputs.cacheIf { false }
  ignoreExitValue = true
  
  commandLine osAdaptiveCommand(['npm', 'run', 'audit-ci'])
}

def sources = fileTree(dir: "src") + fileTree(dir: "scripts") + fileTree(dir: "config") + fileTree(dir: "__mocks__")

task licenseCheckWeb(type: com.hierynomus.gradle.license.tasks.LicenseCheck) {
  source = sources
  exclude 'main/js/helpers/standards.json'
  if (official) exclude 'main/js/app/components/GlobalFooterBranding.js'
}
licenseMain.dependsOn licenseCheckWeb

task licenseFormatWeb(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
  source = sources
  if (official) exclude 'main/js/app/components/GlobalFooterBranding.js'
}
licenseFormat.dependsOn licenseFormatWeb