Skip to content

Conversation

@Bencodes
Copy link
Owner

@Bencodes Bencodes commented Feb 12, 2025

Passing the JDK to AndroidLint so that it has these types available.

val jdkHome: Path? by parser
.storing(
names = arrayOf("--jdk-home"),
help = "The relative location of Android home",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "The relative location of the Java home" or JDK home?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, updated!

Copy link
Contributor

@kateliu20 kateliu20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for tagging me on this.

@Bencodes Bencodes merged commit b081b0e into main Feb 12, 2025
7 checks passed
@Bencodes Bencodes deleted the pass-the-jdk-to-lint branch February 12, 2025 22:46
@arunkumar9t2
Copy link
Contributor

Not sure if this is still relevant in latest rules_java/bazel but in our implementation we had to ensure JAVA_HOME/release file exists since some lint codepath depended on it.

https://github.com/grab/grab-bazel-common/blob/fb410531d8e093c0d2c3bce992c5ed3f3200eea5/tools/lint/src/main/java/com/grab/lint/LintBaseCommand.kt#L242

private fun prepareJdk() {
        // Prepare JDK
        // Lint uses $JAVA_HOME/release which is not provided by Bazel's JavaRuntimeInfo, so manually populate it
        // Only MODULES is populated here since Lint only seem to use that
        File(jdkHome, "release").also { release ->
            if (!release.exists()) {
                release.writeText(
                    ModuleLayer
                        .boot()
                        .modules()
                        .joinToString(
                            separator = " ",
                            prefix = "MODULES=\"",
                            postfix = "\"",
                            transform = Module::getName
                        )
                )
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants