aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-docs/build.gradle
blob: 344241e2d6d32473289d2b520bb30f388eac806c (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import java.util.regex.Matcher
import java.util.regex.Pattern

Pattern PLUGIN_NAME_PATTERN = Pattern.compile("(sonar-.*-plugin)(.*)")


/**
 * This module is building the zip file containing the static web site
 */

sonarqube {
  skipProject = true
}

group = 'com.sonarsource.sonarqube'

configurations {
  languagePlugin { transitive = false }
}

dependencies {
  languagePlugin 'com.sonarsource.abap:sonar-abap-plugin@jar'
  languagePlugin 'com.sonarsource.slang:sonar-apex-plugin@jar'
  languagePlugin "org.sonarsource.dotnet:sonar-csharp-plugin@jar"
  languagePlugin 'com.sonarsource.cpp:sonar-cfamily-plugin@jar'
  languagePlugin 'com.sonarsource.cobol:sonar-cobol-plugin@jar'
  languagePlugin 'org.sonarsource.css:sonar-css-plugin@jar'
  languagePlugin 'org.sonarsource.flex:sonar-flex-plugin@jar'
  languagePlugin 'org.sonarsource.java:sonar-java-plugin@jar'
  languagePlugin 'org.sonarsource.javascript:sonar-javascript-plugin@jar'
  languagePlugin "org.sonarsource.slang:sonar-kotlin-plugin@jar"
  languagePlugin 'org.sonarsource.php:sonar-php-plugin@jar'
  languagePlugin 'com.sonarsource.pli:sonar-pli-plugin@jar'
  languagePlugin 'com.sonarsource.plsql:sonar-plsql-plugin@jar'
  languagePlugin 'org.sonarsource.python:sonar-python-plugin@jar'
  languagePlugin 'com.sonarsource.rpg:sonar-rpg-plugin@jar'
  languagePlugin 'org.sonarsource.slang:sonar-go-plugin@jar'
  languagePlugin "org.sonarsource.slang:sonar-ruby-plugin@jar"
  languagePlugin "org.sonarsource.slang:sonar-scala-plugin@jar"
  languagePlugin 'com.sonarsource.swift:sonar-swift-plugin@jar'
  languagePlugin 'org.sonarsource.typescript:sonar-typescript-plugin@jar'
  languagePlugin 'com.sonarsource.tsql:sonar-tsql-plugin@jar'
  languagePlugin "org.sonarsource.dotnet:sonar-vbnet-plugin@jar"
  languagePlugin 'com.sonarsource.plugins.vb:sonar-vb-plugin@jar'
  languagePlugin 'org.sonarsource.html:sonar-html-plugin@jar'
  languagePlugin 'org.sonarsource.xml:sonar-xml-plugin@jar'
}

task extractAnalyzerDocFiles {
  doLast {
    configurations.languagePlugin.files.each {
      File file = it
      copy {
        from(zipTree(file).matching { include 'static/documentation.md' }) {
          eachFile { fcd ->
            Matcher m = PLUGIN_NAME_PATTERN.matcher(file.getName())
            if (m.find()) {
              fcd.relativePath = new RelativePath(true, m.group(1) + '.md')
            }
          }
          includeEmptyDirs = false
        }
        into "$buildDir/tmp/plugin-documentation/"
      }
    }
  }
}

yarn_run {
  def docsVersion = version.split("[.-]").take(2).join('.')
  environment = [ GATSBY_DOCS_VERSION: docsVersion ]
  inputs.property('version', docsVersion)
  inputs.dir('src').withPathSensitivity(PathSensitivity.RELATIVE)
  ['gatsby-config.js', 'gatsby-node.js', 'package.json', 'yarn.lock', 'tsconfig.json'].each {
    inputs.file(it).withPathSensitivity(PathSensitivity.RELATIVE)
  }
  outputs.dir('public')
  outputs.cacheIf { true }
  args = ['build']
}
// To clean outputs outside of "build" directory:
clean.dependsOn(cleanYarn_run)

"yarn_validate-ci" {
  // 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', '.eslintrc'].each {
    inputs.file(it)
  }
  outputs.file('eslint-report.json')
  outputs.dir('coverage')
  outputs.cacheIf { true }

  dependsOn(yarn)
}

task zip(type: Zip) {
  def archiveDir = "$version"
  duplicatesStrategy DuplicatesStrategy.EXCLUDE
  baseName "sonar-docs"

  into("${archiveDir}") {
    from tasks.getByName('yarn_run').outputs
  }
}
zip.dependsOn yarn_run
assemble.dependsOn zip, extractAnalyzerDocFiles

publishing {
  publications {
    docs(MavenPublication) {
      artifactId 'sonar-docs'
      artifact zip
    }
  }
}

artifactory {
  publish {
    contextUrl = System.getenv('ARTIFACTORY_URL')
    repository {
      repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO_PRIVATE')
      username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME_PRIVATE')
      password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD_PRIVATE')
    }
  }
}

artifactoryPublish {
  skip = false
  publishPom = false
  publications(publishing.publications.docs)
}