aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/build.gradle
blob: b233360ed0df113e9f7d6728474b62363b591b10 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import org.apache.tools.ant.filters.ReplaceTokens

sonarqube {
  properties {
    property 'sonar.projectName', "${projectTitle} :: Application"
  }
}

configurations {
  zip
  jsw
  scanner
  web
  shutdowner
  jdbc_mssql {
    transitive = false
  }
  jdbc_postgresql {
    transitive = false
  }
  jdbc_h2 {
    transitive = false
  }
  bundledPlugin {
    transitive = false
  }
}

dependencies {
  // please keep list ordered
  compile 'org.slf4j:slf4j-api'

  compile 'org.elasticsearch.client:transport'
  compile project(':server:sonar-ce')
  compile project(':server:sonar-main')
  compile project(':server:sonar-process')
  compile project(':server:sonar-webserver')
  compile project(':sonar-core')
  compile project(path: ':sonar-plugin-api', configuration: 'shadow')
  compile project(':sonar-plugin-api-impl')

  compileOnly 'com.google.code.findbugs:jsr305'

  jsw 'tanukisoft:wrapper:3.2.3'
  scanner project(path: ':sonar-scanner-engine-shaded', configuration: 'shadow')
  web project(':server:sonar-web')
  shutdowner project(':sonar-shutdowner')

  jdbc_h2 'com.h2database:h2'
  jdbc_mssql 'com.microsoft.sqlserver:mssql-jdbc'
  jdbc_postgresql 'org.postgresql:postgresql'

  bundledPlugin 'org.sonarsource.css:sonar-css-plugin@jar'
  bundledPlugin "org.sonarsource.dotnet:sonar-csharp-plugin@jar"
  bundledPlugin "org.sonarsource.dotnet:sonar-vbnet-plugin@jar"
  bundledPlugin 'org.sonarsource.flex:sonar-flex-plugin@jar'
  bundledPlugin 'org.sonarsource.go:sonar-go-plugin@jar'
  bundledPlugin 'org.sonarsource.html:sonar-html-plugin@jar'
  bundledPlugin 'org.sonarsource.java:sonar-java-plugin@jar'
  bundledPlugin 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.0.2.475@jar'
  bundledPlugin 'org.sonarsource.javascript:sonar-javascript-plugin@jar'
  bundledPlugin 'org.sonarsource.ldap:sonar-ldap-plugin:2.2.0.608@jar'
  bundledPlugin 'org.sonarsource.php:sonar-php-plugin@jar'
  bundledPlugin 'org.sonarsource.python:sonar-python-plugin@jar'
  bundledPlugin "org.sonarsource.slang:sonar-kotlin-plugin@jar"
  bundledPlugin "org.sonarsource.slang:sonar-ruby-plugin@jar"
  bundledPlugin 'org.sonarsource.scm.git:sonar-scm-git-plugin:1.8.0.1574@jar'
  bundledPlugin 'org.sonarsource.scm.svn:sonar-scm-svn-plugin:1.9.0.1295@jar'
  bundledPlugin "org.sonarsource.slang:sonar-scala-plugin@jar"
  bundledPlugin 'org.sonarsource.typescript:sonar-typescript-plugin@jar'
  bundledPlugin 'org.sonarsource.xml:sonar-xml-plugin@jar'
}

jar {
  manifest {
    attributes(
      'Class-Path': configurations.compile.resolvedConfiguration.files.collect { "common/${it.getName()}" }.join(' '),
      'Main-Class': 'org.sonar.application.App'
    )
  }
}

