Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] JavacSourceVersion JavacTargetVersion Harmonization #4771

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

jonpryor
Copy link
Member

@jonpryor jonpryor commented Jun 5, 2020

Context: #4567

In order to support using JDK 11 to build Xamarin.Android, we need to
consistently use javac -source 1.8 -target 1.8 ~everywhere, because
we also require javac --boot-class-path, and JDK11 doesn't support
javac --boot-class-path unless targeting < JDK 1.9:

% javac --boot-class-path ~/android-toolchain/sdk/platforms/android-29/android.jar Example.java
error: option --boot-class-path not allowed with target 11

The <Javac/> task use javac --boot-class-path to compile Java
code, so that Android's android.jar provides everything:

Task "Javac" (TaskId:154)
  Task Parameter:JavaPlatformJarPath=/Users/runner/Library/Android/sdk/platforms/android-29/android.jar
  Task Parameter:ClassesOutputDirectory=obj/Release/android/bin/classes/
  Task Parameter:ClassesZip=obj/Release/android/bin/classes.zip
  Task Parameter:StubSourceDirectory=obj/Release/android/src/
  Task Parameter:ToolPath=/Users/runner/Library/Android/jdk/bin
  Task Parameter:
      Jars=
          /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v10.0/mono.android.jar
          /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/java_runtime.jar
  /Users/runner/Library/Android/jdk/bin/javac -J-Dfile.encoding=UTF8 "@/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmp2eba46d8.tmp"
JAVAC : error : option --boot-class-path not allowed with target 11
  The command exited with code 2. (TaskId:154)

Harmonize provisioning of javac -source and javac -target values:

  • Add $(JavacSourceVersion) and $(JavacTargetVersion) MSBuild
    properties to Configuration.props.

  • Update the src/manifestmerger and src/r8 builds so that
    $(JavacSourceVersion) and $(JavacTargetVersion) are used to
    control the .class files that they create.

  • Update build-tools/scripts/Jar.targets to use the values from
    Configuration.props, instead of separate values.

  • Fix errant invocations of javac -target $(JavacSourceVersion),
    which should be javac -target $(JavacTargetVersion).

Context: dotnet#4567

In order to support using JDK 11 to build Xamarin.Android, we need to
consistently use `javac -source 1.8 -target 1.8` ~everywhere, because
we also require `javac --boot-class-path`, and JDK11 doesn't support
`javac --boot-class-path` unless targeting < JDK 1.9:

	% javac --boot-class-path ~/android-toolchain/sdk/platforms/android-29/android.jar Example.java
	error: option --boot-class-path not allowed with target 11

The `<Javac/>` task use `javac --boot-class-path` to compile Java
code, so that Android's `android.jar` provides everything:

	Task "Javac" (TaskId:154)
	  Task Parameter:JavaPlatformJarPath=/Users/runner/Library/Android/sdk/platforms/android-29/android.jar
	  Task Parameter:ClassesOutputDirectory=obj/Release/android/bin/classes/
	  Task Parameter:ClassesZip=obj/Release/android/bin/classes.zip
	  Task Parameter:StubSourceDirectory=obj/Release/android/src/
	  Task Parameter:ToolPath=/Users/runner/Library/Android/jdk/bin
	  Task Parameter:
	      Jars=
	          /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v10.0/mono.android.jar
	          /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/java_runtime.jar
	  /Users/runner/Library/Android/jdk/bin/javac -J-Dfile.encoding=UTF8 "@/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmp2eba46d8.tmp"
	JAVAC : error : option --boot-class-path not allowed with target 11
	  The command exited with code 2. (TaskId:154)

Harmonize provisioning of `javac -source` and `javac -target` values:

  * Add `$(JavacSourceVersion)` and `$(JavacTargetVersion)` MSBuild
    properties to `Configuration.props`.

  * Update the `src/manifestmerger` and `src/r8` builds so that
    `$(JavacSourceVersion)` and `$(JavacTargetVersion)` are used to
    control the `.class` files that they create.

  * Update `build-tools/scripts/Jar.targets` to use the values from
    `Configuration.props`, instead of separate values.

  * Fix errant invocations of `javac -target $(JavacSourceVersion)`,
    which should be `javac -target $(JavacTargetVersion)`.
@jonpryor jonpryor merged commit dcee2c8 into dotnet:master Jun 5, 2020
jonpryor added a commit that referenced this pull request Jun 5, 2020
Context: #4567

In order to support using JDK 11 to build Xamarin.Android, we need to
consistently use `javac -source 1.8 -target 1.8` ~everywhere, because
we also require `javac --boot-class-path`, and JDK11 doesn't support
`javac --boot-class-path` unless targeting < JDK 1.9:

	% javac --boot-class-path ~/android-toolchain/sdk/platforms/android-29/android.jar Example.java
	error: option --boot-class-path not allowed with target 11

The `<Javac/>` task use `javac --boot-class-path` to compile Java
code, so that Android's `android.jar` provides everything:

	Task "Javac" (TaskId:154)
	  Task Parameter:JavaPlatformJarPath=/Users/runner/Library/Android/sdk/platforms/android-29/android.jar
	  Task Parameter:ClassesOutputDirectory=obj/Release/android/bin/classes/
	  Task Parameter:ClassesZip=obj/Release/android/bin/classes.zip
	  Task Parameter:StubSourceDirectory=obj/Release/android/src/
	  Task Parameter:ToolPath=/Users/runner/Library/Android/jdk/bin
	  Task Parameter:
	      Jars=
	          /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v10.0/mono.android.jar
	          /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/java_runtime.jar
	  /Users/runner/Library/Android/jdk/bin/javac -J-Dfile.encoding=UTF8 "@/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmp2eba46d8.tmp"
	JAVAC : error : option --boot-class-path not allowed with target 11
	  The command exited with code 2. (TaskId:154)

Harmonize provisioning of `javac -source` and `javac -target` values:

  * Add `$(JavacSourceVersion)` and `$(JavacTargetVersion)` MSBuild
    properties to `Configuration.props`.

  * Update the `src/manifestmerger` and `src/r8` builds so that
    `$(JavacSourceVersion)` and `$(JavacTargetVersion)` are used to
    control the `.class` files that they create.

  * Update `build-tools/scripts/Jar.targets` to use the values from
    `Configuration.props`, instead of separate values.

  * Fix errant invocations of `javac -target $(JavacSourceVersion)`,
    which should be `javac -target $(JavacTargetVersion)`.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants