找回密码
 加入最MC
搜索
热搜: 活动 交友 discuz
查看: 662|回复: 0

[资源]分享针对国内开发者的Maven源镜像

[复制链接]
发表于 2019-2-10 00:31:17 | 显示全部楼层 |阅读模式
记得最开始使用Maven的时候,基本上大部分时间都花在寻找依赖和下载依赖上。
许多API的作者也都是把自己的工件放在自己的maven仓库上,  
如果你使用Maven或者Gradle,那么你不仅要在pom.xml中写dependency,还要写一个repository。
有些仓库在国内访问还很慢、甚至无法打开,这大大降低了开发效率。

如果你现在正为此苦恼的话,那么试试我搭建的仓库吧!  

介绍  


仓库地址:https://lss233.com/artifactory/minecraft
这个仓库镜像了以下内容:
  • Spigot的Snapshots (主要包含了spigot-api, bukkit-api)
  • Spongepowered (主要包含了spongeapi, spongecommon 以及其他开发sponge插件可能用到的工件)
  • forge(镜像了files.minecraftforge.net/maven)
  • nexus.hc.to(主要包含了vault-api, heroes, Residence等工件)
  • placeholderapi-repo(主要包含了PlaceholderAPI)
  • sk89q-repo (主要包含了worldedit, worldguard, craftbook,dynmap-api 等工件 )
  • dmulloy2-snapshots(主要包含了ProtocolLib等工件)
  • ess3-repo (主要包含了Essentials插件的一些工件)
  • dakanilabs-repo (主要包含了SQLibrary, PlayerPoints等一些工件)
  • kk-central (主要包含了KCauldron等一些工件)
  • Phoenix(主要包含了PhoenixAPI)
  • destroystokyo-repo(主要包含paper-api, paperclip, waterfall等工件)
  • lex-snapshots(主要包含了NeptuneLib)
  • sonatype(主要包含了bungeecord-api等一大堆工件)
  • codemc(主要包含了craftbukkit、spigot服务端)
  • nukkit (主要包含了nukkit, nukkit-parent)
  • libraries.minecraft.net


使用方法

对于使用Maven进行开发的小伙伴  

打开pom.xml ,在 <repositories> ... </repositories> 代码块中加入:
  1. <repository>
  2.   <id> lss233-minecraft </id>
  3.   <name> Lss233's Minecraft Repository </name>
  4.   <url>https://lss233.com/artifactory/minecraft</url>
  5. </repository>
复制代码
然后就可以把其他已经在本仓库中的 <repository> ... </repository> 删除啦。  
Gradle Wrapper加速
通常首次使用 gradlew 的时候总会从Gradle官网缓慢地下载gradle.
本人对此也提供了一个简单的镜像。
加速方法:
打开项目中的 gradle/wrapper/gradle-wrapper.properties 文件,
将 services.gradle.org/distributions 替换为 lss233.com/artifactory/gradle-dist 即可。

对于使用Gradle进行Forge Mod开发的小伙伴  

把build.gradle里
  1. maven {
  2.             name = "forge"
  3.             url = "http://files.minecraftforge.net/maven"
  4.         }
复制代码
替换成
  1. maven {
  2.             name = "forge"
  3.             url = "https://lss233.com/artifactory/minecraft"
  4.         }
复制代码
就可以提升下载速度啦,还能避免下载失败的问题呢。
高版本MDK  
如果使用高版本的MDK,可能还会遇到 jcenter 无法访问的现象。  
解决方法:
由于仓库中已经包含JCenter,您可以直接将build.gradle中的 jcenter() 删除。

