From 3d7678f9d6e69f07f5d09c3d4ec00f4213a65691 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 24 Apr 2015 15:16:39 -0700 Subject: [PATCH] Fix java resource globbing Handle java resource globbing in two passes, the first on the list of resource dirs to produce a list of directories, and the second to glob for files inside those directories using **/*. Fixes incorrect jarSpec dir errors when the resource directories list contains globs. Change-Id: Icea5d8178336eb7de4ad91a9acba4822423d9f60 --- java/resources.go | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/java/resources.go b/java/resources.go index 2fbf54bf2..7aa909eef 100644 --- a/java/resources.go +++ b/java/resources.go @@ -21,24 +21,41 @@ import ( ) var resourceExcludes = []string{ - "*.java", - "package.html", - "overview.html", - ".*.swp", - ".DS_Store", - "*~", + "**/*.java", + "**/package.html", + "**/overview.html", + "**/.*.swp", + "**/.DS_Store", + "**/*~", } -func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, dirs []string) []jarSpec { - jarSpecs := make([]jarSpec, len(dirs)) +func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs []string) []jarSpec { + var excludes []string - for i, dir := range dirs { - fileListFile := filepath.Join(common.ModuleOutDir(ctx), "res", dir, "resources.list") - depFile := fileListFile + ".d" - dir := filepath.Join(common.ModuleSrcDir(ctx), dir) - glob := filepath.Join(dir, "**/*") - common.GlobRule(ctx, glob, resourceExcludes, fileListFile, depFile) - jarSpecs[i] = jarSpec{fileListFile, dir} + for _, resourceDir := range resourceDirs { + if resourceDir[0] == '-' { + excludes = append(excludes, filepath.Join(common.ModuleSrcDir(ctx), resourceDir[1:], "**/*")) + } + } + + excludes = append(excludes, resourceExcludes...) + + var jarSpecs []jarSpec + + for _, resourceDir := range resourceDirs { + if resourceDir[0] == '-' { + continue + } + resourceDir := filepath.Join(common.ModuleSrcDir(ctx), resourceDir) + dirs := common.Glob(ctx, resourceDir, nil) + for _, dir := range dirs { + fileListFile := filepath.Join(common.ModuleOutDir(ctx), "res", dir, "resources.list") + depFile := fileListFile + ".d" + + glob := filepath.Join(dir, "**/*") + common.GlobRule(ctx, glob, excludes, fileListFile, depFile) + jarSpecs = append(jarSpecs, jarSpec{fileListFile, dir}) + } } return jarSpecs