Skip to content

Commit

Permalink
Prepare for 3.0.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
buijs-dev committed May 12, 2024
1 parent 7face23 commit bfdf626
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 13 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
* Use klutter_ui 1.1.0.
* Use Klutter Gradle v2024.1.1.beta with support for protobuf.
* Move post-build tasks in root/platform build.gradle.kts to gradle plugin.
* Add kradle script (which replaces producer and consumer).
* Add interactive cli mode.
* Add project create and build tasks.
* Remove producer and consumer scripts.
* Add kradle script.
* Refactor library to enable generating a native executable.

## 2.0.0
* Uses AGP 8.0.2 in projects.
Expand Down
5 changes: 4 additions & 1 deletion dartdoc_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ dartdoc:
"gradle":
markdown: doc/gradle.md
name: gradle
categoryOrder: ["consumer", "producer", "gradle"]
"tasks":
markdown: doc/tasks.md
name: tasks
categoryOrder: ["consumer", "producer", "gradle", "tasks"]
4 changes: 2 additions & 2 deletions doc/consumer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ and Frameworks for iOS. A standard Flutter project won't be able to find
these artifacts for a Klutter plugin which means they won't work.

To work with Klutter plugins the following 2 tasks are required:
- consumer init (initialize Klutter in your project)
- consumer add (add a Klutter plugin to your project)
- kradle init (initialize Klutter in your project)
- kradle add (add a Klutter plugin to your project)
2 changes: 1 addition & 1 deletion doc/gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ roughly does two things:

Gradle needs to be installed to be able to do all this.
Even though Flutter installs gradle wrapper in the android folder,
Klutter adds it's own wrapper files to producer project.
Klutter adds its own wrapper files to producer project.

This is done to make sure all Gradle versions within the Klutter project
are aligned and to make the Gradle distributions between consumer
Expand Down
3 changes: 2 additions & 1 deletion doc/producer.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ A producer project is basically a Flutter plugin project with an extra
Kotlin Multiplatform module where all (native) platform code will be written.

The following producer tasks are available:
- producer init (initialize Klutter in your project)
- kradle create (create new klutter project)
- kradle init (initialize Klutter in an existing flutter project)
1 change: 1 addition & 0 deletions doc/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Klutter tasks are used to create, build and manage klutter projects and their dependencies.
4 changes: 4 additions & 0 deletions lib/src/cli/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import "cli.dart";
import "context.dart";