完整版的build.gradle参考:
1.12.2


  1. buildscript {
  2.     repositories {
  3.         jcenter()
  4.         maven { url = "https://lss233.com/artifactory/minecraft" }
  5.     }
  6.     dependencies {
  7.         classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
  8.     }
  9. }
  10. apply plugin: 'net.minecraftforge.gradle.forge'

  11. version = "1.0"
  12. group= "com.yourname" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  13. archivesBaseName = "modid"

  14. sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
  15. compileJava {
  16.     sourceCompatibility = targetCompatibility = '1.8'
  17. }

  18. minecraft {
  19.     version = "1.12.2-14.23.5.2808"
  20.     runDir = "run"

  21.     // the mappings can be changed at any time, and must be in the following format.
  22.     // snapshot_YYYYMMDD   snapshot are built nightly.
  23.     // stable_#            stables are built at the discretion of the MCP team.
  24.     // Use non-default mappings at your own risk. they may not always work.
  25.     // simply re-run your setup task after changing the mappings to update your workspace.
  26.     mappings = "snapshot_20171003"
  27.     // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
  28. }

  29. dependencies {
  30.     // you may put jars on which you depend on in ./libs
  31.     // or you may define them like so..
  32.     //compile "some.group:artifact:version:classifier"
  33.     //compile "some.group:artifact:version"

  34.     // real examples
  35.     //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
  36.     //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

  37.     // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
  38.     //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

  39.     // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
  40.     // except that these dependencies get remapped to your current MCP mappings
  41.     //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
  42.     //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

  43.     // for more info...
  44.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  45.     // http://www.gradle.org/docs/current/userguide/dependency_management.html

  46. }

  47. processResources {
  48.     // this will ensure that this task is redone when the versions change.
  49.     inputs.property "version", project.version
  50.     inputs.property "mcversion", project.minecraft.version

  51.     // replace stuff in mcmod.info, nothing else
  52.     from(sourceSets.main.resources.srcDirs) {
  53.         include 'mcmod.info'

  54.         // replace version and mcversion
  55.         expand 'version':project.version, 'mcversion':project.minecraft.version
  56.     }

  57.     // copy everything else except the mcmod.info
  58.     from(sourceSets.main.resources.srcDirs) {
  59.         exclude 'mcmod.info'
  60.     }
  61. }
复制代码


1.7.10:


  1. buildscript {
  2.     repositories {
  3.         mavenLocal()
  4.         mavenCentral()

  5.         maven {
  6.             url = "https://lss233.com/artifactory/minecraft"
  7.         }
  8.     }
  9.     dependencies {
  10.         classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
  11.     }
  12. }

  13. apply plugin: 'forge'

  14. version = "1.0"
  15. group= "com.yourname" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  16. archivesBaseName = "modid"

  17. minecraft {
  18.     version = "1.7.10-10.13.4.1558-1.7.10"
  19.     runDir = "eclipse"
  20. }

  21. dependencies {
  22.     // you may put jars on which you depend on in ./libs
  23.     // or you may define them like so..
  24.     //compile "some.group:artifact:version:classifier"
  25.     //compile "some.group:artifact:version"
  26.       
  27.     // real examples
  28.     //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
  29.     //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
  30.     // for more info...
  31.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  32.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  33.     compile project(':PokeMarketCommon')
  34. }

  35. processResources
  36. {
  37.     // this will ensure that this task is redone when the versions change.
  38.     inputs.property "version", project.version
  39.     inputs.property "mcversion", project.minecraft.version

  40.     // replace stuff in mcmod.info, nothing else
  41.     from(sourceSets.main.resources.srcDirs) {
  42.         include 'mcmod.info'
  43.                
  44.         // replace version and mcversion
  45.         expand 'version':project.version, 'mcversion':project.minecraft.version
  46.     }
  47.         
  48.     // copy everything else, thats not the mcmod.info
  49.     from(sourceSets.main.resources.srcDirs) {
  50.         exclude 'mcmod.info'
  51.     }
  52. }
复制代码



对于使用Gradle进行插件开发的小伙伴  
在build.gradle里的   repositories { .... }  里面加入一行:
  1. maven {
  2.             url 'https://lss233.com/artifactory/minecraft/'
  3. }
复制代码



对于啥都不用的小伙伴  

你可以用浏览器直接打开本仓库的网址,自行寻找你想要的依赖。


如果您有什么需要补充的仓库,或者想要提交自己的工件,也可以告诉我喔。
另外,如果出现 504 Gateway Time-out 的情况,应该是不会影响你的构建程序自动下载文件的。
如果本仓库无法正常使用,请提醒我,我会尽快修复。



最后
本人是没有稳定收入的学生,维护这个镜像服务需要不小的开销。
关于本镜像源的更新会首发于本人博客,你可以点击这里访问。
如果这个东西对您有帮助、想支持我继续下去,可以了解一下我在爱发电的主页喔~



















评分

参与人数 1人气 +10 收起 理由
NFC_Yan + 10 精华内容!

查看全部评分

您需要登录后才可以回帖 登录 | 加入最MC

本版积分规则

Archiver|手机版|小黑屋|最MC论坛 ( 粤ICP备12035413号 )

GMT+8, 2026-12-1 03:43 , Processed in 0.026902 second(s), 19 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表