At Q2BSTUDIO we present you a method to simplify the package structure in Kotlin projects by applying a single OpenRewrite recipe to flatten folders quickly and efficiently
The technique consists of analyzing the current package configuration, identifying old organization patterns, and creating a custom recipe that relocates classes to the root level according to a defined pattern
Steps to create and test the OpenRewrite recipe
1 Analyze the current project structure and detect unnecessary nesting
2 Define a Java Kotlin recipe class that implements RewriteRecipe and configure a visitor that replaces nested packages with flat packages
3 Compile and register the recipe in a yaml or properties file to integrate it into code analysis
4 Run OpenRewrite apply in dry run mode to validate that class relocation is performed without compilation errors
5 Adjust package renaming rules and exclude specific files or modules if necessary
6 Confirm the changes and apply the recipe across the entire project to achieve a flat, easy-to-maintain package structure
The advantage of using a single recipe lies in automating large-scale migrations, reducing complexity when creating new modules, and improving code readability
At Q2BSTUDIO we are experts in custom applications and custom software, in addition to offering solutions in artificial intelligence ai for businesses and ai agents, guaranteeing high standards of cybersecurity
We also provide aws and azure cloud services and business intelligence services with power bi integrations to enhance decision-making in your organization
Trust Q2BSTUDIO to optimize Kotlin projects with OpenRewrite and take your company to the next level





