Skip to content

fix: Upgrading from deprecated imperative apply of gradle's plugin to plugin DSL #453

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

Merged
merged 4 commits into from
Mar 17, 2025
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
**/.cxx/

# IntelliJ related
*.iml
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"editor.tabSize": 4,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
},
"java.configuration.updateBuildConfiguration": "interactive"
}
19 changes: 9 additions & 10 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,16 +22,14 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 34
namespace "com.ccextractor.taskwarriorflutter"
compileSdkVersion 35

// compileSdkVersion flutter.compileSdkVersion

Expand Down Expand Up @@ -78,5 +77,5 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

}
13 changes: 0 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
30 changes: 22 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}

include ":app"
147 changes: 76 additions & 71 deletions lib/app/modules/home/controllers/widget.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class WidgetController extends GetxController {
final HomeController storageWidget = Get.find<HomeController>();
late Storage storage;
late final Filters filters; // Use RxList for observable list
List<ChartSeries> dailyBurnDown = [];
List<CartesianSeries> dailyBurnDown = [];
Directory? baseDirectory;
RxList<Task> allData = <Task>[].obs; // Use RxList for observable list
bool stopTraver = false;
Expand All @@ -31,103 +31,108 @@ class WidgetController extends GetxController {
// var currentProfile = ProfilesWidget.of(context!).currentProfile;
var currentProfile = Get.find<SplashController>().currentProfile.value;
baseDirectory = Get.find<SplashController>().baseDirectory();
storage =
storage =
Storage(Directory('${baseDirectory!.path}/profiles/$currentProfile'));
allData.assignAll(storage.data.allData());
sendAndUpdate();
}
}

Future<void> sendAndUpdate() async {
await sendData();
await updateWidget();
}

