1

I face a problem in buck gen_rule usage.

I have a executable jar file, called SqlDelightBin, which could generate Java source files, during gradle build process, there will be a gradle task to run this jar file, and the generated Java files could be compiled properly.

But when I wrap this jar file with a gen_rule, named sqldelight_devDebug, and add it into my android_library’s deps list, although this gen_rule runs properly, but the generated Java files are not compiled in this compile round, so the generated class could not be found, when I run the buck build command again, it succeed.

My gen_rule is:

genrule(
    name = 'sqldelight_devDebug',
    srcs = glob([
        'src/*/sqldelight/**/*.sq',
    ]),
    out = 'out',
    bash = 'java -jar /Users/piasy/src/OkBuck/.okbuck/cache/c61171f7a8bee5d459102d49daecb0b6/SqlDelightBin-0.4.3.jar $SRCDIR /Users/piasy/src/OkBuck/app/build/okbuck/sqldelight && echo $SRCS > $OUT',
)

It run the jar file, which will compile SQL files in src/*/sqldelight/ to Java files in /Users/piasy/src/OkBuck/app/build/okbuck/sqldelight dir, and to make BUCK think this genrule succeed, we create the $OUT file with SQL file list.

My android_library is:

android_library(
    name = 'src_devDebug',
    srcs = glob([
        'src/main/java/**/*.java',
        'build/okbuck/sqldelight/**/*.java’, # the generated Java files
        'src/dev/java/**/*.java',
    ]),
    # other params
    deps = [
        # other deps
        ':sqldelight_devDebug',
    ],
    visibility = [
        'PUBLIC',
    ],
)
4

1 に答える 1