{"action":"created","issue":{"url":"https://api.github.com/repos/uber/NullAway/issues/75","repository_url":"https://api.github.com/repos/uber/NullAway","labels_url":"https://api.github.com/repos/uber/NullAway/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/uber/NullAway/issues/75/comments","events_url":"https://api.github.com/repos/uber/NullAway/issues/75/events","html_url":"https://github.com/uber/NullAway/issues/75","id":280336343,"number":75,"title":"Does not work with Java + Kotlin Android based projects","user":{"login":"jaredsburrows","id":1739848,"avatar_url":"https://avatars0.githubusercontent.com/u/1739848?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredsburrows","html_url":"https://github.com/jaredsburrows","followers_url":"https://api.github.com/users/jaredsburrows/followers","following_url":"https://api.github.com/users/jaredsburrows/following{/other_user}","gists_url":"https://api.github.com/users/jaredsburrows/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredsburrows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredsburrows/subscriptions","organizations_url":"https://api.github.com/users/jaredsburrows/orgs","repos_url":"https://api.github.com/users/jaredsburrows/repos","events_url":"https://api.github.com/users/jaredsburrows/events{/privacy}","received_events_url":"https://api.github.com/users/jaredsburrows/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-12-08T01:16:37Z","updated_at":"2018-02-09T05:35:29Z","closed_at":null,"author_association":"NONE","body":"## Repro:\r\n\r\n```\r\nbuildscript {\r\n  repositories {\r\n    google()\r\n    maven { url \"https://plugins.gradle.org/m2/\" }\r\n  }\r\n\r\n  dependencies {\r\n    classpath \"com.android.tools.build:gradle:2.3.3\"\r\n    classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0\"\r\n    classpath \"net.ltgt.gradle:gradle-errorprone-plugin:0.0.11\"\r\n  }\r\n}\r\n\r\nrepositories {\r\n  google()\r\n  maven { url \"https://plugins.gradle.org/m2/\" }\r\n}\r\n\r\napply plugin: \"com.android.application\"\r\napply plugin: \"com.kotlin-android\"\r\napply plugin: \"com.kotlin-kapt\"\r\napply plugin: \"net.ltgt.errorprone\"\r\n\r\nandroid {\r\n  ...\r\n}\r\n\r\ndependencies {\r\n  kapt \"com.uber.nullaway:nullaway:0.2.2\"\r\n\r\n  errorprone \"com.google.errorprone:error_prone_core:2.1.1\"\r\n}\r\n\r\ntasks.withType(JavaCompile) {\r\n  // remove the if condition if you want to run NullAway on test code\r\n  if (!name.toLowerCase().contains(\"test\")) {\r\n    options.compilerArgs += [\"-Xep:NullAway:ERROR\", \"-XepOpt:NullAway:AnnotatedPackages=com.uber\"]\r\n  }\r\n}\r\n```\r\n\r\n## Error:\r\n```\r\n> Task :app:compileDebugJavaWithJavac FAILED\r\nNote: Some input files use or override a deprecated API.\r\nNote: Recompile with -Xlint:deprecation for details.\r\ncom.google.errorprone.InvalidCommandLineOptionException: NullAway is not a valid checker name\r\n\r\nFAILURE: Build failed with an exception.\r\n\r\n* What went wrong:\r\nExecution failed for task ':app:compileDebugJavaWithJavac'.\r\n> Compilation failed with exit code 2; see the compiler error output for details.\r\n\r\n* Try:\r\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\r\n\r\n* Get more help at https://help.gradle.org\r\n\r\nBUILD FAILED in 1m 25s\r\n77 actionable tasks: 77 executed\r\n```"},"comment":{"url":"https://api.github.com/repos/uber/NullAway/issues/comments/364340018","html_url":"https://github.com/uber/NullAway/issues/75#issuecomment-364340018","issue_url":"https://api.github.com/repos/uber/NullAway/issues/75","id":364340018,"user":{"login":"msridhar","id":193105,"avatar_url":"https://avatars1.githubusercontent.com/u/193105?v=4","gravatar_id":"","url":"https://api.github.com/users/msridhar","html_url":"https://github.com/msridhar","followers_url":"https://api.github.com/users/msridhar/followers","following_url":"https://api.github.com/users/msridhar/following{/other_user}","gists_url":"https://api.github.com/users/msridhar/gists{/gist_id}","starred_url":"https://api.github.com/users/msridhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msridhar/subscriptions","organizations_url":"https://api.github.com/users/msridhar/orgs","repos_url":"https://api.github.com/users/msridhar/repos","events_url":"https://api.github.com/users/msridhar/events{/privacy}","received_events_url":"https://api.github.com/users/msridhar/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T05:35:29Z","updated_at":"2018-02-09T05:35:29Z","author_association":"COLLABORATOR","body":"Ok, dug at this a bit.  It seems that when enabling both `kotlin-android` and `kotlin-kapt` plugins, Kotlin tries hard to prevent javac from running any annotation processors by passing `-proc:none` as a compiler arg and not passing the `annotationProcessor` dependencies on the processor path.  This kills Error Prone plugins, as they need to be on the processor path.  After much experimentation, I seem to have a hackish workaround.  Here's a modified build file for the sample app that seems to work:\r\n\r\n```gradle\r\nbuildscript {\r\n    repositories {\r\n      google()\r\n    }\r\n    dependencies {\r\n        classpath deps.build.gradlePlugins.android\r\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.20\"\r\n        classpath \"net.ltgt.gradle:gradle-errorprone-plugin:0.0.13\"\r\n    }\r\n}\r\napply plugin: 'com.android.application'\r\napply plugin: 'net.ltgt.errorprone'\r\napply plugin: \"kotlin-android\"\r\napply plugin: \"kotlin-kapt\"\r\nandroid {\r\n  // Android stuff\r\n}\r\nconfigurations.maybeCreate(\"nullawayAnnotProc\")\r\ndependencies {\r\n    compile deps.support.appcompat\r\n\r\n    testCompile deps.test.junit4\r\n\r\n    nullawayAnnotProc project(path: \":nullaway\", configuration: \"shadow\")\r\n    nullawayAnnotProc project(path: \":sample-library-model\")\r\n\r\n    errorprone \"com.google.errorprone:error_prone_core:2.1.3\"\r\n}\r\n\r\nafterEvaluate {\r\n  tasks.withType(JavaCompile) {\r\n    // remove the if condition if you want to run NullAway on test code\r\n    if (!name.toLowerCase().contains(\"test\")) {\r\n      options.annotationProcessorPath = configurations.nullawayAnnotProc\r\n      options.compilerArgs.removeAll { it.equals(\"-proc:none\") }\r\n      options.compilerArgs += [\"-Xep:NullAway:ERROR\", \"-XepOpt:NullAway:AnnotatedPackages=com.uber\"]\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nDon't ask me exactly why it works 😄 If you have \"real\" annotation processors, you can hopefully stick them in the `kapt` configuration and they will still run for your Java code as well.  If anyone has luck with this let me know."}}
{"actor":{"display_login":"msridhar"}}