Skip to content

Commit 8396974

Browse files
authored
Use gradle build directly for dev build (#8387)
This changes over to using gradle for writing the JX Browser key and setting the dev version number, which allows us to call `./gradlew build` for building the dev release instead of using the plugin tool. Note that the plugin tool is still being used to upload the dev build to jetbrains. I think the next step is removing the gradle build command from the plugin tool and auditing the rest of the commands in the plugin tool to see if we can remove more. I ran a test of building dev from this branch, but I'll wait to make sure this works over the weekend before proceeding.
1 parent d7708c7 commit 8396974

File tree

7 files changed

+88
-38
lines changed

7 files changed

+88
-38
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,3 @@ lib/kotlin*
4848
/build/
4949
gradle-app.setting
5050
gradle/wrapper/gradle-wrapper.jar
51-
52-
# User specific configuration based on current Intellij SDKs.
53-
gradle.properties

build.gradle.kts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import org.jetbrains.intellij.platform.gradle.models.ProductRelease
1212
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
1313
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1414
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
15+
import java.io.File
16+
import java.time.LocalDate
17+
import java.time.format.DateTimeFormatter
1518

1619
// Specify UTF-8 for all compilations so we avoid Windows-1252.
1720
allprojects {
@@ -39,7 +42,11 @@ plugins {
3942
id("org.jetbrains.kotlin.jvm") version "2.2.0" // Kotlin support
4043
}
4144

42-
val flutterPluginVersion = providers.gradleProperty("flutterPluginVersion").get()
45+
var flutterPluginVersion = providers.gradleProperty("flutterPluginVersion").get()
46+
if (project.hasProperty("dev-version")) {
47+
val datestamp = DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now())
48+
flutterPluginVersion = project.property("dev-version").toString() + "-dev." + datestamp
49+
}
4350
val ideaVersion = providers.gradleProperty("ideaVersion").get()
4451
val dartPluginVersion = providers.gradleProperty("dartPluginVersion").get()
4552
val sinceBuildInput = providers.gradleProperty("sinceBuild").get()
@@ -267,3 +274,47 @@ tasks.register("printCompileClasspath") {
267274
println("--- End Compile Classpath ---")
268275
}
269276
}
277+
278+
// This finds the JxBrowser license key from the environment and writes it to a file.
279+
// This is only used by the dev build on kokoro for now.
280+
val writeLicenseKey = tasks.register("writeLicenseKey") {
281+
group = "build"
282+
description = "Writes the license key from an environment variable to a file."
283+
284+
// Find the output file
285+
val outputDir = rootProject.file("resources/jxbrowser")
286+
val licenseFile = outputDir.resolve("jxbrowser.properties")
287+
outputs.file(licenseFile)
288+
289+
doLast {
290+
// Read the license key from the environment variable
291+
val base = System.getenv("KOKORO_KEYSTORE_DIR")
292+
val id = System.getenv("FLUTTER_KEYSTORE_ID")
293+
val name = System.getenv("FLUTTER_KEYSTORE_JXBROWSER_KEY_NAME")
294+
295+
val readFile = File(base + "/" + id + "_" + name)
296+
if (readFile.isFile) {
297+
val licenseKey = readFile.readText(Charsets.UTF_8)
298+
licenseFile.writeText("jxbrowser.license.key=$licenseKey")
299+
} else {
300+
println("$readFile is not a file")
301+
}
302+
}
303+
}
304+
305+
tasks.named("buildPlugin") {
306+
dependsOn(writeLicenseKey)
307+
}
308+
309+
tasks.named("processResources") {
310+
dependsOn(writeLicenseKey)
311+
}
312+
313+
// TODO(helin24): Find a better way to skip checking this file for tests.
314+
tasks.withType<ProcessResources>().configureEach {
315+
if (name == "processTestResources") {
316+
// This block will only execute for the 'processTestResources' task.
317+
// The context here is unambiguously the task itself.
318+
exclude("jxbrowser/jxbrowser.properties")
319+
}
320+
}

gradle.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright 2025 The Chromium Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
#
6+
7+
# Change to version when releasing, e.g.
8+
#flutterPluginVersion=87.0.1
9+
flutterPluginVersion=SNAPSHOT
10+
ideaVersion=2024.3.1.7
11+
dartPluginVersion= 243.21565.120
12+
sinceBuild=243
13+
untilBuild=253.*
14+
javaVersion=21
15+
kotlin.stdlib.default.dependency=false
16+
org.gradle.parallel=true
17+
org.gradle.jvmargs=-Xms1024m -Xmx4048m

tool/kokoro/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ setup
55

66
echo "kokoro build start"
77

8-
./bin/plugin make --channel=dev
8+
./third_party/gradlew buildPlugin
99

1010
echo "kokoro build finished"

tool/kokoro/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ setup
55

66
echo "kokoro build start"
77

8-
./bin/plugin make --channel=dev
8+
./third_party/gradlew buildPlugin -Pdev-version=88.0
99

1010
echo "kokoro build finished"
1111

tool/plugin/lib/plugin.dart

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -418,34 +418,29 @@ class DeployCommand extends ProductCommand {
418418

419419
@override
420420
Future<int> doit() async {
421-
if (isReleaseMode) {
422-
if (!await performReleaseChecks(this)) {
423-
return 1;
424-
}
425-
} else if (!isDevChannel) {
426-
log('Deploy must have a --release or --channel=dev argument');
421+
if (!isDevChannel) {
422+
log('Deploy must have --channel=dev argument');
427423
return 1;
428424
}
429425

430426
var token = readTokenFromKeystore('FLUTTER_KEYSTORE_NAME');
431427
var value = 0;
432428
var originalDir = Directory.current;
433-
for (var spec in specs) {
434-
if (spec.channel != channel) continue;
435-
var filePath = releasesFilePath(spec);
436-
log("uploading $filePath");
437-
var file = File(filePath);
438-
changeDirectory(file.parent);
439-
var pluginNumber = pluginRegistryIds[spec.pluginId];
440-
value = await upload(
441-
p.basename(file.path),
442-
pluginNumber!,
443-
token,
444-
spec.channel,
445-
);
446-
if (value != 0) {
447-
return value;
448-
}
429+
var filePath = p.join(
430+
rootPath,
431+
'build/distributions/flutter-intellij-kokoro.zip',
432+
);
433+
log("uploading $filePath");
434+
var file = File(filePath);
435+
changeDirectory(file.parent);
436+
value = await upload(
437+
p.basename(file.path),
438+
'9212', // plugin registry ID for io.flutter
439+
token,
440+
'dev',
441+
);
442+
if (value != 0) {
443+
return value;
449444
}
450445
changeDirectory(originalDir);
451446
return value;

tool/plugin/test/plugin_test.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,6 @@ void main() {
162162
});
163163
expect(cmd.paths, orderedEquals([]));
164164
});
165-
166-
test('release paths', () async {
167-
var runner = makeTestRunner();
168-
late TestDeployCommand cmd;
169-
await runner.run(["--release=19", "-d../..", "deploy"]).whenComplete(() {
170-
cmd = (runner.commands['deploy'] as TestDeployCommand);
171-
});
172-
var specs = cmd.specs.where((s) => s.isStableChannel).toList();
173-
expect(cmd.paths.length, specs.length);
174-
});
175165
});
176166

177167
group('build', () {

0 commit comments

Comments
 (0)