diff --git a/java/lint.go b/java/lint.go index ca87dbab6..b73d6a51a 100644 --- a/java/lint.go +++ b/java/lint.go @@ -155,8 +155,11 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, cmd.FlagForEachArg("--extra_checks_jar ", l.extraLintCheckJars.Strings()) deps = append(deps, l.extraLintCheckJars...) - // The cache tag in project.xml is relative to the project.xml file. - cmd.FlagWithArg("--cache_dir ", "cache") + cmd.FlagWithArg("--root_dir ", "$PWD") + + // The cache tag in project.xml is relative to the root dir, or the project.xml file if + // the root dir is not set. + cmd.FlagWithArg("--cache_dir ", cacheDir.String()) cmd.FlagWithInput("@", android.PathForSource(ctx, "build/soong/java/lint_defaults.txt")) diff --git a/scripts/lint-project-xml.py b/scripts/lint-project-xml.py index 7ab4f0150..38c57cadf 100755 --- a/scripts/lint-project-xml.py +++ b/scripts/lint-project-xml.py @@ -77,6 +77,8 @@ def parse_args(): help='mark the module as a test.') parser.add_argument('--cache_dir', dest='cache_dir', help='directory to use for cached file.') + parser.add_argument('--root_dir', dest='root_dir', + help='directory to use for root dir.') group = parser.add_argument_group('check arguments', 'later arguments override earlier ones.') group.add_argument('--fatal_check', dest='checks', action=check_action('fatal'), default=[], help='treat a lint issue as a fatal error.') @@ -162,6 +164,8 @@ def write_project_xml(f, args): f.write("\n") f.write("\n") + if args.root_dir: + f.write(" \n" % args.root_dir) f.write(" \n" % (args.name, "library='true' " if args.library else "")) if args.manifest: f.write(" \n" % (args.manifest, test_attr))