task zip(type: Zip, dependsOn: [configurations.compile]) {
  duplicatesStrategy DuplicatesStrategy.EXCLUDE
  def archiveDir = "sonarqube-$version"

  into("${archiveDir}/") {
    from file('src/main/assembly')
      exclude 'conf/sonar.properties'
      exclude 'elasticsearch-patch'
      // elasticsearch script will be replaced by patched version below
      exclude 'elasticsearch/bin/elasticsearch'
      exclude 'elasticsearch/bin/elasticsearch.bat'
      exclude 'elasticsearch/bin/elasticsearch-env.bat'
      exclude 'elasticsearch/bin/elasticsearch-service.bat'
      exclude 'elasticsearch/bin/elasticsearch-service-*.exe'
      exclude 'elasticsearch/bin/elasticsearch-certgen*'
      exclude 'elasticsearch/bin/elasticsearch-certutil*'
      exclude 'elasticsearch/bin/elasticsearch-cli*'
      exclude 'elasticsearch/bin/elasticsearch-croneval*'
      exclude 'elasticsearch/bin/elasticsearch-keystore*'
      exclude 'elasticsearch/bin/elasticsearch-migrate*'
      exclude 'elasticsearch/bin/elasticsearch-plugin*'
      exclude 'elasticsearch/bin/elasticsearch-saml-metadata*'
      exclude 'elasticsearch/bin/elasticsearch-setup-passwords*'
      exclude 'elasticsearch/bin/elasticsearch-shard*'
      exclude 'elasticsearch/bin/elasticsearch-sql-cli*'
      exclude 'elasticsearch/bin/elasticsearch-syskeygen*'
      exclude 'elasticsearch/bin/elasticsearch-translog*'
      exclude 'elasticsearch/bin/elasticsearch-users*'
      exclude 'elasticsearch/bin/x-pack/**'
      exclude 'elasticsearch/bin/x-pack*'
      exclude 'elasticsearch/lib/tools/**'
      exclude 'elasticsearch/modules/aggs-matrix-stats/**'
      exclude 'elasticsearch/modules/ingest-common/**'
      exclude 'elasticsearch/modules/ingest-geoip/**'
      exclude 'elasticsearch/modules/ingest-user-agent/**'
      exclude 'elasticsearch/modules/lang-expression/**'
      exclude 'elasticsearch/modules/lang-groovy/**'
      exclude 'elasticsearch/modules/lang-mustache/**'
      exclude 'elasticsearch/modules/rank-eval/**'
      exclude 'elasticsearch/modules/tribe/**'
      exclude 'elasticsearch/modules/x-pack-*/**'
  }

  into("${archiveDir}/conf/") {
    from file('src/main/assembly/conf/sonar.properties')
      filter(ReplaceTokens, tokens: [
              'searchDefaultHeapSize': '512MB',
              'searchJavaOpts'       : '-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError',
              'ceDefaultHeapSize'    : '512MB',
              'ceJavaOpts'           : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
              'webDefaultHeapSize'   : '512MB',
              'webJavaOpts'          : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
      ])
  }
    
  
  into("${archiveDir}/elasticsearch/") {
    from file('src/main/assembly/elasticsearch-patch')
      include 'bin/elasticsearch'
  }
  // Create the empty dir (plugins) required by elasticsearch
  into("${archiveDir}/elasticsearch/") {
    from "$buildDir/elasticsearch"
  }
  into("${archiveDir}/lib/") {
    from jar
  }
  into("${archiveDir}/extensions/plugins/") {
    from configurations.bundledPlugin
  }
  into("${archiveDir}/lib/jsw/") {
    from configurations.jsw
  }
  into("${archiveDir}/lib/scanner/") {
    from configurations.scanner
  }
  into("${archiveDir}/lib/common/") {
    from configurations.compile
  }
  into("${archiveDir}/web/") {
    duplicatesStrategy DuplicatesStrategy.FAIL
    // FIXME use configurations.web with correct artifacts
    from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
      if (official) {
         project(':private:branding').fileTree('src').visit { b ->
           if (!b.isDirectory) {
             a.exclude b.relativePath.toString()
           }
         }
      }
    }
    if (official) {
      from project(':private:branding').file('src')
    }
  }
  into("${archiveDir}/lib/jdbc/mssql/") {
    from configurations.jdbc_mssql
  }
  into("${archiveDir}/lib/jdbc/postgresql/") {
    from configurations.jdbc_postgresql
  }
  into("${archiveDir}/lib/jdbc/h2/") {
    from configurations.jdbc_h2
  }
  into("${archiveDir}/lib/") {
    from configurations.shutdowner
  }
}
// Create the empty dir required by elasticsearch
zip.doFirst {
  new File(buildDir, 'elasticsearch/plugins').mkdirs()
}
// Check the size of the archive
zip.doLast {
  def minLength = 199000000
  def maxLength = 207000000
  def length = archiveFile.get().asFile.length()
  if (length < minLength)
    throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  if (length > maxLength)
    throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
}
assemble.dependsOn zip

// the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
// This directory should be deleted when the zip is changed.
task cleanLocalUnzippedDir(dependsOn: zip) {
  def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  outputs.upToDateWhen { true }

  doLast {
    println("delete directory ${unzippedDir}")
    project.delete(unzippedDir)
  }
}
assemble.dependsOn cleanLocalUnzippedDir

artifacts { zip zip }

artifactoryPublish.skip = false

publishing {
  publications {
    mavenJava(MavenPublication) {
      artifact zip
    }
  }
}