Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧱 Change common package JDK version to 8 #323

Merged
merged 6 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/qodana.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "1.0"
linter: jetbrains/qodana-jvm:latest
projectJDK: 11
projectJDK: "11"
profile:
name: qodana.recommended.full
exclude:
Expand Down
16 changes: 16 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2021-2024 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)

Expand Down
16 changes: 16 additions & 0 deletions changelog.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/usr/bin/env bash
#
# Copyright 2021-2024 JetBrains s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

previous_tag=0
for current_tag in $(git tag --sort=-creatordate)
do
Expand Down
24 changes: 24 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2021-2024 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)

Expand All @@ -11,17 +27,25 @@ val kotlinVersion by extra(libs.versions.kotlin.get())

group = "org.jetbrains.qodana.common"
version = "${properties("majorVersion").get()}.${properties("buildNumber").get()}"

kotlin {
jvmToolchain(11)
version = "2024.1.6"
}

tasks.register<Jar>("jarSources") {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

publishing {
publications {
create<MavenPublication>("common") {
groupId = group.toString()
artifactId = "cli"
version = version.toString()
from(components["java"])
artifact(tasks["jarSources"])
pom {
url.set("https://github.com/JetBrains/qodana-action")
licenses {
Expand Down
16 changes: 16 additions & 0 deletions common/qodana.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2021-2024 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// noinspection JSUnusedGlobalSymbols
import {checksum, version} from './cli.json'
import {createHash} from 'crypto'
Expand Down
38 changes: 38 additions & 0 deletions common/src/main/kotlin/org/jetbrains/qodana/cli/Checksums.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2021-2024 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jetbrains.qodana.cli

// CHECKSUMS is a map of Qodana CLI versions binaries and their checksums.
// Note: the content of this file is generated by the build script. Do not modify it manually.
val CHECKSUMS = mapOf(
"2023.3.2" to mapOf(
"windows_x86_64" to "da666d34e60167461ed75ce69a8d0dced33255d7d0785c4a3cdc33419cada022",
"windows_arm64" to "4c7d2363bf0ffe1f7269dde4af03bb3b8586f8e213f1cb3bc3c77d1d9f4a0e90",
"linux_x86_64" to "71abcb82489daba6200b5791ee56058a2f8ad8a87f8bbdcd33e6180906e1e482",
"linux_arm64" to "47f86194e30a33a702971cbc33c78a38aa2e1af18eeccabe6d10a7a36451d43a",
"darwin_x86_64" to "72b85e7e5a28f49b553df9e8efcb789c2622c41694f06ad9f83833baf335c8c5",
"darwin_arm64" to "468178072a0ffbdb80d8305a88ef7b671d484205c20c043adc7c257ddc0032a4"
),
"2024.1.6" to mapOf(
"windows_x86_64" to "cba8236cc8c650ecac61d543e744cb20e4763a26a075f37dc5909880de93b1f3",
"windows_arm64" to "b0547cd008959ca275d0a945e9ae025c4c9271cffa0e87ffaac883d164bf84e2",
"linux_x86_64" to "597d870f4c747d04d0280956306e2e7b9e003662d4600d93c1b69fcaffc2bb7b",
"linux_arm64" to "b127fc5fe46f5c197781ff0f30de4e4f68b3ba19c5748dcb87c3d1417a3d9f89",
"darwin_x86_64" to "847495bdeb8bffd2e13b0af8decdbd3b7b23735ad18746d0629e7a5e25c867de",
"darwin_arm64" to "e87ff91a64b8c77466938ee2020bf8636b46016ff9b587aa3fcaa356d6de6b72"
)
)
51 changes: 33 additions & 18 deletions common/src/main/kotlin/org/jetbrains/qodana/cli/Qodana.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2021-2024 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jetbrains.qodana.cli

import java.io.File
Expand All @@ -14,25 +30,23 @@ import java.util.logging.Logger
@Suppress("MemberVisibilityCanBePrivate")
class Installer {
val log: Logger = Logger.getLogger(Installer::class.java.name)

companion object {
private const val VERSION = "2024.1.6"
private const val RELEASE_DOWNLOAD_URL = "https://github.com/JetBrains/qodana-cli/releases/download/v%s/qodana_%s_%s"
private val CHECKSUMS = mapOf(
"windows_x86_64" to "cba8236cc8c650ecac61d543e744cb20e4763a26a075f37dc5909880de93b1f3",
"windows_arm64" to "b0547cd008959ca275d0a945e9ae025c4c9271cffa0e87ffaac883d164bf84e2",
"linux_x86_64" to "597d870f4c747d04d0280956306e2e7b9e003662d4600d93c1b69fcaffc2bb7b",
"linux_arm64" to "b127fc5fe46f5c197781ff0f30de4e4f68b3ba19c5748dcb87c3d1417a3d9f89",
"darwin_x86_64" to "847495bdeb8bffd2e13b0af8decdbd3b7b23735ad18746d0629e7a5e25c867de",
"darwin_arm64" to "e87ff91a64b8c77466938ee2020bf8636b46016ff9b587aa3fcaa356d6de6b72"
)

fun getQodanaUrl(platform: String = getPlatformName(), arch: String = getArchName(), version: String = VERSION): String {
private const val LATEST_VERSION = "2024.1.6"
private const val RELEASE_DOWNLOAD_URL =
"https://github.com/JetBrains/qodana-cli/releases/download/v%s/qodana_%s_%s"

fun getQodanaUrl(
platform: String = getPlatformName(),
arch: String = getArchName(),
version: String = LATEST_VERSION
): String {
return String.format(RELEASE_DOWNLOAD_URL, version, platform, arch) + getExtension()
}

fun getExtension(): String = if (getPlatformName() == "windows") ".exe" else ""

fun getVersion(): String = VERSION
fun getLatestVersion(): String = LATEST_VERSION

fun getArchName(): String {
val arch = System.getProperty("os.arch").lowercase()
Expand All @@ -53,20 +67,21 @@ class Installer {
}
}

fun getChecksum(): String {
fun getChecksum(version: String = getLatestVersion()): String {
val platform = getPlatformName()
val arch = getArchName()
return CHECKSUMS["${platform}_${arch}"]
?: throw IllegalArgumentException("Unsupported combination of platform and architecture: ${platform}_${arch}")
return CHECKSUMS[version]?.get("${platform}_${arch}")
?: throw IllegalArgumentException("Unsupported combination of version, platform and architecture: $version ${platform}_${arch}")
}
}

fun setup(path: File, downloadURL: String = getQodanaUrl()): String {
fun setup(path: File, downloadURL: String = getQodanaUrl(), version: String = getLatestVersion()): String {
if (path.exists()) {
verifyChecksum(path, getChecksum(version))
return path.absolutePath
} else try {
download(downloadURL, path)
verifyChecksum(path, getChecksum())
verifyChecksum(path, getChecksum(version))
} catch (e: IOException) {
throw IOException("Unable to download latest qodana binary", e)
}
Expand Down
Loading
Loading