Skip to content

Upgrading modules to v2 runtime

Rikki Gibson edited this page May 11, 2018 · 3 revisions

Upgrading modules to v2 runtime

Note that this guide is based on the state of the repository in https://github.com/Azure/azure-libraries-for-java/tree/v2-resources.

  1. Update the pom files.
  • Go to the parent pom.xml and comment the module element for your module back in.
  • In the child module, update the parent element to use the groupId com.microsoft.azure.v2 and version 2.0.0-SNAPSHOT.
  • Update the versions of azure-mgmt-resources and any other peer dependencies to 2.0.0-snapshot in the child module. Note that any peer dependencies must already be migrated, e.g. we can't migrate compute until storage, network and msi have been migrated first.
  1. Change the base package from com.microsoft.azure.management to com.microsoft.azure.v2.management for back compatibility. Run the following commands:
# in the module folder, e.g. azure-mgmt-storage
mkdir -p src/main/java/com/microsoft/azure/v2
mv src/main/java/com/microsoft/azure/management src/main/java/com/microsoft/azure/v2
mkdir -p src/test/java/com/microsoft/azure/v2
mv src/test/java/com/microsoft/azure/management src/test/java/com/microsoft/azure/v2
# Do this before any other edits so git will understand these are moved files, not new files
git commit -am "Move files to new package"
  1. Regenerate the inners for the module.
# in the repo root folder
gulp codegen --projects storage  # specify the module you're actually regenerating
  1. Run a few find and replaces in the java files under the module:
  • Replace com.microsoft.azure with com.microsoft.azure.v2
  • Replace com.microsoft.rest with com.microsoft.rest.v2
  • Replace rx. with io.reactivex. for RxJava2
  • Replace Func0 with Callable, Func1 with Function, Action0 with Action, Action1 with Consumer, etc.
    • There will still be a substantial amount of manual fixup to do for the anonymous classes passed to Rx operators.

At this point it's a good idea to create another branch and PR the following steps to it so that the meaningful manual changes are separate from the enormous batch changes that happen from moving and regenerating.

  1. Deal with the numerous compile errors.
  • Read https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0 to get the hang of RxJava2.
  • RxJava 2 renamed all the functional interfaces, so Func1 is now Function, Action1 is now Callable, and more, so you'll be fixing errors in a lot of anonymous classes.
  • RestClient is now HttpPipeline (basically) and most things are configured by calling HttpPipelineBuilder.withRequestPolicy. You can see ResourceManager.java for an example of the usage.
  1. Rerun the tests, track down the failures, rerecord tests as needed. Report issues in the runtime under the "v2" label.
Clone this wiki locally