Skip to content

Commit

Permalink
Add kradlew files with default config.
Browse files Browse the repository at this point in the history
  • Loading branch information
buijs-dev committed Oct 22, 2023
1 parent f0878c9 commit 6aa46a6
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.0.0
* Copies kradle-wrapper distribution to new project.
* Uses kradlew.yaml instead of klutter.yaml.
* Uses kradle.yaml instead of klutter.yaml.
* Bump SDK constraints to >=2.17.6 <4.0.0.
* Uses Klutter Gradle v2023.3.1.beta.
* Uses klutter_ui 1.0.1.
Expand Down
4 changes: 3 additions & 1 deletion lib/res/kradle.env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
cache={{user.home}}/.kradle/cache/
cache={{system.user.home}}/.kradle/cache/
output.path={{project.build}}/klutter
skip.codegen=false
4 changes: 2 additions & 2 deletions lib/res/kradle.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bom-version: "2023.3.1.beta"
flutter-version: "3.10.6"
bom-version: '2023.3.1.beta'
flutter-version: '3.10.6'
2 changes: 1 addition & 1 deletion lib/res/kradlew
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH=$APP_HOME/lib/kradle-standalone.jar
CLASSPATH=./kradle/kradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
Expand Down
16 changes: 9 additions & 7 deletions lib/src/cli/command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ class Command {
return null;
}

final taskName = arguments.removeAt(0).toTaskNameOrNull;
final taskName = arguments.first.toTaskNameOrNull;

if (taskName == null) {
return null;
}

final args = arguments.sublist(1, arguments.length);

if (script == ScriptName.consumer) {
if (taskName == TaskName.init) {
if (arguments.isEmpty) {
Expand All @@ -70,11 +72,11 @@ class Command {
}

if (taskName == TaskName.add) {
if (arguments.length != 1) {
if (args.length != 1) {
return null;
}

final option = arguments.first.split("=");
final option = args.first.split("=");

if (option.length != 2) {
return null;
Expand All @@ -93,13 +95,13 @@ class Command {

if (script == ScriptName.producer) {
if (taskName == TaskName.init) {
if (arguments.length > 2) {
if (args.length > 2) {
return null;
}

final options = <ScriptOption, String>{};

for (final arg in arguments) {
for (final arg in args) {
final option = arg.split("=");

if (option.length != 2) {
Expand Down Expand Up @@ -128,11 +130,11 @@ class Command {
}

if (taskName == TaskName.get) {
if (arguments.length != 1) {
if (args.length != 1) {
return null;
}

final option = arguments.first.split("=");
final option = args.first.split("=");

if (option.length != 2) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/task_consumer_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ConsumerAdd extends Task {

registerPlugin(
pathToRoot: pathToRoot,
pluginName: ":klutter:$options",
pluginName: ":klutter:${options[ScriptOption.lib]}",
pluginLocation: location,
);
}
Expand Down
28 changes: 0 additions & 28 deletions lib/src/producer/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,6 @@ class PlatformModule {
/// The root/platform/src/iosMain/kotlin/<organisation>/platform/ folder.
final Directory iosMain;

/// Get the path to the cached Flutter SDK installation
/// as configured in the root-project/kradle.yaml File.
///
/// Returns [String] path to Flutter SDK installation or blank if not found.
///
/// {@category producer}
String get findFlutterSDK =>
root
.resolveFile("/../kradle.yaml".normalize)
.readAsLinesSync()
.map((line) {
if (line.contains("flutter-version:")) {
final start = line.indexOf("'") + 1;
final end = line.lastIndexOf("'");
return line.substring(start, end);
} else {
return null;
}
}).firstWhere((line) => line != null) ??
"";

/// Create the source folders:
/// - androidMain
/// - commonMain
Expand Down Expand Up @@ -293,13 +272,6 @@ class PlatformModule {
|
| include("bill-of-materials")
|}
|
|ksp {
| arg("klutterScanFolder", project.buildDir.absolutePath)
| arg("klutterOutputFolder", project.projectDir.parentFile.absolutePath)
| arg("klutterGenerateAdapters", "true")
| arg("flutterVersion", "$findFlutterSDK")
|}
|
|kotlin {
|
Expand Down
7 changes: 0 additions & 7 deletions test/src/producer/platform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,6 @@ void main() {
include("bill-of-materials")
}
ksp {
arg("klutterScanFolder", project.buildDir.absolutePath)
arg("klutterOutputFolder", project.projectDir.parentFile.absolutePath)
arg("klutterGenerateAdapters", "true")
arg("flutterVersion", "3.0.5.macos.arm64")
}
kotlin {
android()
Expand Down
12 changes: 6 additions & 6 deletions test/src/systemtest/e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,19 @@ void main() {
arguments: ["init"],
);

final registry =
File("${consumerPlugin.absolutePath}/.klutter-plugins".normalize);

expect(registry.existsSync(), true,
reason: "klutter-plugins file should be created");

/// Add plugin to consumer project.
await sut.execute(
pathToRoot: consumerPlugin.absolutePath,
script: sut.ScriptName.consumer,
arguments: ["add", "lib=$pluginName"],
);

final registry =
File("${consumerPlugin.absolutePath}/.klutter-plugins".normalize);

expect(registry.existsSync(), true,
reason: "klutter-plugins file should be created");

final registryContainsPlugin =
registry.readAsStringSync().contains(pluginName);

Expand Down

0 comments on commit 6aa46a6

Please sign in to comment.