okbuck icon indicating copy to clipboard operation
okbuck copied to clipboard

mixed scala + java projects leads to wrong compiler flags

Open dsilvasc opened this issue 6 years ago • 3 comments

Say you have a gradle project with both scala and java sources (both scala and java plugins applied), and with extra compiler flags for your java code:

        testCompile.options.compilerArgs << "-Xlint:unchecked"

okbuck generates a BUCK file with incorrect scala compiler flags:

scala_test(
    name = 'test_main',
    srcs = glob([
        'src/test/scala/**/*.java',
        'src/test/scala/**/*.scala',
    ]),
    source = '8',
    target = '8',
    extra_arguments = [
        '-Xlint:unchecked',
    ],

which then causes buckw to fail:

$ ./buckw test
scalac error: 'unchecked' is not a valid choice for '-Xlint'
  scalac -help  gives more information

Build failed: Command failed with exit code 1.
stderr: scalac error: 'unchecked' is not a valid choice for '-Xlint'
  scalac -help  gives more information

dsilvasc avatar Apr 30 '18 14:04 dsilvasc

This needs to be fixed upstream in buck as well:

https://github.com/facebook/buck/blob/master/src/com/facebook/buck/jvm/scala/ScalaLibraryDescription.java#L178

Currently it overrides the java args and passes them into javac

kageiit avatar May 24 '18 22:05 kageiit

This needs to be fixed upstream in buck before we can apply a fix in okbuck. Kotlin and groovy rules use their own extra compiler arguments that the scala rules do not. @dsilvasc Can you please create an issue on buck?

kageiit avatar May 24 '18 22:05 kageiit

@kageiit Thanks for following up. I filed https://github.com/facebook/buck/issues/1898

dsilvasc avatar May 24 '18 22:05 dsilvasc