Skip to content

Commit 98e49b1

Browse files
eric-lee-ltkWillemJiang
authored andcommitted
SCB-457 demostrate how to run bmi with gradle
Signed-off-by: Eric Lee <[email protected]>
1 parent dfb7d35 commit 98e49b1

File tree

6 files changed

+201
-8
lines changed

6 files changed

+201
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ __pycache__/
8080

8181
# Mac
8282
.DS_Store
83+
84+
# gradle
85+
.gradle

samples/bmi/README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ There are two microservices in this demo.
77
## Prerequisite
88
1. [Oracle JDK 1.8+](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html)
99
2. [Maven 3.x](https://maven.apache.org/install.html)
10+
3. [Gradle 4.x](https://gradle.org/install/)(Optional)
1011

1112
## Quick Start(Linux)
1213
1. Run the service center
@@ -19,12 +20,26 @@ git clone https://github.com/apache/incubator-servicecomb-java-chassis.git
1920
cd incubator-servicecomb-java-chassis/samples
2021
```
2122
3. Run microservices
22-
* Run the **BMI calculator service**
23-
```bash
24-
(cd bmi/calculator; mvn spring-boot:run)
25-
```
26-
* Run the **webapp service**
27-
```bash
28-
(cd bmi/webapp; mvn spring-boot:run)
29-
```
23+
* via maven
24+
* Run the **BMI calculator service**
25+
```bash
26+
(cd bmi/calculator; mvn spring-boot:run)
27+
```
28+
* Run the **webapp service**
29+
```bash
30+
(cd bmi/webapp; mvn spring-boot:run)
31+
```
32+
* via gradle
33+
* Install ServiceComb Java Chassis
34+
```bash
35+
mvn clean install -DskipTests
36+
```
37+
* Run the **BMI calculator service**
38+
```bash
39+
(cd bmi/calculator; gradle bootRun)
40+
```
41+
* Run the **webapp service**
42+
```bash
43+
(cd bmi/webapp; gradle bootRun)
44+
```
3045
4. Visit the services via **<a>http://127.0.0.1:8889</a>**.

samples/bmi/build.gradle

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
allprojects {
19+
apply plugin: 'maven'
20+
21+
group = 'org.apache.servicecomb.samples'
22+
version = '1.0.0-m2-SNAPSHOT'
23+
}
24+
25+
buildscript {
26+
dependencies {
27+
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.5.RELEASE")
28+
}
29+
repositories {
30+
mavenLocal()
31+
mavenCentral()
32+
}
33+
}
34+
35+
subprojects {
36+
apply plugin: 'java'
37+
apply plugin: 'org.springframework.boot'
38+
39+
sourceCompatibility = 1.8
40+
targetCompatibility = 1.8
41+
42+
tasks.withType(JavaCompile) {
43+
options.encoding = 'UTF-8'
44+
}
45+
46+
repositories {
47+
mavenLocal()
48+
mavenCentral()
49+
}
50+
51+
dependencies {
52+
compile group: 'org.hibernate', name: 'hibernate-validator', version:'5.2.4.Final'
53+
}
54+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
description = 'Java Chassis::Samples::BMI::Calculator'
19+
20+
dependencies {
21+
compile(group: 'org.springframework.boot', name: 'spring-boot-starter') {
22+
exclude(module: 'commons-logging')
23+
}
24+
compile group: 'org.apache.servicecomb', name: 'spring-boot-starter-provider'
25+
compile group: 'org.apache.servicecomb', name: 'handler-flowcontrol-qps'
26+
compile group: 'org.apache.servicecomb', name: 'handler-bizkeeper'
27+
compile group: 'org.apache.servicecomb', name: 'handler-tracing-zipkin'
28+
}
29+
30+
// dependency-management-plugin is a replacement of dependencyManagement in maven
31+
// we need to enable the plugin and specify the dependencyManagement in the following form in each submodule
32+
// according to the official document: https://github.com/spring-gradle-plugins/dependency-management-plugin.
33+
buildscript {
34+
dependencies {
35+
classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
36+
}
37+
repositories {
38+
mavenLocal()
39+
mavenCentral()
40+
}
41+
}
42+
43+
apply plugin: 'io.spring.dependency-management'
44+
45+
dependencyManagement {
46+
imports {
47+
mavenBom 'org.apache.servicecomb:java-chassis-dependencies:1.0.0-m2-SNAPSHOT'
48+
}
49+
}

samples/bmi/settings.gradle

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
rootProject.name = 'bmi'
19+
include ':bmi-calculator'
20+
include ':webapp'
21+
22+
project(':bmi-calculator').projectDir = "$rootDir/calculator" as File
23+
project(':webapp').projectDir = "$rootDir/webapp" as File

samples/bmi/webapp/build.gradle

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
description = 'Java Chassis::Samples::BMI::Webapp'
19+
20+
dependencies {
21+
compile(group: 'org.springframework.boot', name: 'spring-boot-starter') {
22+
exclude(module: 'commons-logging')
23+
}
24+
compile group: 'org.apache.servicecomb', name: 'spring-boot-starter-servicecomb'
25+
compile group: 'org.apache.servicecomb', name: 'spring-boot-starter-discovery'
26+
compile group: 'org.apache.servicecomb', name: 'spring-cloud-zuul'
27+
compile group: 'org.apache.servicecomb', name: 'spring-cloud-zuul-zipkin'
28+
}
29+
30+
// dependency-management-plugin is a replacement of dependencyManagement in maven
31+
// we need to enable the plugin and specify the dependencyManagement in the following form in each submodule
32+
// according to the official document: https://github.com/spring-gradle-plugins/dependency-management-plugin.
33+
buildscript {
34+
dependencies {
35+
classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
36+
}
37+
repositories {
38+
mavenLocal()
39+
mavenCentral()
40+
}
41+
}
42+
43+
apply plugin: 'io.spring.dependency-management'
44+
45+
dependencyManagement {
46+
imports {
47+
mavenBom 'org.apache.servicecomb:java-chassis-dependencies:1.0.0-m2-SNAPSHOT'
48+
}
49+
}

0 commit comments

Comments
 (0)