maven脚手架指引.md
文章目录
spring-cloud-lumos 脚手架
1. 使用方式:
1.1 引入脚手架
在idea里添加脚手架配置
1.2 创建项目
创建项目时,指定脚手架:

2. 创建脚手架方式
- 进入
spring-cloud-lumos-archetype模块根目录,执行:mvn archetype:create-from-project - 执行
cd target/generated-sources/archetype 修改
target/generated-sources/archetype/src/main/resource/META-INF/maven目录下的artchetype-metadata.xml:<br/>- 在
yml的fileSet上添加filtered="true",这样yml文件的变量${artifactId}就可以被替换了 在
Dockerfile提成一个独立的fileSet,上添加filtered="true",这样Dockerfile文件的变量${artifactId}就可以被替换了<fileSet filtered="true" encoding="UTF-8"> <directory></directory> <includes> <include>Dockerfile</include> </includes> </fileSet>- 其他需要替代变量的,也用以上添加
filtered="true"的方式;doc目录下的artchetype-metadata.xml是个示例,可直接复制&替换,无需上面两步的操作。
- 在
- 执行
mvn clean install,可以看到本地仓库的根目录有了archetype-catalog.xml文件,如果有多个settings.xml,可以在mvn指令里指定文件mvn clean install --settings /usr/local/apache-maven-3.6.1/conf/settings.xml 如果要上传到远程:<br/>
先修改
target/generated-sources/archetype下的pom文件,否则会报Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy (default-deploy) on project spring-cloud-lumos-archetype-archetype: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::url parameter。其中repository的id要跟maven的settings.xml文件里的server的id要一样,否则上传鉴权会失败。<distributionManagement> <repository> <id>mirrors-releases</id> <name>thirdparty</name> <url>https://xxx.xxx.com/repository/maven/thirdparty</url> </repository> <snapshotRepository> <id>mirrors-snapshots</id> <name>thirdparty-snapshots</name> <url>https://xxx.xxx.com/repository/maven/thirdparty-snapshots</url> </snapshotRepository> </distributionManagement>doc目录下的pom.xml是个示例,可直接复制&替换,无需上面一步的操作。
将
archetype-catalog.xml上传到仓库,让其他人也可以使用。(如果没有升级脚手架的版本的话,那就无需操作这一步,因为文件里的内容不会有变化)- 执行
mvn deploy:deploy-file -Durl=https://xxx.xxx.com/repository/maven/thirdparty-snapshots -DrepositoryId=mirrors-snapshots -Dfile=archetype-catalog.xml -DgroupId=com.tencent.lumos -DartifactId=spring-cloud-lumos-archetype-archetype -Dversion=0.0.2-SNAPSHOT -Dpackaging=xml。<br/> - TODO:通过这种方式deploy的文件,仓库里的文件名会被修改成其他文件名,而不是
archetype-catalog.xml,后续有时间了再看下有没有其他方式上传
- 执行

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论