-
Notifications
You must be signed in to change notification settings - Fork 101
Add API to configure which specific thrift files get compiled #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to configure which specific thrift files get compiled #367
Conversation
Codecov Report
@@ Coverage Diff @@
## master #367 +/- ##
============================================
- Coverage 76.75% 76.69% -0.07%
Complexity 381 381
============================================
Files 29 29
Lines 1665 1665
Branches 148 148
============================================
- Hits 1278 1277 -1
Misses 292 292
- Partials 95 96 +1
Continue to review full report at Codecov.
|
include '**/*.thrift' | ||
exclude '**/*.analytics.thrift' | ||
} | ||
|
||
// Augment the thrift include path with one or more directories: | ||
includeDir 'path/to/include/dir', 'path/to/other/dir' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but this should be includePath
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can includeDir
receive multiple paths, or would it need to be includeDirs
in this example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rename seems reasonable.
includeDir
takes one single path; includeDirs
is the varargs version.
I'm try to get this running locally so I can run through it fully, but I could use a little help that may be related to how I'm building/using this branch locally. I'm able to load the plugin with a little buildscript {
repositories {
flatDir { dirs /* paths to locally-built jars */ }
}
dependencies {
classpath 'com.microsoft.thrifty:thrifty-gradle-plugin:2.1.1-SNAPSHOT'
}
}
apply plugin: 'com.microsoft.thrifty'
apply plugin: 'kotlin'
thrifty {
kotlin {
omitFileComments true
}
} ... barks back at me with an error when I run the
Update: This also happens for me with the 2.1.0 binary release, too, so it must be some kind of misconfiguration in my environment unrelated to building this branch locally. |
Yikes, that sure is unfriendly. The error is that |
I don't think that's quite it in my case. I run into the same problem when I use a valid option (thanks for spotting my goof!) or something like: thrifty {
includePath 'commons/thrift'
kotlin { }
} |
Again, I'm sorry to say that your example isn't well formed. As you noted, while the option should be |
Ah. And correcting that gets me to an error like this:
... for |
That one is clearly down to my misunderstanding of the dependency APIs; will fix. |
I'm afraid cfa1483 didn't fix that error for me. |
Also, if I use something like: thrifty {
sourceDir 'thrift'
} ... I get And if I try: thrifty {
sourceDir('thrift') {
include 'base.thrift'
}
} ... I get this unfriendly result:
|
There must be something very different between the integration tests and your actual usage, because I can't seem to reproduce most of the issues you're encountering :( |
Thanks for spending so much time with this today. I finally got a repro, but have to confess that I don't quite understand why the error happens. As with most things in Gradle, the problem goes away when I stop doing things in the officially-recommended way. |
I finally found my misconfiguration. In order to load the locally-build jar, I needed to be more explicit in the classpath 'com.microsoft.thrifty.gradle.ThriftyGradlePlugin:thrifty-gradle-plugin:2.1.1-SNAPSHOT' ... and now it's loading the code from this branch rather than the plugin jar that shipped with 2.1.0. Now that sanity has been restored, I can go about testing the new behavior introduced by this change. 😉 |
Now I'm stuck trying to resolve this (apparently common) ANTLR dependency issue that pops up sometimes in Android projects:
|
Lol, wtf. Could it be that you are depending on multiple thrifty versions (one for the plugin, another for the rest of it)? |
I think aside from the fact that I can't quite test it in-to-end, the code in this branch should do what I want it to. :) The one additional thing that would be nice to customize is the output directory. There doesn't appear to be an option for that. |
Can you say more about the output directory? I'm thinking that the files generated here are ephemeral, not to be preserved or checked in. What would configuring the output directory enable for you? |
It's not a very important requirement. We currently generate the files in |
Adds an API to allow configuring include and exclude patterns on
sourceDir
entries in the Gradle plugin extension.@jparise please take a look and let me know whether this addresses your use-case. You're welcome to comment on anything here but probably the most interesting thing will be the readme changes which document the new API, and its direct implementation in
ThriftyExtension.kt
should you be so inclined.Fixes #365