[ 
https://issues.apache.org/jira/browse/SCB-457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16437080#comment-16437080
 ] 

ASF GitHub Bot commented on SCB-457:
------------------------------------

WillemJiang closed pull request #640: SCB-457 demostrate how to run spring 
boot/non spring boot application with gradle
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/640
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.gitignore b/.gitignore
index 044d558c7..67e5a7dcf 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 e7a9c9e59..3d37342b9 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 000000000..7109344c5
--- /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 000000000..16223d9a0
--- /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 000000000..308a503ba
--- /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 000000000..c8973f6b8
--- /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'
+    }
+}
diff --git a/samples/codefirst-sample/README.md 
b/samples/codefirst-sample/README.md
index f74ba6468..dc9b0c674 100644
--- a/samples/codefirst-sample/README.md
+++ b/samples/codefirst-sample/README.md
@@ -24,30 +24,52 @@ For detail information please refer to 
[Doc](http://servicecomb.incubator.apache
 
 2. Start the codefirst-provider service
 
-   - Start provider service by maven
+   - Start provider service via maven
 
-     Compile the source code at root directory of ServiceComb Java Chassis, 
which is `incubator-servicecomb-java-chassis/`, and use `mvn exec` to execute 
the main class `CodeFirstProviderMain`.
+      Compile the source code at root directory of ServiceComb Java Chassis, 
which is `incubator-servicecomb-java-chassis/`, and use `mvn exec` to execute 
the main class `CodeFirstProviderMain`.
 
-     ```bash
-     cd incubator-servicecomb-java-chassis/
-     mvn clean install -Psamples -DskipTests                   #only need to 
install at first time.
-     cd samples/codefirst-sample/codefirst-provider/
-     mvn exec:java 
-Dexec.mainClass="org.apache.servicecomb.samples.codefirst.provider.CodeFirstProviderMain"
-     ```
+      ```bash
+      cd incubator-servicecomb-java-chassis/
+      mvn clean install -Psamples -DskipTests                  #only need to 
install at first time.
+      cd samples/codefirst-sample/codefirst-provider/
+      mvn exec:java 
-Dexec.mainClass="org.apache.servicecomb.samples.codefirst.provider.CodeFirstProviderMain"
+      ```
 
-   - Start provider service by IDE
+   - Start provider service via gradle
 
-     Import the project by InteliJ IDEA or Eclipse, add sample module to 
pom.xml file in root module `incubator-servicecomb-java-chassis/pom.xml`, and 
add `<module>samples</module>` to `<modules></modules>` block, Then find `main` 
function `CodeFirstProviderMain` of provider service and `RUN` it like any 
other Java program.
+      Compile the source code at root directory of ServiceComb Java Chassis, 
which is `incubator-servicecomb-java-chassis/`, and use `mvn exec` to execute 
the main class `CodeFirstProviderMain`.
 
-3. Start the codefirst-consumer service
+      ```bash
+      cd incubator-servicecomb-java-chassis/
+      mvn clean install -Psamples -DskipTests                  #only need to 
install at first time.
+      cd samples/codefirst-sample/codefirst-provider/
+      gradle clean run
+      ```
+
+   - Start provider service via IDE
 
-   Just like how to start codefirst-provider service. But the main class of 
codefirst-consumer service is `CodeFirstConsumerMain`. 
+      Import the project by InteliJ IDEA or Eclipse, add sample module to 
pom.xml file in root module `incubator-servicecomb-java-chassis/pom.xml`, and 
add `<module>samples</module>` to `<modules></modules>` block, Then find `main` 
function `CodeFirstProviderMain` of provider service and `RUN` it like any 
other Java program.
+
+3. Start the codefirst-consumer service
 
    ```bash
    cd samples/codefirst-sample/codefirst-consumer/
-   mvn exec:java 
-Dexec.mainClass="org.apache.servicecomb.samples.codefirst.consumer.CodeFirstConsumerMain"
    ```
 
+   - Start consumer service via maven
+
+      Just like how to start codefirst-provider service. But the main class of 
codefirst-consumer service is `CodeFirstConsumerMain`.
+
+      ```bash
+      mvn exec:java 
-Dexec.mainClass="org.apache.servicecomb.samples.codefirst.consumer.CodeFirstConsumerMain"
+      ```
+
+   - Start consumer service via gradle
+
+      ```bash
+      gradle clean run
+      ```
+
 4. How to verify
    On the producer side, the output should contain the following stuffs if the 
producer starts up successfully:
    1. *'swagger: 2.0 info: version: 1.0.0 ...'* means the producer generated 
swagger contracts
diff --git a/samples/codefirst-sample/build.gradle 
b/samples/codefirst-sample/build.gradle
new file mode 100644
index 000000000..cfff44a76
--- /dev/null
+++ b/samples/codefirst-sample/build.gradle
@@ -0,0 +1,39 @@
+/*
+ * 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'
+}
+
+subprojects {
+    apply plugin: 'java'
+
+    sourceCompatibility = 1.8
+    targetCompatibility = 1.8
+
+    tasks.withType(JavaCompile) {
+        options.encoding = 'UTF-8'
+    }
+
+    repositories {
+        mavenLocal()
+        mavenCentral()
+    }
+}
\ No newline at end of file
diff --git a/samples/codefirst-sample/codefirst-consumer/build.gradle 
b/samples/codefirst-sample/codefirst-consumer/build.gradle
new file mode 100644
index 000000000..060ad092e
--- /dev/null
+++ b/samples/codefirst-sample/codefirst-consumer/build.gradle
@@ -0,0 +1,51 @@
+/*
+ * 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::CodeFirst::Consumer'
+
+dependencies {
+    compile group: 'org.apache.servicecomb', name: 'provider-pojo'
+    compile group: 'org.apache.servicecomb', name: 'transport-highway'
+    compile group: 'org.apache.servicecomb', name: 'transport-rest-vertx'
+    compile group: 'org.apache.servicecomb.samples', name: 'common-schema', 
version: '1.0.0-m2-SNAPSHOT'
+    compile group: 'org.slf4j', name: 'slf4j-log4j12'
+}
+
+apply plugin: 'application'
+
+mainClassName = 
'org.apache.servicecomb.samples.codefirst.consumer.CodeFirstConsumerMain'
+
+// 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 {
+    repositories {
+        mavenLocal()
+        mavenCentral()
+    }
+    dependencies {
+        
classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
+    }
+}
+
+apply plugin: 'io.spring.dependency-management'
+
+dependencyManagement {
+    imports {
+        mavenBom 
'org.apache.servicecomb:java-chassis-dependencies:1.0.0-m2-SNAPSHOT'
+    }
+}
\ No newline at end of file
diff --git a/samples/codefirst-sample/codefirst-provider/build.gradle 
b/samples/codefirst-sample/codefirst-provider/build.gradle
new file mode 100644
index 000000000..bb0b845f3
--- /dev/null
+++ b/samples/codefirst-sample/codefirst-provider/build.gradle
@@ -0,0 +1,52 @@
+/*
+ * 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::CodeFirst::Provider'
+
+dependencies {
+    compile group: 'org.apache.servicecomb', name: 'provider-pojo'
+    compile group: 'org.apache.servicecomb', name: 'provider-springmvc'
+    compile group: 'org.apache.servicecomb', name: 'transport-highway'
+    compile group: 'org.apache.servicecomb', name: 'transport-rest-vertx'
+    compile group: 'org.apache.servicecomb.samples', name: 'common-schema', 
version: '1.0.0-m2-SNAPSHOT'
+    compile group: 'org.slf4j', name: 'slf4j-log4j12'
+}
+
+apply plugin: 'application'
+
+mainClassName = 
'org.apache.servicecomb.samples.codefirst.provider.CodeFirstProviderMain'
+
+// 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 {
+    repositories {
+        mavenLocal()
+        mavenCentral()
+    }
+    dependencies {
+        
classpath('io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE')
+    }
+}
+
+apply plugin: 'io.spring.dependency-management'
+
+dependencyManagement {
+    imports {
+        mavenBom 
'org.apache.servicecomb:java-chassis-dependencies:1.0.0-m2-SNAPSHOT'
+    }
+}
\ No newline at end of file
diff --git a/samples/codefirst-sample/settings.gradle 
b/samples/codefirst-sample/settings.gradle
new file mode 100644
index 000000000..c32b5bb43
--- /dev/null
+++ b/samples/codefirst-sample/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 = 'codefirst-sample'
+include ':codefirst-provider'
+include ':codefirst-consumer'
+
+project(':codefirst-provider').projectDir = "$rootDir/codefirst-provider" as 
File
+project(':codefirst-consumer').projectDir = "$rootDir/codefirst-consumer" as 
File
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Verify if gradle can manage the ServiceComb java Chassis jars in a remote or 
> local maven repository
> ---------------------------------------------------------------------------------------------------
>
>                 Key: SCB-457
>                 URL: https://issues.apache.org/jira/browse/SCB-457
>             Project: Apache ServiceComb
>          Issue Type: Task
>            Reporter: Minzhi Yan
>            Assignee: Eric Lee
>            Priority: Major
>
> Verify if gradle can manage the ServiceComb java Chassis jars in a remote or 
> local maven repository, and provide the document on how to use Java Chassis 
> with gradle in the ServiceComb website.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to