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

gradle updates #346

Closed
wants to merge 2 commits into from
Closed
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/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
matrix:
gradleVersion:
- 7.6
- 8.5
- 8.9
os:
- windows-latest
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ testGradleVersion=
testGradleArguments=

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.5
gradleVersion=8.9

# https://github.com/gradle/gradle/issues/20416
systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
18 changes: 12 additions & 6 deletions plugin/src/main/kotlin/org/jetbrains/qodana/Qodana.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class Installer {
val log: Logger = Logger.getLogger(Installer::class.java.name)

companion object {
private const val LATEST_VERSION = "2024.1.8"
private const val LATEST_VERSION = "v2024.1.8"
private const val RELEASE_DOWNLOAD_URL =
"https://github.com/JetBrains/qodana-cli/releases/download/v%s/qodana_%s_%s"
"https://github.com/JetBrains/qodana-cli/releases/download/%s/qodana_%s_%s"

fun getQodanaUrl(
platform: String = getPlatformName(),
Expand Down Expand Up @@ -70,15 +70,21 @@ class Installer {
fun getChecksum(version: String = getLatestVersion()): String {
val platform = getPlatformName()
val arch = getArchName()
return CHECKSUMS[version]?.get("${platform}_${arch}")
return CHECKSUMS[version.removePrefix("v")]?.get("${platform}_${arch}")
?: throw IllegalArgumentException("Unsupported combination of version, platform and architecture: $version ${platform}_${arch}")
}
}

fun setup(path: File, downloadURL: String = getQodanaUrl(), version: String = getLatestVersion()): String {
fun setup(
path: File,
version: String = getLatestVersion(),
): String {
val downloadURL = getQodanaUrl(version = version)
val useNightly = version == "nightly"

if (path.exists()) {
try {
verifyChecksum(path, getChecksum(version))
if (!useNightly) verifyChecksum(path, getChecksum(version))
return path.absolutePath
} catch (e: IOException) {
log.warning("Checksum verification failed. Redownloading the binary.")
Expand All @@ -88,7 +94,7 @@ class Installer {

try {
download(downloadURL, path)
verifyChecksum(path, getChecksum(version))
if (!useNightly) verifyChecksum(path, getChecksum(version))
} catch (e: IOException) {
throw IOException("Unable to download latest qodana binary", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class QodanaPlugin : Plugin<Project> {
project.file(extension.qodanaPath)
})
arguments.convention(listOf())
useNightly.convention(false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import java.io.File

@UntrackedTask(because = "Qodana tracks the state") // TODO:
open class QodanaScanTask : Exec() {
private val currentPath = System.getenv("PATH")
private val currentHome = System.getenv("HOME")

/**
* Root directory of the project to be analyzed.
*/
Expand Down Expand Up @@ -64,11 +67,27 @@ open class QodanaScanTask : Exec() {
@Optional
val arguments: ListProperty<String> = objectFactory.listProperty(String::class.java)


/**
* Use a nightly version of Qodana CLI.
*/
@Input
@Optional
val useNightly = objectFactory.property<Boolean>()

@TaskAction
override fun exec() {
setArgs(getArguments())
executable = Installer().setup(qodanaPath.get())

executable = (if (useNightly.get()) "nightly" else Installer.getLatestVersion()).let {
Installer().setup(
qodanaPath.get(),
version = it
)
}
environment(QODANA_ENV, QODANA_ENV_NAME)
environment("PATH", currentPath)
environment("HOME", currentHome)

ByteArrayOutputStream().use { os ->
standardOutput = TeeOutputStream(System.out, os)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class QodanaScanTaskTest : BaseTest() {
}

@Test
fun `run qodana in a non-empty directory and fail with threshold`() {
fun `run qodana in a container in a non-empty directory and fail with threshold`() {
val githubActions = "true".equals(System.getenv("GITHUB_ACTIONS"), ignoreCase = true)
val isLinux = System.getProperty("os.name").contains("Linux")
if (githubActions) {
Expand All @@ -60,6 +60,29 @@ class QodanaScanTaskTest : BaseTest() {
assertTrue(e.message!!.contains("The number of problems exceeds"))
}
}
//
// @Test
// fun `run qodana in a non-empty directory and fail a with threshold`() {
// buildFile.groovy("""
// $EXTENSION_NAME {
// }
// $QODANA_SCAN_TASK_NAME {
// environment = [
// "QD_PRODUCT_INTERNAL_FEED" : "https://data.services.jetbrains.com/products",
// "QODANA_LICENSE_ONLY_TOKEN": "",
// ]
// arguments = ["--fail-threshold", "0", "--property=idea.headless.enable.statistics=false"]
// useNightly = true
// }
// """.trimIndent())
// file("main.py").writeText("print('Hello, world!')\n\n\n\n\n\nprintln()")
// file("qodana.yaml").writeText("ide: QDPY-EAP")
// try {
// runTaskForCommand(QODANA_SCAN_TASK_NAME)
// } catch (e: Exception) {
// assertTrue(e.message!!.contains("The number of problems exceeds"))
// }
// }

@Test
fun `task loads from the configuration cache`() {
Expand Down
Loading