提交 bf668cfc 编写于 作者: 武汉红喜's avatar 武汉红喜

脚手架优化

上级 2d968c2a
......@@ -2,20 +2,60 @@
<archetype-descriptor name="standard">
<requiredProperties>
<requiredProperty key="package">
<defaultValue>${groupId}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdCamelCase">
<defaultValue>${artifactId.replaceAll("^a|-a", "A").replaceAll("^b|-b", "B").replaceAll("^c|-c", "C").replaceAll("^d|-d", "D").replaceAll("^e|-e", "E").replaceAll("^f|-f", "F").replaceAll("^g|-g", "G").replaceAll("^h|-h", "H").replaceAll("^i|-i", "I").replaceAll("^j|-j", "J").replaceAll("^k|-k", "K").replaceAll("^l|-l", "L").replaceAll("^m|-m", "M").replaceAll("^n|-n", "N").replaceAll("^o|-o", "O").replaceAll("^p|-p", "P").replaceAll("^q|-q", "Q").replaceAll("^r|-r", "R").replaceAll("^s|-s", "S").replaceAll("^t|-t", "T").replaceAll("^u|-u", "U").replaceAll("^v|-v", "V").replaceAll("^w|-w", "W").replaceAll("^x|-x", "X").replaceAll("^y|-y", "Y").replaceAll("^z|-z", "Z")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdPackage">
<defaultValue>${artifactId.replace("-",".")}</defaultValue>
<requiredProperty key="includeActuator">
<defaultValue>false</defaultValue>
</requiredProperty>
</requiredProperties>
<modules>
<module id="${rootArtifactId}-api" name="${rootArtifactId}-api" dir="__rootArtifactId__-api">
</module>
<module id="${rootArtifactId}-service" name="${rootArtifactId}-service" dir="__rootArtifactId__-service">
</module>
</modules>
<fileSets>
<fileSet filtered="true">
<directory></directory>
<fileSet filtered="true" encoding="UTF-8" packaged="true">
<directory>__rootArtifactId__-api/src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8" packaged="true">
<directory>__rootArtifactId__-api/src/test/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8" packaged="true">
<directory>__rootArtifactId__-service/src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8" packaged="true">
<directory>__rootArtifactId__-service/src/test/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory />
<includes>
<include>**/.gitignore</include>
<include>**/log4j2.xml</include>
<include>**/*.yaml</include>
<include>**/*.yml</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
......@@ -4,11 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<artifactId>${rootArtifactId}</artifactId>
<version>${version}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>${artifactId}-api</artifactId>
<artifactId>${artifactId}</artifactId>
</project>
\ No newline at end of file
......@@ -3,12 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<artifactId>${rootArtifactId}</artifactId>
<version>${version}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>${artifactId}-service</artifactId>
<artifactId>${artifactId}</artifactId>
<dependencies>
<dependency>
......@@ -20,10 +20,16 @@
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>Rocket.S8</version>
</dependency>
#if (${includeActuator} == 'true' || ${includeActuator} == 'Y' || ${includeActuator} == 'y')
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
#end
<dependency>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}-api</artifactId>
<artifactId>${rootArtifactId}-api</artifactId>
<version>${version}</version>
</dependency>
</dependencies>
......
package org.hongxi.${artifactIdPackage}.service.impl;
package ${package}.service.impl;
import org.apache.dubbo.config.annotation.Service;
import org.hongxi.${artifactIdPackage}.api.DemoService;
import ${package}.api.DemoService;
@Service
public class DemoServiceImpl implements DemoService {
public class ${artifactIdCamelCase}ServiceImpl implements ${artifactIdCamelCase}Service {
@Override
public String hello(String name) {
......
#!/bin/bash
type=${1}
groupId=${2}
artifactId=${3}
package=${4}
includeActuator=${5}
if [ -z "$type" ]; then
echo "you must enter project type: web or dubbo"
exit 0
fi
if [ -z "$groupId" ]; then
echo "you must enter groupId"
exit 0
fi
if [ -z "$artifactId" ]; then
echo "you must enter artifactId"
exit 0
fi
rm -rf ${artifactId}
rm -f ${artifactId}.tar
mvn archetype:generate \
-DarchetypeCatalog=internal \
-DarchetypeGroupId=org.hongxi \
-DarchetypeArtifactId=${type}-archetype \
-DarchetypeVersion=Rocket.S8 \
-DgroupId=${groupId} \
-DartifactId=${artifactId} \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=${package} \
-DincludeActuator=${includeActuator} \
-DinteractiveMode=false
tar -zcvf ${artifactId}.tar ${artifactId}
rm -rf ${artifactId}
time=$(date "+%Y-%m-%d %H:%M:%S")
echo "${time} create project ${artifactId} successfully" >> generate-project.log
# 可用java调用此脚本生成工程,上传至某个地方,然后下载
\ No newline at end of file
......@@ -2,20 +2,40 @@
<archetype-descriptor name="standard">
<requiredProperties>
<requiredProperty key="package">
<defaultValue>${groupId}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdCamelCase">
<defaultValue>${artifactId.replaceAll("^a|-a", "A").replaceAll("^b|-b", "B").replaceAll("^c|-c", "C").replaceAll("^d|-d", "D").replaceAll("^e|-e", "E").replaceAll("^f|-f", "F").replaceAll("^g|-g", "G").replaceAll("^h|-h", "H").replaceAll("^i|-i", "I").replaceAll("^j|-j", "J").replaceAll("^k|-k", "K").replaceAll("^l|-l", "L").replaceAll("^m|-m", "M").replaceAll("^n|-n", "N").replaceAll("^o|-o", "O").replaceAll("^p|-p", "P").replaceAll("^q|-q", "Q").replaceAll("^r|-r", "R").replaceAll("^s|-s", "S").replaceAll("^t|-t", "T").replaceAll("^u|-u", "U").replaceAll("^v|-v", "V").replaceAll("^w|-w", "W").replaceAll("^x|-x", "X").replaceAll("^y|-y", "Y").replaceAll("^z|-z", "Z")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdPackage">
<defaultValue>${artifactId.replace("-",".")}</defaultValue>
<requiredProperty key="includeActuator">
<defaultValue>false</defaultValue>
</requiredProperty>
</requiredProperties>
<fileSets>
<fileSet filtered="true">
<directory></directory>
<fileSet filtered="true" encoding="UTF-8" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8" packaged="true">
<directory>src/test/java</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory />
<includes>
<include>**/*.sh</include>
<include>**/.gitignore</include>
<include>**/*.xml</include>
<include>**/*.yaml</include>
<include>**/*.yml</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
......@@ -29,6 +29,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
#if (${includeActuator} == 'true' || ${includeActuator} == 'Y' || ${includeActuator} == 'y')
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
#end
</dependencies>
<build>
......
package org.hongxi.${artifactIdPackage}.controller;
package ${package}.controller;
import com.hongxi.${artifactIdPackage}.model.Greeting;
import ${package}.model.Greeting;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册