This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-agent-skills.git
commit 40d1dda65e2f80c560fa12796e7087e68f4b399f Author: Konrad Windszus <[email protected]> AuthorDate: Sat May 9 18:29:02 2026 +0200 Look for @Component annotation anywhere prior to class declaration Not just in the 20 lines before class declaration, as it can be further up in the file. Print warning and skip metatype generation if @Component annotation or class declaration cannot be found. --- osgi-scr-migrator/scripts/migrate_annotations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osgi-scr-migrator/scripts/migrate_annotations.py b/osgi-scr-migrator/scripts/migrate_annotations.py index 3378f11..8c647bc 100755 --- a/osgi-scr-migrator/scripts/migrate_annotations.py +++ b/osgi-scr-migrator/scripts/migrate_annotations.py @@ -944,16 +944,19 @@ class AnnotationMigrator: break if class_idx is None: + print(f"Warning: Could not find class declaration for {self.component_name}, skipping metatype generation") return # Find the @Component annotation component_idx = None - for i in range(class_idx - 1, max(0, class_idx - 20), -1): + # must be somewhere between start of file and class declaration, look backwards from class declaration + for i in range(class_idx - 1, 0, -1): if '@Component' in self.lines[i]: component_idx = i break if component_idx is None: + print(f"Warning: Could not find @Component annotation for {self.component_name}, skipping metatype generation") return # Add @Designate annotation before @Component
