operaton / migrate-from-camunda-recipe

An Open Rewrite Recipe to migrate a Camunda 7 Instance to Operaton
https://www.operaton.org
4 stars 1 forks source link

Rewrite package path `org.camunda` to `org.operaton` in Java files using Camunda #14

Open javahippie opened 2 weeks ago

javahippie commented 2 weeks ago

Is your feature request related to a problem? Please describe. The script needs to rewrite imports and fully qualified references in the code to the new path. It also needs to rename classes with "Camunda" in the name to "Operaton"

MBoegers commented 2 weeks ago

Hi Tim, for this the Rename package name should do the trick.

Please be aware that any module-info.java, especially the exports/imports are not migrated because the java parser do not handle them correctly ATM.

javahippie commented 2 weeks ago

Hi Merlin,

thanks for the pointer, already had that one in an experiment locally :)

It's working recursively, too, which is nice. Do you know a way to apply this with subpackages, also?

For example, we have a package org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue. If I use this rule:

  - org.openrewrite.java.ChangePackage:
      oldPackageName: org.camunda
      newPackageName: org.operaton
      recursive: true

Then the package is renamed to org.operaton.bpm.model.bpmn.instance.camunda.CamundaValue. I did not find an existing recipe for this, so my assumption is that I have to implement one, overriding the visitPackage method by myself, if I don't want to explicitly mention every package on it's own but act on a pattern?

MBoegers commented 2 weeks ago

No ATM package names are always use full-match. Supprisingly GAVs in Maven and Gradle support glob, this would be an interesting addition to the ChangePackage.

Because I see it, there is no recipe to rename all classes that contain 'Camunda' they have to be handles one by one with the org.openrewrite.java.ChangeType recipe.