Future<void> sendData() async {
final HomeController taskController = Get.find<HomeController>();
int lengthBeforeFilters = allData.length;
List<Task> tasks = allData;
debugPrint('Tasks: ${tasks.length}, ${taskController.projectFilter}, ${taskController.pendingFilter.value}, ${taskController.selectedSort.value}');
if (taskController.projectFilter.value != 'All Projects'&&taskController.projectFilter.toString().isNotEmpty) {
tasks = tasks.where((task) => task.project == taskController.projectFilter.value).toList();
debugPrint(
'Tasks: ${tasks.length}, ${taskController.projectFilter}, ${taskController.pendingFilter.value}, ${taskController.selectedSort.value}');
if (taskController.projectFilter.value != 'All Projects' &&
taskController.projectFilter.toString().isNotEmpty) {
tasks = tasks
.where((task) => task.project == taskController.projectFilter.value)
.toList();
} else {
tasks = List<Task>.from(tasks);
}

// Apply other filters and sorting
tasks.sort((a, b) => a.id!.compareTo(b.id!));

tasks = tasks.where((task) {
if (taskController.pendingFilter.value) {
return task.status == 'pending';
} else {
tasks = List<Task>.from(tasks);
return task.status == 'completed';
}
}).toList();

// Apply other filters and sorting
tasks.sort((a, b) => a.id!.compareTo(b.id!));

tasks = tasks.where((task) {
if (taskController.pendingFilter.value) {
return task.status == 'pending';
} else {
return task.status == 'completed';
tasks = tasks.where((task) {
var tags = task.tags?.toSet() ?? {};
if (taskController.tagUnion.value) {
if (taskController.selectedTags.isEmpty) {
return true;
}
}).toList();
return taskController.selectedTags.any((tag) => (tag.startsWith('+'))
? tags.contains(tag.substring(1))
: !tags.contains(tag.substring(1)));
} else {
return taskController.selectedTags.every((tag) => (tag.startsWith('+'))
? tags.contains(tag.substring(1))
: !tags.contains(tag.substring(1)));
}
}).toList();

tasks = tasks.where((task) {
var tags = task.tags?.toSet() ?? {};
if (taskController.tagUnion.value) {
if (taskController.selectedTags.isEmpty) {
return true;
}
return taskController.selectedTags.any((tag) => (tag.startsWith('+'))
? tags.contains(tag.substring(1))
: !tags.contains(tag.substring(1)));
} else {
return taskController.selectedTags.every((tag) => (tag.startsWith('+'))
? tags.contains(tag.substring(1))
: !tags.contains(tag.substring(1)));
}
}).toList();

// Apply sorting based on selectedSort
tasks.sort((a, b) {
switch (taskController.selectedSort.value) {
case 'Created+':
return a.entry.compareTo(b.entry);
case 'Created-':
return b.entry.compareTo(a.entry);
case 'Modified+':
return a.modified!.compareTo(b.modified!);
case 'Modified-':
return b.modified!.compareTo(a.modified!);
case 'Due till+':
return a.due!.compareTo(b.due!);
case 'Due till-':
return b.due!.compareTo(a.due!);
case 'Priority-':
return a.priority!.compareTo(b.priority!);
case 'Priority+':
return b.priority!.compareTo(a.priority!);
case 'Project+':
return a.project!.compareTo(b.project!);
case 'Project-':
return b.project!.compareTo(a.project!);
case 'Urgency-':
return b.urgency!.compareTo(a.urgency!);
case 'Urgency+':
return a.urgency!.compareTo(b.urgency!);
default:
return 0;
}
});
// Apply sorting based on selectedSort
tasks.sort((a, b) {
switch (taskController.selectedSort.value) {
case 'Created+':
return a.entry.compareTo(b.entry);
case 'Created-':
return b.entry.compareTo(a.entry);
case 'Modified+':
return a.modified!.compareTo(b.modified!);
case 'Modified-':
return b.modified!.compareTo(a.modified!);
case 'Due till+':
return a.due!.compareTo(b.due!);
case 'Due till-':
return b.due!.compareTo(a.due!);
case 'Priority-':
return a.priority!.compareTo(b.priority!);
case 'Priority+':
return b.priority!.compareTo(a.priority!);
case 'Project+':
return a.project!.compareTo(b.project!);
case 'Project-':
return b.project!.compareTo(a.project!);
case 'Urgency-':
return b.urgency!.compareTo(a.urgency!);
case 'Urgency+':
return a.urgency!.compareTo(b.urgency!);
default:
return 0;
}
});
List<Map<String, String>> l = [];
for (var task in tasks) {
l.add({
"description": task.description,
"urgency": 'urgencyLevel : ${urgency(task)}',
"uuid": task.uuid,
"priority": task.priority ?? "N"
});
l.add({
"description": task.description,
"urgency": 'urgencyLevel : ${urgency(task)}',
"uuid": task.uuid,
"priority": task.priority ?? "N"
});
}
if (l.isEmpty&&lengthBeforeFilters>0) {
if (l.isEmpty && lengthBeforeFilters > 0) {
l.add({
"description": "No tasks found because of filter",
"urgency": "urgencyLevel : 0",
"priority": "2",
"uuid": "NO_TASK"
});
}else if(l.isEmpty&&lengthBeforeFilters==0){
} else if (l.isEmpty && lengthBeforeFilters == 0) {
l.add({
"description": "No tasks found",
"urgency": "urgencyLevel : 0",
Expand Down
5 changes: 4 additions & 1 deletion lib/app/modules/reports/views/burn_down_weekly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class BurnDownWeekly extends StatelessWidget {
),
primaryYAxis: NumericAxis(
title: AxisTitle(
text: SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.reportsPageTasks,
text: SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.reportsPageTasks,
textStyle: TextStyle(
fontFamily: FontFamily.poppins,
fontWeight: TaskWarriorFonts.bold,
Expand Down
3 changes: 1 addition & 2 deletions lib/app/services/notification_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ class NotificationService {
notificationDetails,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
// ignore: deprecated_member_use
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle)
androidScheduleMode: AndroidScheduleMode.alarmClock)
.then((value) {
if (kDebugMode) {
print('Notification scheduled successfully');
Expand Down
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
#include "generated_plugin_registrant.h"

#include <file_selector_linux/file_selector_plugin.h>
#include <flutter_timezone/flutter_timezone_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
g_autoptr(FlPluginRegistrar) flutter_timezone_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterTimezonePlugin");
flutter_timezone_plugin_register_with_registrar(flutter_timezone_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
flutter_timezone
url_launcher_linux
)

Expand Down
6 changes: 2 additions & 4 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import file_picker
import file_picker_writable
import file_selector_macos
import flutter_local_notifications
import flutter_native_timezone
import flutter_timezone
import package_info_plus
import path_provider_foundation
import permission_handler_apple
import shared_preferences_foundation
import sqflite_darwin
import url_launcher_macos
Expand All @@ -24,10 +23,9 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FilePickerWritablePlugin.register(with: registry.registrar(forPlugin: "FilePickerWritablePlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterNativeTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterNativeTimezonePlugin"))
FlutterTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterTimezonePlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
PermissionHandlerPlugin.register(with: registry.registrar(forPlugin: "PermissionHandlerPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
Expand Down
Loading
Loading