diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 58 | 
1 files changed, 52 insertions, 6 deletions
| diff --git a/java/java.go b/java/java.go index 2897fd7f5..dae69dcdc 100644 --- a/java/java.go +++ b/java/java.go @@ -118,6 +118,16 @@ var (  		copyEverythingToSnapshot,  	} +	snapshotRequiresImplementationJar = func(ctx android.SdkMemberContext) bool { +		// In the S build the build will break if updatable-media does not provide a full implementation +		// jar. That issue was fixed in Tiramisu by b/229932396. +		if ctx.IsTargetBuildBeforeTiramisu() && ctx.Name() == "updatable-media" { +			return true +		} + +		return false +	} +  	// Supports adding java boot libraries to module_exports and sdk.  	//  	// The build has some implicit dependencies (via the boot jars configuration) on a number of @@ -135,13 +145,21 @@ var (  			SupportsSdk:  true,  		},  		func(ctx android.SdkMemberContext, j *Library) android.Path { +			if snapshotRequiresImplementationJar(ctx) { +				return exportImplementationClassesJar(ctx, j) +			} +  			// Java boot libs are only provided in the SDK to provide access to their dex implementation  			// jar for use by dexpreopting and boot jars package check. They do not need to provide an  			// actual implementation jar but the java_import will need a file that exists so just copy an  			// empty file. Any attempt to use that file as a jar will cause a build error.  			return ctx.SnapshotBuilder().EmptyFile()  		}, -		func(osPrefix, name string) string { +		func(ctx android.SdkMemberContext, osPrefix, name string) string { +			if snapshotRequiresImplementationJar(ctx) { +				return sdkSnapshotFilePathForJar(ctx, osPrefix, name) +			} +  			// Create a special name for the implementation jar to try and provide some useful information  			// to a developer that attempts to compile against this.  			// TODO(b/175714559): Provide a proper error message in Soong not ninja. @@ -164,6 +182,9 @@ var (  		android.SdkMemberTypeBase{  			PropertyName: "java_systemserver_libs",  			SupportsSdk:  true, + +			// This was only added in Tiramisu. +			SupportedBuildReleaseSpecification: "Tiramisu+",  		},  		func(ctx android.SdkMemberContext, j *Library) android.Path {  			// Java systemserver libs are only provided in the SDK to provide access to their dex @@ -172,7 +193,7 @@ var (  			// file. Any attempt to use that file as a jar will cause a build error.  			return ctx.SnapshotBuilder().EmptyFile()  		}, -		func(osPrefix, name string) string { +		func(_ android.SdkMemberContext, osPrefix, name string) string {  			// Create a special name for the implementation jar to try and provide some useful information  			// to a developer that attempts to compile against this.  			// TODO(b/175714559): Provide a proper error message in Soong not ninja. @@ -510,6 +531,20 @@ func (v javaVersion) String() string {  	}  } +func (v javaVersion) StringForKotlinc() string { +	// $ ./external/kotlinc/bin/kotlinc -jvm-target foo +	// error: unknown JVM target version: foo +	// Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17 +	switch v { +	case JAVA_VERSION_7: +		return "1.6" +	case JAVA_VERSION_9: +		return "9" +	default: +		return v.String() +	} +} +  // Returns true if javac targeting this version uses system modules instead of a bootclasspath.  func (v javaVersion) usesJavaModules() bool {  	return v >= 9 @@ -655,7 +690,7 @@ const (  )  // path to the jar file of a java library. Relative to <sdk_root>/<api_dir> -func sdkSnapshotFilePathForJar(osPrefix, name string) string { +func sdkSnapshotFilePathForJar(_ android.SdkMemberContext, osPrefix, name string) string {  	return sdkSnapshotFilePathForMember(osPrefix, name, jarFileSuffix)  } @@ -672,7 +707,7 @@ type librarySdkMemberType struct {  	// Function to compute the snapshot relative path to which the named library's  	// jar should be copied. -	snapshotPathGetter func(osPrefix, name string) string +	snapshotPathGetter func(ctx android.SdkMemberContext, osPrefix, name string) string  	// True if only the jar should be copied to the snapshot, false if the jar plus any additional  	// files like aidl files should also be copied. @@ -730,7 +765,7 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte  	exportedJar := p.JarToExport  	if exportedJar != nil {  		// Delegate the creation of the snapshot relative path to the member type. -		snapshotRelativeJavaLibPath := memberType.snapshotPathGetter(p.OsPrefix(), ctx.Name()) +		snapshotRelativeJavaLibPath := memberType.snapshotPathGetter(ctx, p.OsPrefix(), ctx.Name())  		// Copy the exported jar to the snapshot.  		builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath) @@ -1196,7 +1231,7 @@ func (p *testSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext,  	exportedJar := p.JarToExport  	if exportedJar != nil { -		snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), ctx.Name()) +		snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(ctx, p.OsPrefix(), ctx.Name())  		builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath)  		propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath}) @@ -1442,6 +1477,10 @@ type ImportProperties struct {  	// specified.  	Min_sdk_version *string +	// The max sdk version placeholder used to replace maxSdkVersion attributes on permission +	// and uses-permission tags in manifest_fixer. +	Replace_max_sdk_version_placeholder *string +  	Installable *bool  	// If not empty, classes are restricted to the specified packages and their sub-packages. @@ -1521,6 +1560,13 @@ func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {  	return j.SdkVersion(ctx)  } +func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec { +	if j.properties.Replace_max_sdk_version_placeholder != nil { +		return android.SdkSpecFrom(ctx, *j.properties.Replace_max_sdk_version_placeholder) +	} +	return android.SdkSpecFrom(ctx, "") +} +  func (j *Import) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {  	return j.SdkVersion(ctx)  } |