You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/04/13 09:43:12 UTC
[incubator-servicecomb-java-chassis] 01/02: SCB-457 demostrate how
to run bmi with gradle
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit 98e49b13d18360e36f1aca912d7ba340200137f3
Author: Eric Lee <da...@huawei.com>
AuthorDate: Mon Apr 9 17:06:05 2018 +0800
SCB-457 demostrate how to run bmi with gradle
Signed-off-by: Eric Lee <da...@huawei.com>
---
.gitignore | 3 +++
samples/bmi/README.md | 31 +++++++++++++++------
samples/bmi/build.gradle | 54 +++++++++++++++++++++++++++++++++++++
samples/bmi/calculator/build.gradle | 49 +++++++++++++++++++++++++++++++++
samples/bmi/settings.gradle | 23 ++++++++++++++++
samples/bmi/webapp/build.gradle | 49 +++++++++++++++++++++++++++++++++
6 files changed, 201 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 044d558..67e5a7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,3 +80,6 @@ __pycache__/
# Mac
.DS_Store
+
+# gradle
+.gradle
diff --git a/samples/bmi/README.md b/samples/bmi/README.md
index e7a9c9e..3d37342 100644
--- a/samples/bmi/README.md
+++ b/samples/bmi/README.md
@@ -7,6 +7,7 @@ There are two microservices in this demo.
## Prerequisite
1. [Oracle JDK 1.8+](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html)
2. [Maven 3.x](https://maven.apache.org/install.html)
+3. [Gradle 4.x](https://gradle.org/install/)(Optional)
## Quick Start(Linux)
1. Run the service center
@@ -19,12 +20,26 @@ git clone https://github.com/apache/incubator-servicecomb-java-chassis.git
cd incubator-servicecomb-java-chassis/samples
```
3. Run microservices
-* Run the **BMI calculator service**
-```bash
-(cd bmi/calculator; mvn spring-boot:run)
-```
-* Run the **webapp service**
-```bash
-(cd bmi/webapp; mvn spring-boot:run)
-```
+* via maven
+ * Run the **BMI calculator service**
+ ```bash
+ (cd bmi/calculator; mvn spring-boot:run)
+ ```
+ * Run the **webapp service**
+ ```bash
+ (cd bmi/webapp; mvn spring-boot:run)
+ ```
+* via gradle
+ * Install ServiceComb Java Chassis
+ ```bash
+ mvn clean install -DskipTests
+ ```
+ * Run the **BMI calculator service**
+ ```bash
+ (cd bmi/calculator; gradle bootRun)
+ ```
+ * Run the **webapp service**
+ ```bash
+ (cd bmi/webapp; gradle bootRun)
+ ```
4. Visit the services via **<a>http://127.0.0.1:8889</a>**.
diff --git a/samples/bmi/build.gradle b/samples/bmi/build.gradle
new file mode 100644
index 0000000..7109344
--- /dev/null
+++ b/samples/bmi/build.gradle
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+allprojects {
+ apply plugin: 'maven'
+
+ group = 'org.apache.servicecomb.samples'
+ version = '1.0.0-m2-SNAPSHOT'
+}
+
+buildscript {
+ dependencies {
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.5.RELEASE")
+ }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+}
+
+subprojects {
+ apply plugin: 'java'
+ apply plugin: 'org.springframework.boot'
+
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+
+ tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+ }
+
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+
+ dependencies {
+ compile group: 'org.hibernate', name: 'hibernate-validator', version:'5.2.4.Final'
+ }
+}
diff --git a/samples/bmi/calculator/build.gradle b/samples/bmi/calculator/build.gradle
new file mode 100644
index 0000000..16223d9
--- /dev/null
+++ b/samples/bmi/calculator/build.gradle
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+description = 'Java Chassis::Samples::BMI::Calculator'
+
+dependencies {
+ compile(group: 'org.springframework.boot', name: 'spring-boot-starter') {
+ exclude(module: 'commons-logging')
+ }
+ compile group: 'org.apache.servicecomb', name: 'spring-boot-starter-provider'
+ compile group: 'org.apache.servicecomb', name: 'handler-flowcontrol-qps'
+ compile group: 'org.apache.servicecomb', name: 'handler-bizkeeper'
+ compile group: 'org.apache.servicecomb', name: 'handler-tracing-zipkin'
+}
+
+// dependency-management-plugin is a replacement of dependencyManagement in maven
+// we need to enable the plugin and specify the dependencyManagement in the following form in each submodule
+// according to the official document: https://github.com/spring-gradle-plugins/dependency-management-plugin.
+buildscript {
+ dependencies {
+ classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
+ }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+}
+
+apply plugin: 'io.spring.dependency-management'
+
+dependencyManagement {
+ imports {
+ mavenBom 'org.apache.servicecomb:java-chassis-dependencies:1.0.0-m2-SNAPSHOT'
+ }
+}
diff --git a/samples/bmi/settings.gradle b/samples/bmi/settings.gradle
new file mode 100644
index 0000000..308a503
--- /dev/null
+++ b/samples/bmi/settings.gradle
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+rootProject.name = 'bmi'
+include ':bmi-calculator'
+include ':webapp'
+
+project(':bmi-calculator').projectDir = "$rootDir/calculator" as File
+project(':webapp').projectDir = "$rootDir/webapp" as File
\ No newline at end of file
diff --git a/samples/bmi/webapp/build.gradle b/samples/bmi/webapp/build.gradle
new file mode 100644
index 0000000..c8973f6
--- /dev/null
+++ b/samples/bmi/webapp/build.gradle
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+description = 'Java Chassis::Samples::BMI::Webapp'
+
+dependencies {
+ compile(group: 'org.springframework.boot', name: 'spring-boot-starter') {
+ exclude(module: 'commons-logging')
+ }
+ compile group: 'org.apache.servicecomb', name: 'spring-boot-starter-servicecomb'
+ compile group: 'org.apache.servicecomb', name: 'spring-boot-starter-discovery'
+ compile group: 'org.apache.servicecomb', name: 'spring-cloud-zuul'
+ compile group: 'org.apache.servicecomb', name: 'spring-cloud-zuul-zipkin'
+}
+
+// dependency-management-plugin is a replacement of dependencyManagement in maven
+// we need to enable the plugin and specify the dependencyManagement in the following form in each submodule
+// according to the official document: https://github.com/spring-gradle-plugins/dependency-management-plugin.
+buildscript {
+ dependencies {
+ classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
+ }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+}
+
+apply plugin: 'io.spring.dependency-management'
+
+dependencyManagement {
+ imports {
+ mavenBom 'org.apache.servicecomb:java-chassis-dependencies:1.0.0-m2-SNAPSHOT'
+ }
+}
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.