-
Notifications
You must be signed in to change notification settings - Fork 35
/
build.gradle
205 lines (180 loc) · 7.05 KB
/
build.gradle
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
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.nio.file.Paths
plugins {
id "org.jetbrains.intellij" version "1.16.0"
id "java"
id "maven-publish"
id "de.undercouch.download" version "5.3.0"
id "io.freefair.lombok" version "8.0.1"
}
group 'com.jfrog.ide'
version currentVersion
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
def testPython = project.gradle.startParameter.taskNames.contains("pythonTests")
def intellijType = testPython ? "IC" : "IU"
intellij {
version = sandboxVersion
type = intellijType
plugins = ['gradle', 'maven', 'Groovy', 'properties', 'java', 'Kotlin', 'org.jetbrains.plugins.go:223.8617.56', "PythonCore:223.8617.56"]
pluginName = 'JFrog'
}
runIde {
jvmArgs '-Xmx2G'
}
patchPluginXml {
sinceBuild = "223.4884.69"
// Explicitly setting this to an empty string makes the plugin compatible with all IDE versions up to the latest one.
// Removing this line will limit compatibility to IDE versions up to 'sandboxVersion'.
untilBuild = ""
}
listProductsReleases {
doLast {
// At the end of the build, write the first and last versions of the products to the output file.
// This will be used by the runPluginVerifier task to validate the compatibility of the plugin against the
// first and last versions of IntelliJ IDEA.
def outputFileObj = outputFile.get().asFile
if (outputFileObj.exists()) {
def lines = outputFileObj.readLines()
if (!lines.isEmpty()) {
def firstVersion = lines.first()
def lastVersion = lines.last()
outputFileObj.write("$firstVersion\n$lastVersion")
}
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://releases.jfrog.io/artifactory/oss-releases"
}
maven {
url "https://releases.jfrog.io/artifactory/oss-snapshots"
}
}
def buildInfoVersion = '2.41.13'
def idePluginsCommonVersion = '2.3.6'
dependencies {
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.15.2'
implementation group: 'org.jfrog.buildinfo', name: 'build-info-extractor', version: buildInfoVersion
implementation group: 'com.jfrog.ide', name: 'ide-plugins-common', version: idePluginsCommonVersion
implementation group: 'org.jfrog.buildinfo', name: 'build-info-client', version: buildInfoVersion
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.15.2'
implementation group: 'org.jfrog.buildinfo', name: 'build-info-api', version: buildInfoVersion
implementation group: 'com.jfrog.xray.client', name: 'xray-client-java', version: '0.14.1'
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
implementation group: 'org.jfrog.filespecs', name: 'file-specs-java', version: '1.1.2'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
implementation group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'
implementation group: 'org.codehaus.plexus', name: 'plexus-utils', version: '3.4.1'
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.11.4'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.20'
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.20'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '4.2.0'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.2.0'
}
test {
scanForTestClasses false
include "**/*Test.class"
exclude "**/*IntegrationTest*", "**/*PypiScannerTest*"
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
minGranularity 0
}
}
tasks.register('pythonTests', Test) {
scanForTestClasses false
include "**/*PypiScannerTest*"
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
minGranularity 0
}
}
tasks.register('integrationTests', Test) {
scanForTestClasses false
include "**/*IntegrationTests.class"
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
minGranularity 0
}
}
def webviewFileName = 'jfrog-ide-webview-' + webviewVersion + '.tgz'
def webviewUrl = 'https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/' + webviewFileName
tasks.register('downloadWebview', Download) {
src webviewUrl
dest buildDir
onlyIfModified true
finalizedBy('getAndUpdateWebviewChecksum')
}
tasks.register('getAndUpdateWebviewChecksum') {
finalizedBy('verifyWebview')
if (System.getenv("CI") != null) {
println 'CI mode is active - Skipping Webview checksum update'
ext.checksum = webviewChecksum
return
}
ext.checksum = getWebviewChecksumFromServer(webviewUrl)
updateWebviewChecksumInPropertiesFile(ext.checksum)
}
tasks.register('verifyWebview', Verify) {
src new File(buildDir, webviewFileName)
algorithm 'SHA-256'
checksum getAndUpdateWebviewChecksum.checksum
finalizedBy('extractWebview')
}
tasks.register('extractWebview', Copy) {
from tarTree(new File(buildDir, webviewFileName))
into Paths.get('src', 'main', 'resources', 'jfrog-ide-webview').toFile()
include '**/build/**/*'
eachFile {
path = path.replace('package/build/', '')
}
}
tasks.withType(JavaCompile).configureEach {
options.deprecation = true
options.encoding = "UTF-8"
}
tasks.withType(ProcessResources).configureEach {
dependsOn('downloadWebview')
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact buildPlugin
}
}
}
publishPlugin {
token = System.getenv("JETBRAINS_TOKEN")
}
/**
* Get Webview checksum from releases.jfrog.io
* @param webviewUrl - Webview URL
* @return the sha256 of the webview
*/
static String getWebviewChecksumFromServer(String webviewUrl) {
def headRequest = HttpRequest.newBuilder(new URL(webviewUrl).toURI()).method("HEAD", HttpRequest.BodyPublishers.noBody()).build()
def checksumResponse = HttpClient.newHttpClient().send(headRequest, HttpResponse.BodyHandlers.ofString())
return checksumResponse.headers().firstValue("x-checksum-sha256").get()
}
/**
* Update the Webview checksum in the gradle.properties file
* @param checksum - Webview checksum to update
*/
static def updateWebviewChecksumInPropertiesFile(String checksum) {
def gradleProps = new Properties()
File gradlePropertiesFile = new File("gradle.properties")
gradlePropertiesFile.withInputStream { gradleProps.load(it) }
gradleProps.setProperty("webviewChecksum", checksum)
gradlePropertiesFile.withWriter('UTF-8') { fileWriter ->
gradleProps.each { key, value -> fileWriter.writeLine "$key=$value" }
}
}