Last updated Jun 11, 2024

Using OpenRewrite to automate Platform 7 migrations

About

To help with migrating some of the (breaking) changes introduced in DC Platform 7, which are rolled out as part of major releases across DC Products, we have developed some openrewrite recipes that can automate some of the repetitive changes. These recipes are published here

These recipes were developed as an experimental internal tool. We are releasing these as a courtesy to our partners, since we have seen great success using them ourselves. We will make best-effort attempts to address any problems you may run into, but these recipes do not have an official support status.

Getting started

Openrewrite runs as a Maven plugin. The easiest way to run the recipe is to add a new Maven profile to your POM file.

1
2
<profile>
  <id>openrewrite</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>5.15.4</version> <!-- This version can be newer if you want -->
        <configuration>
          <!-- This tag ensures that we first do a dry run on all modules, before doing a real run. -->
          <failOnDryRunResults>true</failOnDryRunResults>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.openrewrite.recipe</groupId>
            <artifactId>rewrite-migrate-java</artifactId>
            <!-- Ensure this uses the latest version, especially when running standard recipes -->
            <version>2.8.0</version>
          </dependency>
          <dependency>
            <groupId>com.atlassian.platform</groupId>
            <artifactId>openrewrite-recipes</artifactId>
            <!-- Replace this with the latest version of the openrewrite-recipes dependency -->
            <version>${platform.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</profile>

Before running the recipe, it is recommended to first run a mvn install on your project. This ensures the dependencies are correctly pulled in, since sometimes this can cause problems.

1
2
mvn clean install -DskipTests

After that, you can run a recipe using

1
2
mvn -Popenrewrite rewrite:run -Drewrite.activeRecipes=com.package.Recipe

Replace com.package.Recipe with the package name of your recipe to run.

This command will make the changes in place. It is recommended you manually validate the changes before creating a PR.

Available recipes

com.atlassian.platform.recipes.sal.to52x.MigrateSAL

Covers atlassian-sal upgrade guide.

com.atlassian.platform.recipes.rest.tov2.MigrateToRestV2

Covers security features and RestUrlBuilder.

AnonymousAllowed is migrated to AnonymousSiteAccess as it is the more 'restrictive'. If you actually want UnrestrictedAccess - you will need to make the changes manually

Currently does not include:

com.atlassian.platform.recipes.ao.to53x.MigrateAO

Covers activeobjects upgrade guide

com.atlassian.platform.recipes.plugins.to80x.MigrateModuleDescriptor

Covers dom4j to in-house Element migration within module descriptors only. See upgrade guide.

com.atlassian.platform.recipes.plugins.to80x.MigrateTypes

Covers the package restructuring changes in atlassian-plugins. See upgrade guide.

com.atlassian.platform.recipes.webfragment.to70x.MigrateTypes

Covers moved types in webfragments. Does not address calls to now inaccessible API.

com.atlassian.platform.recipes.wrm.to70x.MigrateMethodTypes

Covers moved types in webfragments. Does not address calls to now inaccessible API.

Rate this page: