layotto / java-sdk

java sdk for layotto
8 stars 13 forks source link

中文

How to use java sdk

1. import sdk

For a Maven project, add the following to your pom.xml file:

    <dependency>
        <groupId>io.mosn.layotto</groupId>
        <artifactId>runtime-sdk-parent</artifactId>
        <version>1.0.0</version>
    </dependency>

2. Run the examples

Clone this repository including the submodules:

git clone https://github.com/mosn/layotto.git

Build and run Layotto:

# make sure you replace this` ${projectpath}` with your own project path.
cd ${projectpath}/cmd/layotto
go build
./layotto start -c ../../configs/config_redis.json

Then head over to build the java-sdk Maven (Apache Maven version 3.x) project:

# make sure you replace this` ${projectpath}` with your own project path.
cd ${projectpath}/sdk/java-sdk
mvn clean install

Try the following examples to learn more about this SDK:

java sdk developer guide

How to format java sdk code

Compile before submit your pull request:

mvn clean compile

It will format your code automatically.

How to generate a Java PROTO file

Solution A

make proto

The script will download the layotto proto files and compile them automatically.

Solution B

1. Copy the proto files to spec/src/main/spec
2. Check option fields in these proto files

Make sure these option fields have been configurated.

spec/proto/runtime/v1/appcallback.proto :

option java_outer_classname = "AppCallbackProto";
option java_package = "spec.proto.runtime.v1";

spec/proto/runtime/v1/runtime.proto :

option java_outer_classname = "RuntimeProto";
option java_package = "spec.proto.runtime.v1";
3. Compile them into corresponding JAVA files
# make sure you replace this `${your PROJECT path}` with your own project path.
cd ${your PROJECT path}
mvn compile

How to publish jar to maven central repo

Our CI will do it automatically.

  1. The CI will build and publish the jars to the maven central repo after a new PR get merged.

If it's a snapshot version, e.g. 1.2.0-SNAPSHOT, it will be published to the central snapshot repo;

If it's not a snapshot version, e.g. 1.2.0, it will be published to the central staging repo.

Check the Release pipeline for more details.

  1. After maintainers release a new version in github, our Release without staging pipeline will publish the jars to the central release repo instead of the staging repo.