Skip to content

Commit

Permalink
feat 第一次提交
Browse files Browse the repository at this point in the history
1 完成 测试环境接口调试
2 完成了Lark 自定义消息发送
  • Loading branch information
wuao committed Sep 6, 2023
0 parents commit 282f212
Show file tree
Hide file tree
Showing 71 changed files with 2,183 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# uploadapkplugin

Android. 上传测试服务器 并且自动发送飞书消息的gralde 插件
57 changes: 57 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
plugins {
id 'groovy'
id 'maven-publish'
id 'java-gradle-plugin'
}


task comps {
afterEvaluate {
println("Components: " + components*.name)
}
}
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing{

publications {
release(MavenPublication) {
groupId = 'center.uploadpgy.plugin'
artifactId = 'UploadApkPlugin'
version = '1.0.0'
from components.java


}
}
repositories {
maven {
// url = "$rootDir/repo"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {

// gradle sdk
implementation gradleApi()
// groovy sdk
implementation localGroovy()

implementation "com.android.tools.build:gradle:4.1.2"
implementation 'com.github.dcendents:android-maven-gradle-plugin:2.1'
implementation "com.google.code.gson:gson:2.8.8"
implementation "com.squareup.okhttp3:okhttp:3.12.12"
}
Binary file added app/libs/UploadApkPlugin-1.0.0.jar
Binary file not shown.
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.trubitpro.uploadapkplugin;

public class PluginConstants {

public static final String TASK_GROUP_NAME="publishToThirdPlatform";
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 WEIXIN_GROUP_PARAMS_NAME = "buildWeixinGroupParams";
public static final String GIT_LOG_PARAMS_NAME = "buildGitLogParams";

public static final String ANDROID_EXTENSION_NAME = "android";
public static final String TASK_EXTENSION_NAME = "ApkBuildUploadPlatform";
public static final String TASK_EXTENSION_NAME_ONLY_UPLOAD = "OnlyUploadApkToPlatform";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.trubitpro.uploadapkplugin;

import com.android.build.gradle.AppExtension;
import com.android.build.gradle.api.ApplicationVariant;
import com.android.build.gradle.api.BaseVariant;
import com.trubitpro.uploadapkplugin.help.CmdHelper;
import com.trubitpro.uploadapkplugin.help.ProcessUtils;
import com.trubitpro.uploadapkplugin.pramars.GitLogParams;
import com.trubitpro.uploadapkplugin.pramars.SendLarkParams;
import com.trubitpro.uploadapkplugin.pramars.UploadPgyParams;
import com.trubitpro.uploadapkplugin.task.OnlyUploadTask;

import org.gradle.api.Action;
import org.gradle.api.DomainObjectSet;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.jetbrains.annotations.NotNull;

import java.util.Iterator;
import java.util.Locale;

import kotlin.jvm.internal.Intrinsics;

public class UploadApkPlugin implements Plugin<Project> {
@Override
public void apply(Project target) {
target.getExtensions().create(PluginConstants.GIT_LOG_PARAMS_NAME, GitLogParams.class);

SendLarkParams uploadParams = (SendLarkParams)target.getExtensions().create(PluginConstants.UPLOAD_PARAMS_NAME, SendLarkParams.class, new Object[0]);

target.afterEvaluate(project1 -> {
AppExtension appExtension = ((AppExtension) project1.getExtensions().findByName(PluginConstants.ANDROID_EXTENSION_NAME));
if (appExtension == null) {
return;
}
DomainObjectSet<ApplicationVariant> appVariants = appExtension.getApplicationVariants();
for (ApplicationVariant applicationVariant : appVariants) {
if (applicationVariant.getBuildType() != null) {
dependsOnTask(applicationVariant, true, project1);
}
}
});
OnlyUploadTask uploadTask = target.getTasks()
.create(PluginConstants.TASK_EXTENSION_NAME_ONLY_UPLOAD, OnlyUploadTask.class);
uploadTask.init( null, target);
}


private void dependsOnTask(ApplicationVariant applicationVariant, boolean isInit, Project project1) {
String variantName =
applicationVariant.getName().substring(0, 1).toUpperCase() + applicationVariant.getName().substring(1);
if (variantName.isEmpty()) {
variantName ="Release" ;
}
//创建我们,上传到蒲公英的task任务
OnlyUploadTask uploadTask = project1.getTasks()
.create(PluginConstants.TASK_EXTENSION_NAME + variantName, OnlyUploadTask.class);
uploadTask.init( isInit?applicationVariant:null, project1);
//依赖关系 。上传依赖打包,打包依赖clean。
if (isInit){
applicationVariant.getAssembleProvider().get().dependsOn(project1.getTasks().findByName("clean"));
uploadTask.dependsOn(applicationVariant.getAssembleProvider().get());
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.trubitpro.uploadapkplugin.entry;

import com.google.gson.annotations.SerializedName;


public class BaseResult {

@SerializedName("code")
private Integer code;
@SerializedName("message")
private String message;


public Integer getCode() {
return code;
}

public void setCode(Integer code) {
this.code = code;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.trubitpro.uploadapkplugin.entry;

import com.google.gson.annotations.SerializedName;


public class LarkResult {

@SerializedName("code")
private Integer code;
@SerializedName("data")
private String data;
@SerializedName("msg")
private String msg;

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

public Integer getCode() {
return code;
}

public void setCode(Integer code) {
this.code = code;
}

public String getData() {
return data;
}

public void setData(String data) {
this.data = data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.trubitpro.uploadapkplugin.entry;

import com.google.gson.annotations.SerializedName;

/**
* Created by center
* 2021-09-03.
*
*/
public class PgyCOSTokenResult extends BaseResult {


@SerializedName("data")
private DataDTO data;

public DataDTO getData() {
return data;
}

public void setData(DataDTO data) {
this.data = data;
}

public static class DataDTO {
@SerializedName("params")
private ParamsDTO params;
@SerializedName("key")
private String key;
@SerializedName("endpoint")
private String endpoint;

public ParamsDTO getParams() {
return params;
}

public void setParams(ParamsDTO params) {
this.params = params;
}

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getEndpoint() {
return endpoint;
}

public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}

public static class ParamsDTO {
@SerializedName("signature")
private String signature;
@SerializedName("x-cos-security-token")
private String xcossecuritytoken;
@SerializedName("key")
private String key;

public String getSignature() {
return signature;
}

public void setSignature(String signature) {
this.signature = signature;
}

public String getXcossecuritytoken() {
return xcossecuritytoken;
}

public void setXcossecuritytoken(String xcossecuritytoken) {
this.xcossecuritytoken = xcossecuritytoken;
}

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.trubitpro.uploadapkplugin.entry.lark;

import com.google.gson.annotations.SerializedName;

import java.util.List;


public class ElementsDTO {

@SerializedName("tag")
private String tag;
@SerializedName("text")
private TextDTO text;
@SerializedName("type")
private String type;
@SerializedName("url")
private String url;
@SerializedName("actions")
private List<ElementsDTO> actions;

public String getTag() {
return tag;
}

public void setTag(String tag) {
this.tag = tag;
}

public TextDTO getText() {
return text;
}

public void setText(TextDTO text) {
this.text = text;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public List<ElementsDTO> getActions() {
return actions;
}

public void setActions(List<ElementsDTO> actions) {
this.actions = actions;
}
}
Loading

0 comments on commit 282f212

Please sign in to comment.