Skip to content

Commit

Permalink
Add Bazel build files for the tutorial (rosjava#269)
Browse files Browse the repository at this point in the history
This also allows other Bazel projects to include rosjava_core as an
external repository, as instructed in README.md.

This uses https://github.com/johnynek/bazel-deps to describe the Maven
dependencies. As a result, 3rdparty/ contains autogenerated files, and
the other files contain a hand-written description of the BUILD.
  • Loading branch information
drigz authored Mar 1, 2018
1 parent 8861658 commit cc8f806
Show file tree
Hide file tree
Showing 25 changed files with 515 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ bin
.settings
*.iml
.idea

bazel-*
Empty file added 3rdparty/BUILD
Empty file.
12 changes: 12 additions & 0 deletions 3rdparty/jvm/com/google/code/findbugs/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "jsr305",
exports = [
"//external:jar/com/google/code/findbugs/jsr305"
],
visibility = [
"//visibility:public"
]
)


15 changes: 15 additions & 0 deletions 3rdparty/jvm/com/google/guava/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "guava",
exports = [
"//external:jar/com/google/guava/guava"
],
runtime_deps = [
"//3rdparty/jvm/com/google/code/findbugs:jsr305"
],
visibility = [
"//visibility:public"
]
)


12 changes: 12 additions & 0 deletions 3rdparty/jvm/commons_pool/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "commons_pool",
exports = [
"//external:jar/commons_pool/commons_pool"
],
visibility = [
"//visibility:public"
]
)


15 changes: 15 additions & 0 deletions 3rdparty/jvm/dnsjava/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "dnsjava",
exports = [
"//external:jar/dnsjava/dnsjava"
],
runtime_deps = [
"//3rdparty/jvm/junit:junit"
],
visibility = [
"//visibility:public"
]
)


12 changes: 12 additions & 0 deletions 3rdparty/jvm/io/netty/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "netty",
exports = [
"//external:jar/io/netty/netty"
],
visibility = [
"//visibility:public"
]
)


12 changes: 12 additions & 0 deletions 3rdparty/jvm/junit/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "junit",
exports = [
"//external:jar/junit/junit"
],
visibility = [
"//visibility:public"
]
)


