From fae468ef14fa7fd902c8e004dbd55a3e79b8a30f Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 12 Dec 2023 23:23:53 +0000 Subject: Move validation from FindDeapexerProviderForModule to rdeps FindDeapexerProviderForModule raises an exception if multiple apexes in the tree has an export dep on the java module. In prepartation to support multiple prebuilts, move this error check out of FindDeapexerProviderForModule and into rdeps. i.e. raise an exception only if an rdep calls DexJarBuildPath - This should be a no-op for now. - In the short-term future, a java import module will be allowed to have multiple deapexers. An error will be raised if anyone actually tries to depend on the dexjar - In the long-term future, this function will be removed. All processing will be done at the prebuilt apex level and not at the prebuilt java library level Since this check now happens in the moduleCtx of rdeps, add some additional props to unit tests to ensure that it does not exit early on unrelated validation checks (e.g. hidden_api prop is not set) Test: go test ./apex ./java Bug: 308790457 Change-Id: I3323d993c1ea8f43305834cae8e65b6fe41dfefd --- java/bootclasspath_fragment.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'java/bootclasspath_fragment.go') diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index d2bb52315..83030b51e 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -240,7 +240,8 @@ type BootclasspathFragmentModule struct { sourceOnlyProperties SourceOnlyBootclasspathProperties // Path to the boot image profile. - profilePath android.WritablePath + profilePath android.WritablePath + profilePathErr error } // commonBootclasspathFragment defines the methods that are implemented by both source and prebuilt @@ -1065,8 +1066,11 @@ func (module *PrebuiltBootclasspathFragmentModule) produceBootImageProfile(ctx a return nil } - di := android.FindDeapexerProviderForModule(ctx) - if di == nil { + di, err := android.FindDeapexerProviderForModule(ctx) + if err != nil { + // An error was found, possibly due to multiple apexes in the tree that export this library + // Defer the error till a client tries to call getProfilePath + module.profilePathErr = err return nil // An error has been reported by FindDeapexerProviderForModule. } @@ -1074,6 +1078,9 @@ func (module *PrebuiltBootclasspathFragmentModule) produceBootImageProfile(ctx a } func (b *PrebuiltBootclasspathFragmentModule) getProfilePath() android.Path { + if b.profilePathErr != nil { + panic(b.profilePathErr.Error()) + } return b.profilePath } -- cgit v1.2.3-59-g8ed1b