Rename names in java package to not have java prefix

Prefixing names in the java package with "java" is redundant, inside
the java package it is clear that they refer to something java
related, and outside the package they will be referred to with a
java. prefix.

Test: java_test.go
Change-Id: I9eb8eecb7ac5f6fbf8e87f5c219b3f50dbd18c87
This commit is contained in:
Colin Cross
2017-07-19 15:53:04 -07:00
parent 89536d4948
commit f506d87723
4 changed files with 64 additions and 64 deletions

View File

@@ -20,14 +20,14 @@ import (
"android/soong/android" "android/soong/android"
) )
func (*JavaLibrary) AndroidMk() (ret android.AndroidMkData, err error) { func (*Library) AndroidMk() (ret android.AndroidMkData, err error) {
ret.Class = "JAVA_LIBRARIES" ret.Class = "JAVA_LIBRARIES"
// TODO // TODO
err = fmt.Errorf("Not yet implemented") err = fmt.Errorf("Not yet implemented")
return return
} }
func (*JavaPrebuilt) AndroidMk() (ret android.AndroidMkData, err error) { func (*Prebuilt) AndroidMk() (ret android.AndroidMkData, err error) {
ret.Class = "JAVA_LIBRARIES" ret.Class = "JAVA_LIBRARIES"
// TODO // TODO
err = fmt.Errorf("Not yet implemented") err = fmt.Errorf("Not yet implemented")

View File

@@ -234,7 +234,7 @@ func (a *AndroidApp) aaptFlags(ctx android.ModuleContext) ([]string, android.Pat
var depFile android.OptionalPath var depFile android.OptionalPath
if sdkDep, ok := module.(sdkDependency); ok { if sdkDep, ok := module.(sdkDependency); ok {
depFile = android.OptionalPathForPath(sdkDep.ClasspathFile()) depFile = android.OptionalPathForPath(sdkDep.ClasspathFile())
} else if javaDep, ok := module.(JavaDependency); ok { } else if javaDep, ok := module.(Dependency); ok {
if ctx.OtherModuleName(module) == "framework-res" { if ctx.OtherModuleName(module) == "framework-res" {
depFile = android.OptionalPathForPath(javaDep.(*AndroidApp).exportPackage) depFile = android.OptionalPathForPath(javaDep.(*AndroidApp).exportPackage)
} }

View File

@@ -32,12 +32,12 @@ import (
func init() { func init() {
android.RegisterModuleType("java_defaults", defaultsFactory) android.RegisterModuleType("java_defaults", defaultsFactory)
android.RegisterModuleType("java_library", JavaLibraryFactory) android.RegisterModuleType("java_library", LibraryFactory)
android.RegisterModuleType("java_library_static", JavaLibraryFactory) android.RegisterModuleType("java_library_static", LibraryFactory)
android.RegisterModuleType("java_library_host", JavaLibraryHostFactory) android.RegisterModuleType("java_library_host", LibraryHostFactory)
android.RegisterModuleType("java_binary", JavaBinaryFactory) android.RegisterModuleType("java_binary", BinaryFactory)
android.RegisterModuleType("java_binary_host", JavaBinaryHostFactory) android.RegisterModuleType("java_binary_host", BinaryHostFactory)
android.RegisterModuleType("java_prebuilt_library", JavaPrebuiltFactory) android.RegisterModuleType("java_prebuilt_library", PrebuiltFactory)
android.RegisterModuleType("android_prebuilt_sdk", SdkPrebuiltFactory) android.RegisterModuleType("android_prebuilt_sdk", SdkPrebuiltFactory)
android.RegisterModuleType("android_app", AndroidAppFactory) android.RegisterModuleType("android_app", AndroidAppFactory)
@@ -143,7 +143,7 @@ type Module struct {
installFile android.Path installFile android.Path
} }
type JavaDependency interface { type Dependency interface {
ClasspathFile() android.Path ClasspathFile() android.Path
ClassJarSpecs() []jarSpec ClassJarSpecs() []jarSpec
ResourceJarSpecs() []jarSpec ResourceJarSpecs() []jarSpec
@@ -161,8 +161,8 @@ type dependencyTag struct {
} }
var ( var (
javaStaticLibTag = dependencyTag{name: "staticlib"} staticLibTag = dependencyTag{name: "staticlib"}
javaLibTag = dependencyTag{name: "javalib"} libTag = dependencyTag{name: "javalib"}
bootClasspathTag = dependencyTag{name: "bootclasspath"} bootClasspathTag = dependencyTag{name: "bootclasspath"}
frameworkResTag = dependencyTag{name: "framework-res"} frameworkResTag = dependencyTag{name: "framework-res"}
sdkDependencyTag = dependencyTag{name: "sdk"} sdkDependencyTag = dependencyTag{name: "sdk"}
@@ -190,11 +190,11 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} }
if ctx.Device() && j.deviceProperties.Sdk_version == "" { if ctx.Device() && j.deviceProperties.Sdk_version == "" {
ctx.AddDependency(ctx.Module(), javaLibTag, config.DefaultLibraries...) ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
} }
} }
ctx.AddDependency(ctx.Module(), javaLibTag, j.properties.Libs...) ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
ctx.AddDependency(ctx.Module(), javaStaticLibTag, j.properties.Static_libs...) ctx.AddDependency(ctx.Module(), staticLibTag, j.properties.Static_libs...)
} }
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath, func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
@@ -227,8 +227,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths
otherName := ctx.OtherModuleName(module) otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module) tag := ctx.OtherModuleDependencyTag(module)
javaDep, _ := module.(JavaDependency) dep, _ := module.(Dependency)
if javaDep == nil { if dep == nil {
switch tag { switch tag {
case android.DefaultsDepTag, android.SourceDepTag: case android.DefaultsDepTag, android.SourceDepTag:
default: default:
@@ -239,13 +239,13 @@ func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths
switch tag { switch tag {
case bootClasspathTag: case bootClasspathTag:
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile()) bootClasspath = android.OptionalPathForPath(dep.ClasspathFile())
case javaLibTag: case libTag:
classpath = append(classpath, javaDep.ClasspathFile()) classpath = append(classpath, dep.ClasspathFile())
case javaStaticLibTag: case staticLibTag:
classpath = append(classpath, javaDep.ClasspathFile()) classpath = append(classpath, dep.ClasspathFile())
classJarSpecs = append(classJarSpecs, javaDep.ClassJarSpecs()...) classJarSpecs = append(classJarSpecs, dep.ClassJarSpecs()...)
resourceJarSpecs = append(resourceJarSpecs, javaDep.ResourceJarSpecs()...) resourceJarSpecs = append(resourceJarSpecs, dep.ResourceJarSpecs()...)
case frameworkResTag: case frameworkResTag:
if ctx.ModuleName() == "framework" { if ctx.ModuleName() == "framework" {
// framework.jar has a one-off dependency on the R.java and Manifest.java files // framework.jar has a one-off dependency on the R.java and Manifest.java files
@@ -266,7 +266,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) (classpath android.Paths
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName())) panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
} }
aidlIncludeDirs = append(aidlIncludeDirs, javaDep.AidlIncludeDirs()...) aidlIncludeDirs = append(aidlIncludeDirs, dep.AidlIncludeDirs()...)
}) })
return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, return classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
@@ -294,16 +294,16 @@ func (j *Module) compile(ctx android.ModuleContext) {
flags.aidlFlags = "$aidlFlags" flags.aidlFlags = "$aidlFlags"
} }
var javacDeps android.Paths var deps android.Paths
if bootClasspath.Valid() { if bootClasspath.Valid() {
flags.bootClasspath = "-bootclasspath " + bootClasspath.String() flags.bootClasspath = "-bootclasspath " + bootClasspath.String()
javacDeps = append(javacDeps, bootClasspath.Path()) deps = append(deps, bootClasspath.Path())
} }
if len(classpath) > 0 { if len(classpath) > 0 {
flags.classpath = "-classpath " + strings.Join(classpath.Strings(), ":") flags.classpath = "-classpath " + strings.Join(classpath.Strings(), ":")
javacDeps = append(javacDeps, classpath...) deps = append(deps, classpath...)
} }
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs) srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
@@ -320,7 +320,7 @@ func (j *Module) compile(ctx android.ModuleContext) {
if len(srcFiles) > 0 { if len(srcFiles) > 0 {
// Compile java sources into .class files // Compile java sources into .class files
classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, javacDeps) classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, deps)
if ctx.Failed() { if ctx.Failed() {
return return
} }
@@ -397,7 +397,7 @@ func (j *Module) compile(ctx android.ModuleContext) {
j.outputFile = outputFile j.outputFile = outputFile
} }
var _ JavaDependency = (*JavaLibrary)(nil) var _ Dependency = (*Library)(nil)
func (j *Module) ClasspathFile() android.Path { func (j *Module) ClasspathFile() android.Path {
return j.classpathFile return j.classpathFile
@@ -425,22 +425,22 @@ func (j *Module) logtags() android.Paths {
// Java libraries (.jar file) // Java libraries (.jar file)
// //
type JavaLibrary struct { type Library struct {
Module Module
} }
func (j *JavaLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.compile(ctx) j.compile(ctx)
j.installFile = ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile) j.installFile = ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
} }
func (j *JavaLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
j.deps(ctx) j.deps(ctx)
} }
func JavaLibraryFactory() android.Module { func LibraryFactory() android.Module {
module := &JavaLibrary{} module := &Library{}
module.deviceProperties.Dex = true module.deviceProperties.Dex = true
@@ -452,8 +452,8 @@ func JavaLibraryFactory() android.Module {
return module return module
} }
func JavaLibraryHostFactory() android.Module { func LibraryHostFactory() android.Module {
module := &JavaLibrary{} module := &Library{}
module.AddProperties(&module.Module.properties) module.AddProperties(&module.Module.properties)
@@ -465,19 +465,19 @@ func JavaLibraryHostFactory() android.Module {
// Java Binaries (.jar file plus wrapper script) // Java Binaries (.jar file plus wrapper script)
// //
type javaBinaryProperties struct { type binaryProperties struct {
// installable script to execute the resulting jar // installable script to execute the resulting jar
Wrapper string Wrapper string
} }
type JavaBinary struct { type Binary struct {
JavaLibrary Library
binaryProperties javaBinaryProperties binaryProperties binaryProperties
} }
func (j *JavaBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.JavaLibrary.GenerateAndroidBuildActions(ctx) j.Library.GenerateAndroidBuildActions(ctx)
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
// another build rule before the jar has been installed. // another build rule before the jar has been installed.
@@ -485,12 +485,12 @@ func (j *JavaBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.installFile) j.installFile)
} }
func (j *JavaBinary) DepsMutator(ctx android.BottomUpMutatorContext) { func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
j.deps(ctx) j.deps(ctx)
} }
func JavaBinaryFactory() android.Module { func BinaryFactory() android.Module {
module := &JavaBinary{} module := &Binary{}
module.deviceProperties.Dex = true module.deviceProperties.Dex = true
@@ -503,8 +503,8 @@ func JavaBinaryFactory() android.Module {
return module return module
} }
func JavaBinaryHostFactory() android.Module { func BinaryHostFactory() android.Module {
module := &JavaBinary{} module := &Binary{}
module.AddProperties( module.AddProperties(
&module.Module.properties, &module.Module.properties,
@@ -519,7 +519,7 @@ func JavaBinaryHostFactory() android.Module {
// Java prebuilts // Java prebuilts
// //
type JavaPrebuilt struct { type Prebuilt struct {
android.ModuleBase android.ModuleBase
prebuilt android.Prebuilt prebuilt android.Prebuilt
@@ -527,14 +527,14 @@ type JavaPrebuilt struct {
classJarSpecs, resourceJarSpecs []jarSpec classJarSpecs, resourceJarSpecs []jarSpec
} }
func (j *JavaPrebuilt) Prebuilt() *android.Prebuilt { func (j *Prebuilt) Prebuilt() *android.Prebuilt {
return &j.prebuilt return &j.prebuilt
} }
func (j *JavaPrebuilt) DepsMutator(ctx android.BottomUpMutatorContext) { func (j *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
} }
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
prebuilt := j.prebuilt.Path(ctx) prebuilt := j.prebuilt.Path(ctx)
classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt) classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
@@ -545,26 +545,26 @@ func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile) ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile)
} }
var _ JavaDependency = (*JavaPrebuilt)(nil) var _ Dependency = (*Prebuilt)(nil)
func (j *JavaPrebuilt) ClasspathFile() android.Path { func (j *Prebuilt) ClasspathFile() android.Path {
return j.classpathFile return j.classpathFile
} }
func (j *JavaPrebuilt) ClassJarSpecs() []jarSpec { func (j *Prebuilt) ClassJarSpecs() []jarSpec {
return j.classJarSpecs return j.classJarSpecs
} }
func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec { func (j *Prebuilt) ResourceJarSpecs() []jarSpec {
return j.resourceJarSpecs return j.resourceJarSpecs
} }
func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths { func (j *Prebuilt) AidlIncludeDirs() android.Paths {
return nil return nil
} }
func JavaPrebuiltFactory() android.Module { func PrebuiltFactory() android.Module {
module := &JavaPrebuilt{} module := &Prebuilt{}
module.AddProperties(&module.prebuilt.Properties) module.AddProperties(&module.prebuilt.Properties)
@@ -577,7 +577,7 @@ func JavaPrebuiltFactory() android.Module {
// //
type sdkDependency interface { type sdkDependency interface {
JavaDependency Dependency
AidlPreprocessed() android.OptionalPath AidlPreprocessed() android.OptionalPath
} }
@@ -588,7 +588,7 @@ type sdkPrebuiltProperties struct {
} }
type sdkPrebuilt struct { type sdkPrebuilt struct {
JavaPrebuilt Prebuilt
sdkProperties sdkPrebuiltProperties sdkProperties sdkPrebuiltProperties
@@ -596,7 +596,7 @@ type sdkPrebuilt struct {
} }
func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.JavaPrebuilt.GenerateAndroidBuildActions(ctx) j.Prebuilt.GenerateAndroidBuildActions(ctx)
j.aidlPreprocessed = android.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed) j.aidlPreprocessed = android.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed)
} }

View File

@@ -54,8 +54,8 @@ func testJava(t *testing.T, bp string) *android.TestContext {
ctx := android.NewTestContext() ctx := android.NewTestContext()
ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory)) ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(JavaLibraryFactory)) ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(LibraryFactory))
ctx.RegisterModuleType("java_prebuilt_library", android.ModuleFactoryAdaptor(JavaPrebuiltFactory)) ctx.RegisterModuleType("java_prebuilt_library", android.ModuleFactoryAdaptor(PrebuiltFactory))
ctx.RegisterModuleType("java_defaults", android.ModuleFactoryAdaptor(defaultsFactory)) ctx.RegisterModuleType("java_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.Register() ctx.Register()