/// Interface to encapsulate CLI task functionality.
/// {@category tasks}
abstract class Task<T> {
/// Create a new [Task].
Task(this.taskName, this.taskOptions);
Expand Down Expand Up @@ -123,6 +124,7 @@ abstract class Task<T> {
/// List of available tasks.
///
/// The task functionality depends on the calling script.
/// {@category tasks}
enum TaskName {
/// Tasks which adds libraries.
add,
Expand Down Expand Up @@ -150,6 +152,7 @@ enum TaskName {
}

/// Convert a String value to a [TaskName].
/// {@category tasks}
extension TaskNameParser on String? {
/// Find a [TaskName] that matches the current
/// (trimmed) String value or return null.
Expand Down Expand Up @@ -187,6 +190,7 @@ extension TaskNameParser on String? {
///
/// {@category consumer}
/// {@category producer}
/// {@category tasks}
enum TaskOption {
/// The Klutter (Gradle) BOM version.
bom,
Expand Down
1 change: 1 addition & 0 deletions lib/src/cli/task_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import "task.dart";
/// Task to add a Klutter-made Flutter plugin to a Flutter project.
///
/// {@category consumer}
/// {@category tasks}
class AddLibrary extends Task {
/// Create new Task based of the root folder.
AddLibrary()
Expand Down
1 change: 1 addition & 0 deletions lib/src/cli/task_build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import "context.dart";
/// and ios sub modules.
///
/// {@category gradle}.
/// {@category tasks}
class BuildProject extends Task {
/// Create new Task.
BuildProject({Executor? executor})
Expand Down
3 changes: 3 additions & 0 deletions lib/src/cli/task_clean_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "cli.dart";
import "context.dart";

/// Clean the kradle cache by deleting contents recursively.
/// {@category tasks}
class CleanCache extends Task {
/// Create new Task.
CleanCache([CacheProvider? cacheProvider])
Expand Down Expand Up @@ -69,6 +70,7 @@ class CleanCache extends Task {
}

/// Result of task [CleanCache].
/// {@category tasks}
class CleanCacheResult {
/// Create a new instance of [CleanCacheResult].
const CleanCacheResult(this.deleted, this.notDeletedByError);
Expand All @@ -82,6 +84,7 @@ class CleanCacheResult {

/// Wrapper to provide the kradle cache directory
/// based on [Context] and [TaskOption] input.
/// {@category tasks}
class CacheProvider {
/// Return the files and directory in the kradle cache directory.
List<FileSystemEntity> getCacheContent(
Expand Down
11 changes: 9 additions & 2 deletions lib/src/cli/task_get_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import "context.dart";
///
/// {@category consumer}
/// {@category producer}
/// {@category tasks}
class GetFlutterSDK extends Task<Directory> {
/// Create new Task.
GetFlutterSDK()
Expand Down Expand Up @@ -96,8 +97,9 @@ class GetFlutterSDK extends Task<Directory> {
}

target.listSync(recursive: true).forEach((element) {
if(element is File) {
Process.runSync("chmod", runInShell: true, ["755", element.absolutePath]);
if (element is File) {
Process.runSync(
"chmod", runInShell: true, ["755", element.absolutePath]);
}
});

Expand All @@ -113,6 +115,7 @@ class GetFlutterSDK extends Task<Directory> {

/// Find applicable [FlutterDistribution] for the current
/// [OperatingSystem] and [Architecture] or throw [KlutterException].
/// {@category tasks}
FlutterDistribution toFlutterDistributionOrThrow(
{required VerifiedFlutterVersion version,
required String pathToRoot,
Expand Down Expand Up @@ -141,6 +144,7 @@ FlutterDistribution toFlutterDistributionOrThrow(
return FlutterDistribution(version: version.version, os: os!, arch: arch);
}

/// {@category tasks}
Map<FlutterDistribution, String> get _compatibleFlutterVersions {
final dist = [
_windows(
Expand Down Expand Up @@ -203,6 +207,7 @@ Map<FlutterDistribution, String> get _compatibleFlutterVersions {
}

/// A flutter distribution which is compatible with klutter.
/// {@category tasks}
@immutable
class FlutterDistribution {
/// Create a new [FlutterDistribution] instance.
Expand Down Expand Up @@ -266,6 +271,7 @@ class FlutterDistribution {
///The full Flutter distribution version in format major.minor.patch (platform architecture).
///
/// Example: 3.0.5 MACOS (ARM64).
/// {@category tasks}
@immutable
class PrettyPrintedFlutterDistribution {
/// Create a new [PrettyPrintedFlutterDistribution] instance.
Expand All @@ -283,6 +289,7 @@ class PrettyPrintedFlutterDistribution {
/// The full Flutter distribution version in format major.minor.patch.platform.architecture.
///
/// Example: 3.0.5.windows.x64.
/// {@category tasks}
@immutable
class FlutterDistributionFolderName {
/// Create a new [FlutterDistributionFolderName] instance.
Expand Down
4 changes: 3 additions & 1 deletion lib/src/cli/task_project_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import "../common/common.dart";
import "cli.dart";
import "context.dart";

/// Task
/// Task to create a new klutter project.
/// {@category tasks}
/// {@category producer}
class CreateProject extends Task {
/// Create new Task.
CreateProject(
Expand Down
1 change: 1 addition & 0 deletions lib/src/cli/task_project_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const _resourceTarUrl =
///
/// {@category consumer}
/// {@category producer}
/// {@category tasks}
class ProjectInit extends Task {
/// Create new Task based of the root folder.
ProjectInit()
Expand Down
1 change: 1 addition & 0 deletions lib/src/cli/task_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
///
/// [isOk] is true when task is finished without exceptions or false when not.
/// [message] contains the exception message or is null when task was successful.
/// {@category tasks}
class TaskResult<T> {
/// Create a new result with a message if there was an exception.
const TaskResult({
Expand Down
2 changes: 2 additions & 0 deletions lib/src/cli/task_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import "task_project_create.dart";
import "task_project_init.dart";

/// Service for available tasks.
/// {@category tasks}
class TaskService {
/// Get the [Task] with [TaskName] or null.
Task? toTask(TaskName taskName) {
Expand Down Expand Up @@ -59,6 +60,7 @@ class TaskService {
///
/// {@category producer}
/// {@category consumer}
/// {@category tasks}
Set<Task> allTasks(

/// Injectable Task List for testing purposes.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/common/executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class Executor {

/// An (optional) list of arguments.
///
/// For example: ["clean", "build"] with [executable] "gradlew"
/// For example: "clean", "build" with [executable] "gradlew"
/// would result in a gradlew clean build to be executed from the [workingDirectory].
List<String> arguments = const [];

/// Run the command.
///
/// For example an [executable] 'gradlew'
/// with [arguments] '["clean", "build", "-p", "platform"]'
/// with [arguments] "clean", "build", "-p", "platform"
/// and [workingDirectory] './Users/Foo'
/// would result in command "./Users/Foo/gradlew clean build -p platform".
ProcessResult run() {
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dependencies:
meta: ^1.9.1

dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.4
coverage: ^1.6.4
dartdoc: ^6.1.0 # can be bumped when min SDK is 2.19.0
pana: ^0.22.2
Expand Down
4 changes: 2 additions & 2 deletions test/src/systemtest/e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void main() {

final downloadFlutterResult = await run(["get", "flutter=3.10.6"]);
expect(
downloadFlutterResult.contains(
"Task 'get flutter=3.10.6' finished successful"),
downloadFlutterResult
.contains("Task 'get flutter=3.10.6' finished successful"),
true,
reason: downloadFlutterResult);

Expand Down

0 comments on commit bfdf626

Please sign in to comment.