76 changes: 76 additions & 0 deletions 3rdparty/jvm/org/apache/commons/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "com_springsource_org_apache_commons_codec",
exports = [
"//external:jar/org/apache/commons/com_springsource_org_apache_commons_codec"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "com_springsource_org_apache_commons_httpclient",
exports = [
"//external:jar/org/apache/commons/com_springsource_org_apache_commons_httpclient"
],
runtime_deps = [
":com_springsource_org_apache_commons_codec",
":com_springsource_org_apache_commons_logging"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "com_springsource_org_apache_commons_io",
exports = [
"//external:jar/org/apache/commons/com_springsource_org_apache_commons_io"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "com_springsource_org_apache_commons_lang",
exports = [
"//external:jar/org/apache/commons/com_springsource_org_apache_commons_lang"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "com_springsource_org_apache_commons_logging",
exports = [
"//external:jar/org/apache/commons/com_springsource_org_apache_commons_logging"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "com_springsource_org_apache_commons_net",
exports = [
"//external:jar/org/apache/commons/com_springsource_org_apache_commons_net"
],
visibility = [
"//visibility:public"
]
)


16 changes: 16 additions & 0 deletions 3rdparty/jvm/org/apache/ws/commons/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "ws_commons_util",
exports = [
"//external:jar/org/apache/ws/commons/ws_commons_util"
],
runtime_deps = [
"//3rdparty/jvm/junit:junit",
"//3rdparty/jvm/xml_apis:xml_apis"
],
visibility = [
"//visibility:public"
]
)


12 changes: 12 additions & 0 deletions 3rdparty/jvm/org/mockito/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "mockito_all",
exports = [
"//external:jar/org/mockito/mockito_all"
],
visibility = [
"//visibility:public"
]
)


33 changes: 33 additions & 0 deletions 3rdparty/jvm/org/ros/rosjava_bootstrap/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "gradle_plugins",
exports = [
"//external:jar/org/ros/rosjava_bootstrap/gradle_plugins"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "message_generation",
exports = [
"//external:jar/org/ros/rosjava_bootstrap/message_generation"
],
runtime_deps = [
"//3rdparty/jvm/com/google/guava:guava",
"//3rdparty/jvm/commons_pool:commons_pool",
"//3rdparty/jvm/io/netty:netty",
"//3rdparty/jvm/org/apache/commons:com_springsource_org_apache_commons_codec",
"//3rdparty/jvm/org/apache/commons:com_springsource_org_apache_commons_io",
"//3rdparty/jvm/org/apache/commons:com_springsource_org_apache_commons_lang",
":gradle_plugins"
],
visibility = [
"//visibility:public"
]
)


31 changes: 31 additions & 0 deletions 3rdparty/jvm/org/ros/rosjava_messages/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "rosgraph_msgs",
exports = [
"//external:jar/org/ros/rosjava_messages/rosgraph_msgs"
],
runtime_deps = [
"//3rdparty/jvm/org/ros/rosjava_bootstrap:message_generation",
":std_msgs"
],
visibility = [
"//visibility:public"
]
)



java_library(
name = "std_msgs",
exports = [
"//external:jar/org/ros/rosjava_messages/std_msgs"
],
runtime_deps = [
"//3rdparty/jvm/org/ros/rosjava_bootstrap:message_generation"
],
visibility = [
"//visibility:public"
]
)


12 changes: 12 additions & 0 deletions 3rdparty/jvm/xml_apis/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.
java_library(
name = "xml_apis",
exports = [
"//external:jar/xml_apis/xml_apis"
],
visibility = [
"//visibility:public"
]
)


37 changes: 37 additions & 0 deletions 3rdparty/workspace.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Do not edit. bazel-deps autogenerates this file from dependencies.yaml.

def declare_maven(hash):
native.maven_jar(
name = hash["name"],
artifact = hash["artifact"],
sha1 = hash["sha1"],
repository = hash["repository"]
)
native.bind(
name = hash["bind"],
actual = hash["actual"]
)

def maven_dependencies(callback = declare_maven):
callback({"artifact": "com.google.code.findbugs:jsr305:1.3.9", "lang": "java", "sha1": "40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf", "repository": "https://jcenter.bintray.com/", "name": "com_google_code_findbugs_jsr305", "actual": "@com_google_code_findbugs_jsr305//jar", "bind": "jar/com/google/code/findbugs/jsr305"})
callback({"artifact": "com.google.guava:guava:12.0", "lang": "java", "sha1": "5bc66dd95b79db1e437eb08adba124a3e4088dc0", "repository": "https://jcenter.bintray.com/", "name": "com_google_guava_guava", "actual": "@com_google_guava_guava//jar", "bind": "jar/com/google/guava/guava"})
callback({"artifact": "commons-pool:commons-pool:1.6", "lang": "java", "sha1": "4572d589699f09d866a226a14b7f4323c6d8f040", "repository": "https://jcenter.bintray.com/", "name": "commons_pool_commons_pool", "actual": "@commons_pool_commons_pool//jar", "bind": "jar/commons_pool/commons_pool"})
callback({"artifact": "dnsjava:dnsjava:2.1.1", "lang": "java", "sha1": "5708df81cf6dbff545695f0be6380b7bbc85accc", "repository": "https://jcenter.bintray.com/", "name": "dnsjava_dnsjava", "actual": "@dnsjava_dnsjava//jar", "bind": "jar/dnsjava/dnsjava"})
callback({"artifact": "io.netty:netty:3.5.13.Final", "lang": "java", "sha1": "389edea561995909d5df3e70fb2c49954ac79a54", "repository": "https://jcenter.bintray.com/", "name": "io_netty_netty", "actual": "@io_netty_netty//jar", "bind": "jar/io/netty/netty"})
# duplicates in junit:junit fixed to 4.8.2
# - org.apache.ws.commons:ws-commons-util:1.0.1 wanted version 3.8.1
# - dnsjava:dnsjava:2.1.1 wanted version 3.8.2
callback({"artifact": "junit:junit:4.8.2", "lang": "java", "sha1": "c94f54227b08100974c36170dcb53329435fe5ad", "repository": "https://jcenter.bintray.com/", "name": "junit_junit", "actual": "@junit_junit//jar", "bind": "jar/junit/junit"})
callback({"artifact": "org.apache.commons:com.springsource.org.apache.commons.codec:1.3.0", "lang": "java", "sha1": "f8690570eb0913d750262bb4223eed30b0d619ed", "repository": "https://jcenter.bintray.com/", "name": "org_apache_commons_com_springsource_org_apache_commons_codec", "actual": "@org_apache_commons_com_springsource_org_apache_commons_codec//jar", "bind": "jar/org/apache/commons/com_springsource_org_apache_commons_codec"})
callback({"artifact": "org.apache.commons:com.springsource.org.apache.commons.httpclient:3.1.0", "lang": "java", "sha1": "c493a925a091ac3d8f449d9265fe12482dabb2a7", "repository": "https://jcenter.bintray.com/", "name": "org_apache_commons_com_springsource_org_apache_commons_httpclient", "actual": "@org_apache_commons_com_springsource_org_apache_commons_httpclient//jar", "bind": "jar/org/apache/commons/com_springsource_org_apache_commons_httpclient"})
callback({"artifact": "org.apache.commons:com.springsource.org.apache.commons.io:1.4.0", "lang": "java", "sha1": "51097cd000ec88214ff181c9f059947de1cf4a35", "repository": "https://jcenter.bintray.com/", "name": "org_apache_commons_com_springsource_org_apache_commons_io", "actual": "@org_apache_commons_com_springsource_org_apache_commons_io//jar", "bind": "jar/org/apache/commons/com_springsource_org_apache_commons_io"})
callback({"artifact": "org.apache.commons:com.springsource.org.apache.commons.lang:2.4.0", "lang": "java", "sha1": "686e3713650c8e3a5d98723b4d3e239586bf9822", "repository": "https://jcenter.bintray.com/", "name": "org_apache_commons_com_springsource_org_apache_commons_lang", "actual": "@org_apache_commons_com_springsource_org_apache_commons_lang//jar", "bind": "jar/org/apache/commons/com_springsource_org_apache_commons_lang"})
callback({"artifact": "org.apache.commons:com.springsource.org.apache.commons.logging:1.1.1", "lang": "java", "sha1": "7657caf2c78e1d79c74d36f2ae128a115f7cc180", "repository": "https://jcenter.bintray.com/", "name": "org_apache_commons_com_springsource_org_apache_commons_logging", "actual": "@org_apache_commons_com_springsource_org_apache_commons_logging//jar", "bind": "jar/org/apache/commons/com_springsource_org_apache_commons_logging"})
callback({"artifact": "org.apache.commons:com.springsource.org.apache.commons.net:2.0.0", "lang": "java", "sha1": "03e78766072ff5a5cf3f5431d973c430c94ec612", "repository": "https://jcenter.bintray.com/", "name": "org_apache_commons_com_springsource_org_apache_commons_net", "actual": "@org_apache_commons_com_springsource_org_apache_commons_net//jar", "bind": "jar/org/apache/commons/com_springsource_org_apache_commons_net"})
callback({"artifact": "org.apache.ws.commons:ws-commons-util:1.0.1", "lang": "java", "sha1": "126e80ff798fece634bc94e61f8be8a8da00be60", "repository": "https://jcenter.bintray.com/", "name": "org_apache_ws_commons_ws_commons_util", "actual": "@org_apache_ws_commons_ws_commons_util//jar", "bind": "jar/org/apache/ws/commons/ws_commons_util"})
callback({"artifact": "org.mockito:mockito-all:1.8.5", "lang": "java", "sha1": "a927d8ae3b8d22eb745a74f94e59ce3882f2b524", "repository": "https://jcenter.bintray.com/", "name": "org_mockito_mockito_all", "actual": "@org_mockito_mockito_all//jar", "bind": "jar/org/mockito/mockito_all"})
callback({"artifact": "org.ros.rosjava_bootstrap:gradle_plugins:0.3.0", "lang": "java", "sha1": "9915d897f3b5049e99b268068978a1bca0ae7b5d", "repository": "https://github.com/rosjava/rosjava_mvn_repo/raw/master", "name": "org_ros_rosjava_bootstrap_gradle_plugins", "actual": "@org_ros_rosjava_bootstrap_gradle_plugins//jar", "bind": "jar/org/ros/rosjava_bootstrap/gradle_plugins"})
callback({"artifact": "org.ros.rosjava_bootstrap:message_generation:0.3.0", "lang": "java", "sha1": "5141e448f0ea6a2d6f539219d4fc9b296ff07ca4", "repository": "https://github.com/rosjava/rosjava_mvn_repo/raw/master", "name": "org_ros_rosjava_bootstrap_message_generation", "actual": "@org_ros_rosjava_bootstrap_message_generation//jar", "bind": "jar/org/ros/rosjava_bootstrap/message_generation"})
callback({"artifact": "org.ros.rosjava_messages:rosgraph_msgs:1.11.2", "lang": "java", "sha1": "adb731dd5181976b23c217872f61c724a3af70fe", "repository": "https://github.com/rosjava/rosjava_mvn_repo/raw/master", "name": "org_ros_rosjava_messages_rosgraph_msgs", "actual": "@org_ros_rosjava_messages_rosgraph_msgs//jar", "bind": "jar/org/ros/rosjava_messages/rosgraph_msgs"})
callback({"artifact": "org.ros.rosjava_messages:std_msgs:0.5.11", "lang": "java", "sha1": "a0191f0506dfecfc471eb199a119691717801c0e", "repository": "https://github.com/rosjava/rosjava_mvn_repo/raw/master", "name": "org_ros_rosjava_messages_std_msgs", "actual": "@org_ros_rosjava_messages_std_msgs//jar", "bind": "jar/org/ros/rosjava_messages/std_msgs"})
callback({"artifact": "xml-apis:xml-apis:1.0.b2", "lang": "java", "sha1": "3136ca936f64c9d68529f048c2618bd356bf85c9", "repository": "https://jcenter.bintray.com/", "name": "xml_apis_xml_apis", "actual": "@xml_apis_xml_apis//jar", "bind": "jar/xml_apis/xml_apis"})
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,44 @@ code. The CLA protects you and us.
Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Damon will respond on either github
or email to confirm.

### Building with Bazel ###

To build this project with Bazel, simply run:

```
bazel build //...
```

To depend on `rosjava_core` from another project, you'll need to use
[bazel-deps](https://github.com/johnynek/bazel-deps).

1. Start by copying (or merging) [dependencies.yaml][dependencies.yaml] in to
your project.
1. Follow the instructions in that file to generate the BUILD files inside your
project.
1. Add the following lines to your WORKSPACE file:

```
load("//3rdparty:workspace.bzl", "maven_dependencies")
maven_dependencies()
git_repository(
name = "com_github_rosjava_rosjava_core",
commit = "{insert commit SHA for HEAD}",
remote = "https://github.com/rosjava/rosjava_core.git",
)
load("@com_github_rosjava_rosjava_core//bazel:repositories.bzl", "rosjava_repositories")
rosjava_repositories()
```

*You may want to use `http_archive` instead of `git_repository` for the reasons
described in the [Bazel docs][git-repository-docs].*

[git-repository-docs]: https://docs.bazel.build/versions/master/be/workspace.html#git_repository

You can now depend on rosjava targets (eg
`@com_github_rosjava_rosjava_core//rosjava`) as required by your application.
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
workspace(name = "com_github_rosjava_rosjava_core")

load("//3rdparty:workspace.bzl", "maven_dependencies")

maven_dependencies()

load("//bazel:repositories.bzl", "rosjava_repositories")

rosjava_repositories()
15 changes: 15 additions & 0 deletions apache_xmlrpc_client/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
java_library(
name = "apache_xmlrpc_client",
srcs = glob([
"src/main/**/*.java",
]),
resources = glob([
"src/main/resources/**",
]),
visibility = ["//visibility:public"],
deps = [
"//3rdparty/jvm/org/apache/commons:com_springsource_org_apache_commons_httpclient",
"//3rdparty/jvm/org/apache/ws/commons:ws_commons_util",
"//apache_xmlrpc_common",
],
)
11 changes: 11 additions & 0 deletions apache_xmlrpc_common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
java_library(
name = "apache_xmlrpc_common",
srcs = glob([
"src/main/**/*.java",
]),
visibility = ["//visibility:public"],
deps = [
"//3rdparty/jvm/org/apache/commons:com_springsource_org_apache_commons_httpclient",
"//3rdparty/jvm/org/apache/ws/commons:ws_commons_util",
],
)
Loading

0 comments on commit cc8f806

Please sign in to comment.