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:13 UTC
[incubator-servicecomb-java-chassis] 02/02: SCB-457 demostrate how
to run non spring boot application 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 b31dce3692db1f6b01fdbe98e3e65e7f9740ad14
Author: Eric Lee <da...@huawei.com>
AuthorDate: Tue Apr 10 11:48:25 2018 +0800
SCB-457 demostrate how to run non spring boot application with gradle
Signed-off-by: Eric Lee <da...@huawei.com>
---
samples/codefirst-sample/README.md | 48 ++++++++++++++------
samples/codefirst-sample/build.gradle | 39 ++++++++++++++++
.../codefirst-consumer/build.gradle | 51 +++++++++++++++++++++
.../codefirst-provider/build.gradle | 52 ++++++++++++++++++++++
samples/codefirst-sample/settings.gradle | 23 ++++++++++
5 files changed, 200 insertions(+), 13 deletions(-)
diff --git a/samples/codefirst-sample/README.md b/samples/codefirst-sample/README.md
index f74ba64..dc9b0c6 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 0000000..cfff44a
--- /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 0000000..060ad09
--- /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 0000000..bb0b845
--- /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 0000000..c32b5bb
--- /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
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.