summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2024-01-09 21:35:56 +0000
committer Spandan Das <spandandas@google.com> 2024-01-09 22:53:52 +0000
commit59a4a2b8d210e74e6625794f954bd11bb6157002 (patch)
tree591506fc8acb4eba691f53fc16d9ac175ecc64ce /java/java.go
parent208444ce5d9bd9ca013dc81438ef62d6ac4a461f (diff)
Replace panic with ModuleErrorf
This is a followup cleanup for aosp/2876754 and replaces panic with ctx.ModuleErrorf. The latter creates a more expressive build error. Implementation details - export moduleErrorf interface from build/soong/android. This minimal interface will be used as a parameter for `DexJarBuildPath` - Add ModuleErrorf to the function signature of DexJarBuildPath. This parameter only gets used for Import and SdkLibraryImport structs. These two can have duplicate deapexer definitions, and ModuleErrorf will be used to report that error - Create a minimal implementation of `ModuleErrorf` in tests of java and apex Test: m nothing --no-skip-soong-tests Change-Id: I0febec651f40c3f04deb957e64133c94b80fbd78
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/java/java.go b/java/java.go
index 2a4fafa8b..1ac3730df 100644
--- a/java/java.go
+++ b/java/java.go
@@ -315,7 +315,7 @@ type ApexDependency interface {
// Provides build path and install path to DEX jars.
type UsesLibraryDependency interface {
- DexJarBuildPath() OptionalDexJarPath
+ DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath
DexJarInstallPath() android.Path
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
}
@@ -2011,7 +2011,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
}
-func (al *ApiLibrary) DexJarBuildPath() OptionalDexJarPath {
+func (al *ApiLibrary) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
return al.dexJarFile
}
@@ -2378,9 +2378,9 @@ func (j *Import) ImplementationAndResourcesJars() android.Paths {
return android.Paths{j.combinedClasspathFile}
}
-func (j *Import) DexJarBuildPath() OptionalDexJarPath {
+func (j *Import) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
if j.dexJarFileErr != nil {
- panic(j.dexJarFileErr.Error())
+ ctx.ModuleErrorf(j.dexJarFileErr.Error())
}
return j.dexJarFile
}
@@ -2631,7 +2631,7 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
}
-func (j *DexImport) DexJarBuildPath() OptionalDexJarPath {
+func (j *DexImport) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
return j.dexJarFile
}
@@ -2799,7 +2799,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
// from its CLC should be added to the current CLC.
if sdkLib != nil {
clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib, false,
- dep.DexJarBuildPath().PathOrNil(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
+ dep.DexJarBuildPath(ctx).PathOrNil(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
} else {
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
}