Freeze_Dolphin
本帖最后由 Freeze_Dolphin 于 2021-1-27 08:58 编辑

taboolib-quickstart-archetype  

介绍
这是一个用于创建已经部署好的依赖taboolib的spigot/bukkit服务器插件的maven骨架
类似于TabooLib-SDK

专门给不肯搞gradle的maven钉子户用的

从archetype创建项目
(折叠框里的是图片)

  • 常见的IDE如Eclipse、IntelliJ在创建maven项目时都会让你选择archetype, 你可以直接用"Add Archetype"功能添加远程archetype到内部Nexus服务器; 也可以先添加archetype repository再从其中选取适当的archetype. 这里提供后一种方法, 以Eclipse为例:

  •         在设置(Preferences)中找到: Maven > Archetypes
  • 在右侧点击 "Add Remote Catalog" 并按照图中的方式进行配置


你也可以从控制台创建一个基于此archetype的maven项目

  • 打开console或者terminal, 切到你想要创建工程的目录下
  • 输入以下指令:
    1. mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeGroupId=io.freeze-dolphin.archetypes -DarchetypeArtifactId=taboolib-quickstart-archetype -DarchetypeVersion=1.1.0 -DarchetypeRepository=https://raw.github.com/freeze-dolphin/maven-repository/master/repository
    复制代码

  • 之后会让你配置项目的properties
    (properties中的"groupId"和""artifactId"以及"author"是必填项, 这些都可以在生成的pom.xml中修改)
  • 从ide导入生成的maven项目并开始开发

注意事项

  • 默认去掉了test包, 如果有需要可以自己加回来
  • 通过指令生成项目时请注意一定要用2.4版本的maven-archetype-plugin, 因为貌似只有2.x版本才能在命令行中指定archetypeRepository (当时费了我好久才发现这个= .=)


开源相关


开源地址

github上自建的maven repository: https://github.com/freeze-dolphin/maven-repository
taboolib-quickstart-archetype源码: https://github.com/freeze-dolphin/taboolib-quickstart-archetype

欢迎发issue



如果这个骨架有帮到你的话请在github给个Star或者 评个分


起名是真的难啊
不愧是大佬,深奥,看来我还要学习更多

saok200465
wows可还行 不愧是你

傻缺的秀秀
        MCBBS有你更精彩~

DarcJC
本帖最后由 DarcJC 于 2021-5-25 23:31 编辑

注意,对于Maven 3.x,IDEA添加ArcheType时的Repository是无效的。
相关issue:https://youtrack.jetbrains.com/issue/IDEA-223617

编辑2:Windows的PowerShell中,部分命令内容需使用引号。
  1. mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeGroupId="io.freeze-dolphin.archetypes" -DarchetypeArtifactId=taboolib-quickstart-archetype -DarchetypeVersion="1.1.0" -DarchetypeRepository=https://raw.github.com/freeze-dolphin/maven-repository/master/repository
复制代码


如果使用镜像,需要修改mirrorOf属性:
  1. <mirror>
  2.             <id>aliyunmaven</id>
  3.             <mirrorOf>central,!archetype</mirrorOf>
  4.             <name>阿里云公共仓库</name>
  5.             <url>https://maven.aliyun.com/repository/public</url>
  6.           </mirror>
复制代码
添加,!archetype。

然后对于高版本Maven,可以在项目的pom.xml下自定义archetype remote catalog。无需自定义profile。
  1. <repositories>
  2.         <repository>
  3.             <id>archetype</id><!-- id expected by maven-archetype-plugin to avoid fetching from everywhere -->
  4.             <url>https://raw.github.com/freeze-dolphin/maven-repository/master/repository</url>
  5.             <releases>
  6.                 <enabled>true</enabled>
  7.                 <checksumPolicy>fail</checksumPolicy>
  8.             </releases>
  9.             <snapshots>
  10.                 <enabled>true</enabled>
  11.                 <checksumPolicy>warn</checksumPolicy>
  12.             </snapshots>
  13.         </repository>
  14.     </repositories>
复制代码


原文:
如果非得要这样初始化的话,
可以在对应setting.xml中,添加:
  1. <profile>
  2.             <id>freeze-dolphin</id>
  3.             <repositories>
  4.                 <repository>
  5.                     <id>archetype</id><!-- id expected by maven-archetype-plugin to avoid fetching from everywhere -->
  6.                     <url>https://raw.github.com/freeze-dolphin/maven-repository/master/repository</url>
  7.                     <releases>
  8.                         <enabled>true</enabled>
  9.                         <checksumPolicy>fail</checksumPolicy>
  10.                     </releases>
  11.                     <snapshots>
  12.                         <enabled>true</enabled>
  13.                         <checksumPolicy>warn</checksumPolicy>
  14.                     </snapshots>
  15.                 </repository>
  16.             </repositories>
  17.         </profile>
复制代码

以及
  1. <activeProfile>freeze-dolphin</activeProfile>
复制代码


编辑1,2021年5月25日:
噢对,IDEA不能直接创建,好像是因为不支持交互模式。正在使用高版本Maven的话,建议使用IDEA创建项目后在项目目录使用命令创建。

Freeze_Dolphin
DarcJC 发表于 2021-5-25 22:36
注意,对于Maven 3.x,IDEA添加ArcheType时的Repository是无效的。
相关issue:https://youtrack.jetbrains ...

感谢补充鸭

(没想到这帖子过了这么久还有人看)