Skip to content
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
1 change: 1 addition & 0 deletions kokoro/macos_external/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build_file: "dart-intellij-third-party/kokoro/macos_external/kokoro_build.sh"
14 changes: 14 additions & 0 deletions kokoro/macos_external/kokoro_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# This script should execute after a commit.
date
echo "Automatic build started"

# Fail on any error.
set -e


# Code under repo is checked out to ${KOKORO_ARTIFACTS_DIR}/github.
cd ${KOKORO_ARTIFACTS_DIR}/github/dart-intellij-third-party

./third_party/tool/kokoro/build.sh
13 changes: 13 additions & 0 deletions kokoro/macos_external/kokoro_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# This script should execute during the scheduled builds.
date
echo "Automatic build started"

# Fail on any error.
set -e

# Code under repo is checked out to ${KOKORO_ARTIFACTS_DIR}/github.
cd ${KOKORO_ARTIFACTS_DIR}/github/dart-intellij-third-party

./third_party/tool/kokoro/deploy.sh
1 change: 1 addition & 0 deletions kokoro/macos_external/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build_file: "dart-intellij-third-party/kokoro/macos_external/kokoro_build.sh"
8 changes: 8 additions & 0 deletions kokoro/macos_external/release.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build_file: "dart-intellij-third-party/kokoro/macos_external/kokoro_release.sh"

action {
define_artifacts {
regex: "github/dart-intellij-third-party/third_party/build/distributions/*.zip"
strip_prefix: "github/dart-intellij-third-party/third_party/build"
}
}
31 changes: 30 additions & 1 deletion third_party/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
import java.time.LocalDate
import java.time.format.DateTimeFormatter

// Specify UTF-8 for all compilations so we avoid Windows-1252.
allprojects {
Expand Down Expand Up @@ -34,13 +36,34 @@ repositories {

intellijPlatform {
pluginConfiguration {
var pluginVersion = providers.gradleProperty("pluginVersion").toString()

if (project.hasProperty("dev")) {
val latestVersion = changelog.getLatest().version
val majorVersion = latestVersion.substringBefore('.').toInt()
val nextMajorVersion = majorVersion + 1
val datestamp = DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now())
pluginVersion = "$nextMajorVersion.0.0-dev.$datestamp"

val commitHash = System.getenv("KOKORO_GIT_COMMIT")
if (commitHash is String) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] Using is String to check if an environment variable exists is unidiomatic. System.getenv() returns a nullable String?. A clearer way to perform a null check in Kotlin is using != null or a scope function like .let.

           if (commitHash != null) {
References
  1. Per the style guide, use of idiomatic Kotlin, such as for null safety, is preferred. The double-bang !! operator is forbidden, and safe calls ?., elvis operator ?:, or standard null checks should be used instead. While is String works, != null is more direct and idiomatic for this check. (link)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is String reads a bit better to me but I'm ambivalent.

@helin24: if you feel strongly, happy to tweak.

val shortCommitHash = commitHash.take(7)
pluginVersion = "$pluginVersion-$shortCommitHash"
}
}

version = pluginVersion
name = providers.gradleProperty("pluginName")
id = providers.gradleProperty("pluginId")
version = providers.gradleProperty("pluginVersion")

ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
}

println("plugin version: $pluginVersion")
println("ideaVersion: $ideaVersion")
Comment on lines +64 to +65
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] The repository style guide (rule #27) disallows the use of System.out.println. While this is a build script, using Gradle's own logging mechanism is a better practice for consistency and to control log levels. The logger is available by default in Gradle scripts.

        logger.lifecycle("plugin version: $pluginVersion")
        logger.lifecycle("ideaVersion: $ideaVersion")
References
  1. Style guide rule Remove the rest of the reference to "com.intellij.coverage.*" from the plugin #27 states: 'Reject any use of System.out.println or System.err.println for logging.' (link)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might consider updating the style guide to ignore gradle files but here I do think System.outs are OK (and we have others too).


changeNotes = provider {
project.changelog.renderItem(project.changelog.getLatest(), Changelog.OutputType.HTML)
}
Expand Down Expand Up @@ -157,3 +180,9 @@ tasks.register("printCompileClasspath") {
println("--- End Compile Classpath ---")
}
}

tasks.register("printVersion") {
doLast {
println(version)
}
}
11 changes: 11 additions & 0 deletions third_party/tool/kokoro/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

source ./third_party/tool/kokoro/setup.sh
setup

echo "kokoro build start"

cd third_party
./gradlew buildPlugin

echo "kokoro build finished"
40 changes: 40 additions & 0 deletions third_party/tool/kokoro/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

source ./third_party/tool/kokoro/setup.sh
setup

echo "kokoro build start"

cd third_party

VERSION=$(./gradlew -q printVersion)
./gradlew buildPlugin -Pdev

echo "kokoro build finished"

echo "kokoro deploy start"

DART_KEYSTORE_ID=74840
DART_KEYSTORE_NAME=jetbrains-plugin-upload-auth-token

KOKORO_TOKEN_FILE="${KOKORO_KEYSTORE_DIR}/${DART_KEYSTORE_ID}_${DART_KEYSTORE_NAME}"
if [ ! -f "$KOKORO_TOKEN_FILE" ]; then
echo "Error: Keystore token file not found at $KOKORO_TOKEN_FILE"
exit 1
fi
TOKEN=$(cat "$KOKORO_TOKEN_FILE")

ZIP_FILE="build/distributions/Dart-$VERSION.zip"
if [ ! -f "$ZIP_FILE" ]; then
echo "Error: Zip file not found at $ZIP_FILE"
exit 1
fi

echo "Uploading $ZIP_FILE to JetBrains Marketplace..."
curl -i \
--header "Authorization: Bearer $TOKEN" \
-F pluginId=6351 \
-F file=@$ZIP_FILE \
https://plugins.jetbrains.com/plugin/uploadPlugin

echo "kokoro deploy finished"
13 changes: 13 additions & 0 deletions third_party/tool/kokoro/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

setup() {
# Fail on any error.
set -e

java --version

# Enable verbose output for Gradle
export JAVA_OPTS=" -Djava.net.preferIPv4Stack=false -Djava.net.preferIPv6Addresses=true"

./gradlew --version
}
Loading