Files
build_soong/java/generated_java_library_test.go
Jordan Demeulenaere 8465406663 Add aconfig info to module_bp_java_deps.json
This CL adds a new `aconfig` field to java_aconfig_library modules in
module_bp_java_deps.json, which contains the srcs as well as the aconfig
configuration of the library so that aconfig files can be displayed and
recompiled in the IDE directly (e.g. using go/android-sonata).

Bug: 463647446
Test: go test java/
Test: go test android/
Test: go test aconfig/codegen/
Flag: EXEMPT HOST_MODE
Change-Id: Icccd6a84adc88ceea78428290412b0f5b9868891
2025-12-15 11:47:29 +01:00

70 lines
2.4 KiB
Go

// Copyright 2018 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package java
import (
"testing"
"android/soong/android"
)
func JavaGenLibTestFactory() android.Module {
callbacks := &JavaGenLibTestCallbacks{}
return GeneratedJavaLibraryModuleFactory("test_java_gen_lib", callbacks, &callbacks.properties)
}
type JavaGenLibTestProperties struct {
Foo string
}
type JavaGenLibTestCallbacks struct {
properties JavaGenLibTestProperties
}
func (callbacks *JavaGenLibTestCallbacks) DepsMutator(module *GeneratedJavaLibraryModule, ctx android.BottomUpMutatorContext) {
}
func (callbacks *JavaGenLibTestCallbacks) GenerateSourceJarBuildActions(module *GeneratedJavaLibraryModule, ctx android.ModuleContext) (android.Path, android.Path) {
return android.PathForOutput(ctx, "blah.srcjar"), android.PathForOutput(ctx, "blah.pb")
}
func (callbacks *JavaGenLibTestCallbacks) IDEInfo(module *GeneratedJavaLibraryModule, ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
}
func testGenLib(t *testing.T, errorHandler android.FixtureErrorHandler, bp string) *android.TestResult {
return android.GroupFixturePreparers(
PrepareForIntegrationTestWithJava,
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("test_java_gen_lib", JavaGenLibTestFactory)
}),
).
ExtendWithErrorHandler(errorHandler).
RunTestWithBp(t, bp)
}
func TestGenLib(t *testing.T) {
t.Parallel()
bp := `
test_java_gen_lib {
name: "javagenlibtest",
foo: "bar", // Note: This won't parse if the property didn't get added
}
`
result := testGenLib(t, android.FixtureExpectsNoErrors, bp)
javagenlibtest := result.ModuleForTests(t, "javagenlibtest", "android_common").Module().(*GeneratedJavaLibraryModule)
android.AssertPathsEndWith(t, "Generated_srcjars", []string{"/blah.srcjar"}, javagenlibtest.Library.properties.Generated_srcjars)
}