-
Notifications
You must be signed in to change notification settings - Fork 98
Upgrading modules to v2 runtime
Rikki Gibson edited this page May 11, 2018
·
3 revisions
Note that this guide is based on the state of the repository in https://github.com/Azure/azure-libraries-for-java/tree/v2-resources.
- 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 version2.0.0-SNAPSHOT
. - Update the versions of
azure-mgmt-resources
and any other peer dependencies to2.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.
- Change the base package from
com.microsoft.azure.management
tocom.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"
- Regenerate the inners for the module.
# in the repo root folder
gulp codegen --projects storage # specify the module you're actually regenerating
- Run a few find and replaces in the java files under the module:
- Replace
com.microsoft.azure
withcom.microsoft.azure.v2
- Replace
com.microsoft.rest
withcom.microsoft.rest.v2
- Replace
rx.
withio.reactivex.
for RxJava2 - Replace
Func0
withCallable
,Func1
withFunction
,Action0
withAction
,Action1
withConsumer
, 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.
- 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.
- Rerun the tests, track down the failures, rerecord tests as needed. Report issues in the runtime under the "v2" label.