-
-
Notifications
You must be signed in to change notification settings - Fork 255
关于java 添加腾讯云镜像,mvnd支持,以及测速链接的支持 #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9542ce3
5aeb706
9bec7f3
71e7312
7e00ec6
7dfe942
afd1b08
1ea2009
f2a50d0
6a89e41
645a3d6
93088fe
c872c91
51863e7
ac50bd2
7c9e351
8b4504f
49e15b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* ------------------------------------------------------------*/ | ||
|
||
def_target(pl_java, "java/maven/mvn/gradle"); | ||
def_target(pl_java, "java/maven/mvn/maven-daemon/mvnd/gradle"); | ||
|
||
void | ||
pl_java_prelude () | ||
|
@@ -20,65 +20,119 @@ pl_java_prelude () | |
chef_allow_local_mode (this, CanNot, NULL, NULL); | ||
chef_forbid_english(this); | ||
chef_allow_user_define(this); | ||
chsrc_custom_user_agent("Maven/3.9.11"); | ||
|
||
def_sources_begin() | ||
{&UpstreamProvider, "https://repo1.maven.org/maven2/", DelegateToUpstream}, | ||
{&Ali, "https://maven.aliyun.com/repository/public/", DelegateToMirror}, | ||
{&Huawei, "https://mirrors.huaweicloud.com/repository/maven/", DelegateToMirror}, | ||
|
||
{&UpstreamProvider, "https://repo1.maven.org/maven2/", DelegateToUpstream}, | ||
{&Ali, "https://maven.aliyun.com/repository/public/", "https://maven.aliyun.com/repository/public/com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"}, | ||
{&Huawei, "https://mirrors.huaweicloud.com/repository/maven/", "https://mirrors.huaweicloud.com/repository/maven/com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"}, | ||
{&HuaweiCdn, "https://repo.huaweicloud.com/repository/maven/", "https://repo.huaweicloud.com/repository/maven/com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"}, | ||
{&Tencent, "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 可参考一下 https://github.com/RubyMetric/chsrc/blob/main/src/recipe/os/APT/Debian.c#L50 如果是直接往后面加后缀,可以直接用 chef_ 函数,不用定义一大堆重复的。 |
||
// 网易的24小时更新一次 | ||
{&Netease, "http://mirrors.163.com/maven/repository/maven-public/", DelegateToMirror} | ||
{&Netease, "http://mirrors.163.com/maven/repository/maven-public/", "https://mirrors.163.com/maven/repository/maven-public/com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"} | ||
def_sources_end() | ||
} | ||
|
||
|
||
void | ||
pl_java_check_cmd (bool *maven_exist, bool *gradle_exist) | ||
pl_java_check_cmd (bool *maven_exist, bool *gradle_exist, bool *maven_daemon_exist) | ||
{ | ||
*maven_exist = chsrc_check_program ("mvn"); | ||
*gradle_exist = chsrc_check_program ("gradle"); | ||
*maven_daemon_exist = chsrc_check_program ("mvnd"); | ||
|
||
if (! *maven_exist && ! *gradle_exist) | ||
if (! *maven_exist && ! *gradle_exist && ! *maven_daemon_exist) | ||
{ | ||
chsrc_error ("maven 与 gradle 命令均未找到,请检查是否存在其一"); | ||
chsrc_error ("maven(maven-daemon) 与 gradle 命令均未找到,请检查是否存在其一"); | ||
exit (Exit_UserCause); | ||
} | ||
} | ||
|
||
bool | ||
pl_java_is_home (const char *str) | ||
{ | ||
return (xy_str_start_with (str, "Maven home:")); | ||
} | ||
|
||
bool | ||
pl_java_find_maven_home (const char *line) | ||
{ | ||
if(pl_java_is_home(line)) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
char * | ||
pl_java_find_maven_config () | ||
{ | ||
char *buf = xy_run ("mvn -v", 2); | ||
char *maven_home = xy_str_delete_prefix (buf, "Maven home: "); | ||
maven_home = xy_str_strip (maven_home); | ||
char *output; | ||
int status = xy_run_capture ("mvn -v", &output); | ||
if (0==status) | ||
{ | ||
char *maven_home_line = xy_run_iter_lines ("mvn -v", 0, pl_java_find_maven_home); | ||
char *maven_home = xy_str_delete_prefix (maven_home_line, "Maven home: "); | ||
char *maven_config = xy_normalize_path (xy_2strcat (maven_home, "/conf/settings.xml")); | ||
return maven_config; | ||
} | ||
else | ||
{ | ||
printf("no find maven home\n"); | ||
} | ||
return "~/.m2/settings.xml"; | ||
} | ||
|
||
char *maven_config = xy_normalize_path (xy_2strcat (maven_home, "/conf/settings.xml")); | ||
return maven_config; | ||
char * | ||
pl_java_find_maven_daemon_config () | ||
{ | ||
char *output; | ||
int status = xy_run_capture ("mvnd -v", &output); | ||
if (0==status) | ||
{ | ||
char *maven_home_line = xy_run_iter_lines ("mvnd -v", 0, pl_java_find_maven_home); | ||
char *maven_home = xy_str_delete_prefix (maven_home_line, "Maven home: "); | ||
char *maven_config = xy_normalize_path (xy_2strcat (maven_home, "/conf/settings.xml")); | ||
return maven_config; | ||
} | ||
else | ||
{ | ||
printf ("no find maven home\n"); | ||
} | ||
return "~/.m2/settings.xml"; | ||
} | ||
|
||
|
||
void | ||
pl_java_getsrc (char *option) | ||
{ | ||
bool maven_exist, gradle_exist; | ||
pl_java_check_cmd (&maven_exist, &gradle_exist); | ||
char *maven_config = pl_java_find_maven_config (); | ||
chsrc_note2 (xy_2strcat ("请查看 ", maven_config)); | ||
bool maven_exist, gradle_exist, maven_daemon_exist; | ||
pl_java_check_cmd (&maven_exist, &gradle_exist, &maven_daemon_exist); | ||
if (maven_exist) | ||
{ | ||
char *maven_config = pl_java_find_maven_config (); | ||
chsrc_note2 (xy_2strcat ("请查看 ", maven_config)); | ||
} | ||
if(maven_daemon_exist) | ||
{ | ||
char *maven_config = pl_java_find_maven_daemon_config (); | ||
chsrc_note2 (xy_2strcat ("请查看 ", maven_config)); | ||
} | ||
} | ||
|
||
|
||
|
||
/** | ||
* @consult https://developer.aliyun.com/mirror/maven | ||
*/ | ||
void | ||
pl_java_setsrc (char *option) | ||
{ | ||
bool maven_exist, gradle_exist; | ||
pl_java_check_cmd (&maven_exist, &gradle_exist); | ||
|
||
chsrc_use_this_source (pl_java); | ||
bool maven_exist, gradle_exist, maven_daemon_exist; | ||
pl_java_check_cmd (&maven_exist, &gradle_exist, &maven_daemon_exist); | ||
|
||
chsrc_use_this_source(pl_java); | ||
use_custom_user_agent(); | ||
if (maven_exist) | ||
{ | ||
char *file = xy_str_gsub (RAWSTR_pl_java_maven_config, "@1@", source.mirror->code); | ||
|
@@ -89,6 +143,16 @@ pl_java_setsrc (char *option) | |
println (file); | ||
} | ||
|
||
if (maven_daemon_exist) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 条件不用加 “或” maven_exist 吗? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 其实我是想删掉这个命令判断的, 如果我是用windows 那么 这三个命令都将不存在,如果是linux 则正常存在。 因为我不会主动去配置环境变量,因为本身可以自动切换配置了反而导致每次切换要修改环境变量,甚至有时注销才能生效(还不支持同时启动 不同版本jdk的项目的需求) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
char *file = xy_str_gsub (RAWSTR_pl_java_maven_config, "@1@", source.mirror->code); | ||
file = xy_str_gsub (file, "@name@", source.mirror->name); | ||
file = xy_str_gsub (file, "@url@", source.url); | ||
char *maven_config = pl_java_find_maven_daemon_config (); | ||
chsrc_note2 (xy_strcat (3, "请在 maven 配置文件 ", maven_config, " 中添加:")); | ||
println (file); | ||
} | ||
|
||
if (gradle_exist) | ||
{ | ||
if (maven_exist) br(); | ||
|
@@ -105,4 +169,4 @@ void | |
pl_java_resetsrc (char *option) | ||
{ | ||
pl_java_setsrc (option); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,4 +222,4 @@ chsrc_available_mirrors[] = { | |
|
||
/* ------------------------ chsrc 内部实现 ------------------------ */ | ||
/* 不要列出 &UpstreamProvider 和 &UserDefinedProvider */ | ||
}; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 似乎你的编辑器会删除最后一行空行,可以安装一下 EditorConfig 插件。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 编辑器应该是自动加换行, 这个配置昨天才关掉的,我再看下吧. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个有点纠结,不知道它到底是否通用
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个的话,我去找一些链接(其他镜像)去替换域名到repo 试试, 试试才知道
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://repo.huaweicloud.com/ubuntu-releases/18.04/ubuntu-18.04.6-desktop-amd64.iso
可以下载
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let new = HuaweiCDN
let old = 现有的那个默认华为镜像站
如果 $new 如此通用,而且一直比 $old 快一些,我觉得可以把 $old 直接给换成 $new。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$new 通用 单 并不能保证一直比$old 快 , 从实际体验上来说,和之前的经验, 要看网络状态。我之前都是手动测速后设置的。