Skip to content

Commit

Permalink
Feat 1 新增了flutter 项目的分支和git 记录获取
Browse files Browse the repository at this point in the history
  • Loading branch information
wuao committed Oct 8, 2023
1 parent cce6bea commit 018108f
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 99 deletions.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# uploadapkplugin

Android. 上传测试服务器 并且自动发送飞书消息的gralde 插件
Android. 上传测试服务器 并且自动发送飞书消息的gralde 插件



buildGitLogParams {
//是否发送消息是携带Git记录日志,如果配置了这块参数才会携带Git记录,消息里面可以单独设置是否携带Git日志数据
//获取以当前时间为基准至N天之前的Git记录(限定时间范围),不填或小于等于0为全部记录,会结合数量进行获取
gitLogHistoryDayTime = 3
//显示Git记录的最大数量,值范围1~50,不填默认是10条,最大数量50条
gitLogMaxCount = 20
}

buildTrubitProParams {
//上传服务器的接口地址 方便更改
httpUpLoadUrl = "https://test-api.trubit.com/member-api/api/v1/uploadApp"
//上传文件的key 默认大部分都是file
upLoadKey = "file"
}

buildLarkParams {
//飞书机器人的地址
webHookHostUrl = "https://open.feishu.cn/open-apis/bot/v2/hook/"+token
contentTitle = "TruBitPro Android"
contentText = "最新开发测试包已经上传至测试服务器, 可以下载使用了"
//富文本消息(post)、消息卡片(interactive),默认post
msgtype = "interactive"
//是否@全体群人员,默认false:isAtAll = true
isAtAll = false
clickTxt = "点击进行下载"
//是否单独支持发送Git记录数据,在配置了buildGitLogParams前提下有效,默认为true
isSupportGitLog = true
//是否编译flutter 项目 一般来说在同级目录里面 和当前项目同级即可默认false
isBuildFlutter = false

}

# 功能说明
##### 支持自定义接口地址上传自己服务器
##### 支持是否编译flutter 项目并且打印log 和发送消息当前的flutter的分支和git log 信息
##### 当前Android项目并且打印log 和发送消息当前的项目的分支和git log 信息
##### 支持自定义各种机器人地址传入
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ publishing{
}
repositories {
maven {
// url = "$rootDir/repo"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
url = "$rootDir/repo"
// url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class PluginConstants {
public static final String TASK_DES="tools of upload to third platform";

public static final String UPLOAD_PARAMS_NAME = "buildLarkParams";
public static final String DING_PARAMS_NAME = "buildDingParams";
public static final String TRUBIT_PRO_PARAMS_NAME = "buildTrubitProParams";
public static final String WEIXIN_GROUP_PARAMS_NAME = "buildWeixinGroupParams";
public static final String GIT_LOG_PARAMS_NAME = "buildGitLogParams";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.android.build.gradle.AppExtension;
import com.android.build.gradle.api.ApplicationVariant;
import com.google.gson.Gson;
import com.trubitpro.uploadapkplugin.entry.FlutterGitBean;
import com.trubitpro.uploadapkplugin.pramars.GitLogParams;
import com.trubitpro.uploadapkplugin.pramars.SendLarkParams;
import com.trubitpro.uploadapkplugin.pramars.TrubitProParams;
import com.trubitpro.uploadapkplugin.task.BuildFlutterTask;
import com.trubitpro.uploadapkplugin.task.OnlyUploadTask;

Expand All @@ -16,6 +18,7 @@ public class UploadApkPlugin implements Plugin<Project> {
int process = 0;
@Override
public void apply(Project target) {
target.getExtensions().create(PluginConstants.TRUBIT_PRO_PARAMS_NAME, TrubitProParams.class);
target.getExtensions().create(PluginConstants.GIT_LOG_PARAMS_NAME, GitLogParams.class);
target.getExtensions().create(PluginConstants.UPLOAD_PARAMS_NAME, SendLarkParams.class);
target.afterEvaluate(project1 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.trubitpro.uploadapkplugin.entry;

public class FlutterGitBean {

private String flutterGitBranch;

private String flutterGitLog;

public FlutterGitBean(String flutterGitBranch, String flutterGitLog) {
this.flutterGitBranch = flutterGitBranch;
this.flutterGitLog = flutterGitLog;
}

public String getFlutterGitBranch() {
return flutterGitBranch;
}

public void setFlutterGitBranch(String flutterGitBranch) {
this.flutterGitBranch = flutterGitBranch;
}

public String getFlutterGitLog() {
return flutterGitLog;
}

public void setFlutterGitLog(String flutterGitLog) {
this.flutterGitLog = flutterGitLog;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
package com.trubitpro.uploadapkplugin.help;

import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;

public class ProcessUtils {

Expand Down Expand Up @@ -52,6 +44,34 @@ public static Integer exec(List<String> commands) throws Exception{
}
}

public static String exeCmd(List<String> commands) throws Exception{

String[] arrCommands = list2Array(commands);
ProcessBuilder processBuilder = new ProcessBuilder(arrCommands);
processBuilder.redirectErrorStream(true);
Process process = null;
StringBuilder stringBuilder = new StringBuilder();

try {
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); // 将输出重定向到空的OutputStream
process = processBuilder.start();
// 读取进程的输出流(可选)
InputStream inputStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
// 处理输出(可选)
stringBuilder.append(" * ").append(line).append("\n ");
}
reader.close();
process.waitFor(WAIT_TIME, TimeUnit.SECONDS);
return stringBuilder.toString();
} finally {
if(process != null){
process.destroy();
}
}
}
/**
* List转String
* @param commands
Expand Down
Loading

0 comments on commit 018108f

Please sign in to comment.