-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the initial skeleton of Matter Controller Java CLI App (#23048)
* Add initial skeleton of Java Controller App * Add build target for java_matter_controller * Update comments for java_binary template
- Loading branch information
1 parent
43c5792
commit 1310186
Showing
14 changed files
with
557 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
|
||
# Shared libs & JAR libs (those libs are copied into source tree for easy Android build). | ||
*.so | ||
*.jar | ||
*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2020-2022 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
|
||
# The location of the build configuration file. | ||
buildconfig = "${build_root}/config/BUILDCONFIG.gn" | ||
|
||
# CHIP uses angle bracket includes. | ||
check_system_includes = true | ||
|
||
default_args = { | ||
import("//args.gni") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright (c) 2022 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
|
||
import("${build_root}/config/android_abi.gni") | ||
import("${chip_root}/build/chip/java/rules.gni") | ||
import("${chip_root}/build/chip/tools.gni") | ||
|
||
android_binary("java-matter-controller") { | ||
output_name = "java-matter-controller" | ||
|
||
deps = [ | ||
":android", | ||
"${chip_root}/src/controller/java", | ||
"${chip_root}/src/setup_payload/java", | ||
"${chip_root}/third_party/android_deps:annotation", | ||
] | ||
|
||
sources = [ "java/src/com/matter/controller/Main.java" ] | ||
|
||
javac_flags = [ "-Xlint:deprecation" ] | ||
} | ||
|
||
java_prebuilt("android") { | ||
jar_path = "${android_sdk_root}/platforms/android-21/android.jar" | ||
} | ||
|
||
group("default") { | ||
deps = [ ":java-matter-controller" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Main-Class: com.matter.controller.Main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Matter Controller Java App Example | ||
|
||
This is a Matter Controller Java app that can be used to uses Matter to send | ||
messages to a Matter server. | ||
|
||
<hr> | ||
|
||
- [Matter Controller Java App Example](#matter-controller-java-app-example) | ||
- [Requirements for building](#requirements-for-building) | ||
- [Gradle & JDK Version](#gradle--jdk-version) | ||
- [Preparing for build](#preparing-for-build) | ||
- [Building & Running the app](#building--running-the-app) | ||
|
||
<hr> | ||
|
||
<a name="requirements"></a> | ||
|
||
## Requirements for building | ||
|
||
You need Android SDK 21 & NDK downloaded to your machine. Set the | ||
`$ANDROID_HOME` environment variable to where the SDK is downloaded and the | ||
`$ANDROID_NDK_HOME` environment variable to point to where the NDK package is | ||
downloaded. | ||
|
||
<a name="jdk"></a> | ||
|
||
### Gradle & JDK Version | ||
|
||
We are using Gradle 7.1.1 for all android project which does not support Java 17 | ||
(https://docs.gradle.org/current/userguide/compatibility.html) while the default | ||
JDK version on MacOS for Apple Silicon is 'openjdk 17.0.1' or above. | ||
|
||
Using JDK bundled with Android Studio will help with that. | ||
|
||
```shell | ||
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home/ | ||
``` | ||
|
||
<hr> | ||
|
||
<a name="preparing"></a> | ||
|
||
## Preparing for build | ||
|
||
Complete the following steps to prepare the Matter build: | ||
|
||
1. Check out the Matter repository. | ||
|
||
2. Run bootstrap (**only required first time**) | ||
|
||
```shell | ||
source scripts/bootstrap.sh | ||
``` | ||
|
||
<a name="building-running"></a> | ||
|
||
## Building & Running the app | ||
|
||
This is the simplest option. In the command line, run the following command from | ||
the top Matter directory: | ||
|
||
```shell | ||
./scripts/build/build_examples.py --target android-x86-java-matter-controller build | ||
``` | ||
|
||
The Java executable file `java-matter-controller` will be generated at | ||
`out/android-x86-java-matter-controller/bin/` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2020-2022 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/chip.gni") | ||
|
||
import("${chip_root}/config/standalone/args.gni") | ||
|
||
chip_device_project_config_include = "<CHIPProjectAppConfig.h>" | ||
chip_project_config_include = "<CHIPProjectAppConfig.h>" | ||
chip_system_project_config_include = "<SystemProjectConfig.h>" | ||
|
||
chip_project_config_include_dirs = | ||
[ "${chip_root}/examples/java-matter-controller/include" ] | ||
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../build_overrides |
Oops, something went wrong.