Comments (3)
I'm not sure what you mean.
If you have Java code that does not depend on anything in the Android SDK (i.e., the ordinary JDK), then use a java_library() rule to build that code.
If you have Java code that uses classes from the Android SDK, then compile it with an android_library() rule.
android_library() rules can depend on java_library() rules.
from buck.
Any given module could be compiled for Android or for J2SE. Currently we have an Android directory for Android specific source, a common directory for Java code that can run on anything, and a J2SE directory that has J2SE versions of the code that is in the Android directory. Buck encourages all the code to live in one tree, but having different platform builds complicates that. Is there a best-practices way to organize code of this sort in the buck environment?
from buck.
I believe that you could have everything in one tree. You just might have folders in the root like:
java/common/
java/android/
java/j2se/
or something like that. The BUCK
files in the java/android/
and java/j2se/
folders would reference the ones in java/common/
as deps
, assuming the dependencies are only one-way.
If the deps are two-way, then I would create a macro for each java_library
rule in java/common/
that creates two rules: one that depends on the java/android/
versions of your deps and another that depends on the java/j2se/
versions. So you might have something like:
# Define this in a DEFS file that you list under includes in .buckconfig:
# http://facebook.github.io/buck/concept/buckconfig.html
def create_both_versions(name, srcs, deps):
for type in ['j2se', 'android']:
rule_name = '%s_%s' % (name, type)
rule_deps = []
for dep in deps:
if dep.startswith('//java/XXX'):
rule_deps.append(dep.replace('//java/XXX', '//java/XXX' + type))
else:
rule_deps.append(dep)
java_library(
name = rule_name,
srcs = srcs,
deps = rule_deps,
visibility = [ 'PUBLIC' ],
)
Then under //java/common/analytics
, you might do:
# This creates both //java/common/analytics:analytics_j2se and
# //java/common/analytics:analytics_android
create_both_versions(
name = 'analytics',
srcs = glob(['*.java']),
deps = [
'//java/XXX/base:base',
],
)
So in //java/android/analytics
, you can do:
android_library(
name = 'analytics',
srcs = glob(['*.java']),
deps = [
'//java/common/analytics:analytics_android',
],
)
It's not exactly how Buck is meant to be used, but it may be a useful workaround for you. Ultimately, we would like to support the idea of "flavors" of build rules, which would make this less awkward.
from buck.
Related Issues (20)
- Python 3.10: third-party python modules need update (setuptools: No module named 'symbol', pex: cannot import name 'iterable' from 'collections') HOT 10
- How to Change Xcode xxx.pbxproj resource-id prefix ?
- got OSError: [Errno 45] Operation not supported when run "buck build demo_app_ios" command
- Trying to generate multiple targets with buck project --combined-project, expecting one project, got many
- GCC Toolchain Path Incorrect Post R22 NDK HOT 4
- Invite to slack channel
- How to avoid or allow apple security in M1?
- How do I join slack?
- Jitpack failure
- zip64 self executing jar issue
- Accessing files across directories
- Cannot run a build, failed to initialize buck (sqlite-jdbc) HOT 2
- Unable to build buck. Java class file version error. HOT 3
- Windows,When building rule //src/com/facebook/buck/jvm/java/abi/kotlin:kotlin.
- [Question] Isolation level between test targets within the same project. HOT 1
- Unable to create abi jar
- buck fetch fails with symbolic links in an archive HOT 1
- State of the Project? HOT 2
- Buck fails to link, linkage order seems to be wrong in linker.argsfile HOT 1
- How can we build instant app using buck
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buck.