[Xamarin.Android.Build.Tasks] Support cmdline-tools #4778
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: #4567
The Android SDK
lint
utility is now in two Android SDK packages:the
tools
package, and thecmdline-tools
package, e.g. as of commitd99facb, both of these exist on e.g. macOS:
$HOME/android-toolchain/sdk/tools/bin/lint
$HOME/android-toolchain/sdk/cmdline-tools/1.0/bin/lint
There are two important differences of interest:
tools/bin/lint
will not run on OpenJDK 11.cmdline-tools/1.0/bin/lint
has a lower version thantools/bin/lint
. Much lower:(1) means that we can't use the previous
lint
in an OpenJDK11 world,and thus we should migrate to the cmdline-tools
lint
.Support this by adding a new
$(AndroidCommandLineToolsVersion)
MSBuild property to
Xamarin.Android.Common.props.in
andMicrosoft.Android.Sdk.props
, which allows controlling whichcmdline-tools
package version to use, if more than one is present.The default value is
1.0
.(2) means that the
<Lint/>
Task is broken when using thecmdline-tools version of
lint
, becasuse certainlint --disable
flags are protected by version checks, which are now all "wrong" when
we "expect" >= 26.1.1 and instead get 3.6.0.
Attempt to address (2) by assuming that we're using the cmdline-tools
package if
ToolPath
containscmdline-tools
, in which case we treatlint
as newer than any previous version.(This may be less than ideal.)