GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [feature] upgrade gradle version && chang dsl to extension. · JackyAndroid/PeaPod@15c0fda

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • plugin
    • PeaPod
      • .gitignore
      • build.gradle
      • proguard-rules.pro
      • src/main
        • groovy/pea/pod
          • Log.java
          • Pea.groovy
          • PeaPodPlugin.groovy
          • extension
            • PeaPodExt.groovy
        • resources/META-INF/gradle-plugins
          • pea-pod-plugin.properties
    • build.gradle
    • gradle/wrapper
      • gradle-wrapper.jar
      • gradle-wrapper.properties
    • greenbean-pods-plugin
      • build.gradle
      • src/main
        • groovy/greenbean/pods
          • SpecInternal.groovy
        • resources/META-INF/gradle-plugins
          • greenbean-pods-plugin.properties
    • settings.gradle
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎plugin/greenbean-pods-plugin/.gitignore‎ ‎plugin/PeaPod/.gitignore‎plugin/greenbean-pods-plugin/.gitignore renamed to plugin/PeaPod/.gitignore

Copy file name to clipboard
File renamed without changes.
Collapse file

‎plugin/PeaPod/build.gradle‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apply plugin: 'groovy'
2+
3+
dependencies {
4+
compile gradleApi()
5+
compile localGroovy()
6+
compile fileTree(dir: 'libs', include: ['*.jar'])
7+
}
8+
9+
buildscript {
10+
repositories {
11+
jcenter()
12+
}
13+
dependencies {
14+
15+
}
16+
}
Collapse file

‎…greenbean-pods-plugin/proguard-rules.pro‎ ‎plugin/PeaPod/proguard-rules.pro‎plugin/greenbean-pods-plugin/proguard-rules.pro renamed to plugin/PeaPod/proguard-rules.pro plugin/greenbean-pods-plugin/proguard-rules.pro renamed to plugin/PeaPod/proguard-rules.pro

Copy file name to clipboard
File renamed without changes.
Collapse file

‎plugin/PeaPod/src/main/groovy/pea/pod/Log.java‎

Copy file name to clipboard
+118Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package pea.pod;
2+
3+
import java.io.PrintWriter;
4+
import java.io.StringWriter;
5+
6+
public class Log {
7+
8+
private static LogImp debugLog = new LogImp() {
9+
10+
@Override
11+
public void v(final String tag, final String msg, final Object... obj) {
12+
String log = obj == null ? msg : String.format(msg, obj);
13+
System.out.println(String.format("[VERBOSE][%s]%s", tag, log));
14+
}
15+
16+
@Override
17+
public void i(final String tag, final String msg, final Object... obj) {
18+
String log = obj == null ? msg : String.format(msg, obj);
19+
System.out.println(String.format("[INFO][%s]%s", tag, log));
20+
}
21+
22+
@Override
23+
public void d(final String tag, final String msg, final Object... obj) {
24+
String log = obj == null ? msg : String.format(msg, obj);
25+
System.out.println(String.format("[DEBUG][%s]%s", tag, log));
26+
}
27+
28+
@Override
29+
public void w(final String tag, final String msg, final Object... obj) {
30+
String log = obj == null ? msg : String.format(msg, obj);
31+
System.out.println(String.format("[WARN][%s]%s", tag, log));
32+
}
33+
34+
@Override
35+
public void e(final String tag, final String msg, final Object... obj) {
36+
String log = obj == null ? msg : String.format(msg, obj);
37+
System.out.println(String.format("[ERROR][%s]%s", tag, log));
38+
}
39+
40+
@Override
41+
public void printErrStackTrace(String tag, Throwable tr, String format, Object... obj) {
42+
String log = obj == null ? format : String.format(format, obj);
43+
if (log == null) {
44+
log = "";
45+
}
46+
StringWriter sw = new StringWriter();
47+
PrintWriter pw = new PrintWriter(sw);
48+
tr.printStackTrace(pw);
49+
log += " " + sw.toString();
50+
System.out.println(String.format("[ERROR][%s]%s", tag, log));
51+
}
52+
};
53+
54+
private static LogImp logImp = debugLog;
55+
56+
private Log() {
57+
}
58+
59+
public static void setLogImp(LogImp imp) {
60+
logImp = imp;
61+
}
62+
63+
public static LogImp getImpl() {
64+
return logImp;
65+
}
66+
67+
public static void v(final String tag, final String msg, final Object... obj) {
68+
if (logImp != null) {
69+
logImp.v(tag, msg, obj);
70+
}
71+
}
72+
73+
public static void e(final String tag, final String msg, final Object... obj) {
74+
if (logImp != null) {
75+
logImp.e(tag, msg, obj);
76+
}
77+
}
78+
79+
public static void w(final String tag, final String msg, final Object... obj) {
80+
if (logImp != null) {
81+
logImp.w(tag, msg, obj);
82+
}
83+
}
84+
85+
public static void i(final String tag, final String msg, final Object... obj) {
86+
if (logImp != null) {
87+
logImp.i(tag, msg, obj);
88+
}
89+
}
90+
91+
public static void d(final String tag, final String msg, final Object... obj) {
92+
if (logImp != null) {
93+
logImp.d(tag, msg, obj);
94+
}
95+
}
96+
97+
public static void printErrStackTrace(String tag, Throwable tr, final String format, final Object... obj) {
98+
if (logImp != null) {
99+
logImp.printErrStackTrace(tag, tr, format, obj);
100+
}
101+
}
102+
103+
public interface LogImp {
104+
105+
void v(final String tag, final String msg, final Object... obj);
106+
107+
void i(final String tag, final String msg, final Object... obj);
108+
109+
void w(final String tag, final String msg, final Object... obj);
110+
111+
void d(final String tag, final String msg, final Object... obj);
112+
113+
void e(final String tag, final String msg, final Object... obj);
114+
115+
void printErrStackTrace(String tag, Throwable tr, final String format, final Object... obj);
116+
117+
}
118+
}
Collapse file

‎…n/groovy/greenbean/pods/GreenBean.groovy‎ ‎…eaPod/src/main/groovy/pea/pod/Pea.groovy‎plugin/greenbean-pods-plugin/src/main/groovy/greenbean/pods/GreenBean.groovy renamed to plugin/PeaPod/src/main/groovy/pea/pod/Pea.groovy plugin/greenbean-pods-plugin/src/main/groovy/greenbean/pods/GreenBean.groovy renamed to plugin/PeaPod/src/main/groovy/pea/pod/Pea.groovy

Copy file name to clipboardExpand all lines: plugin/PeaPod/src/main/groovy/pea/pod/Pea.groovy
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package greenbean.pods
1+
package pea.pod
22

33
/**
44
* DSL 基础脚本
@@ -7,7 +7,7 @@ package greenbean.pods
77
* @description Basic Script
88
* @since 2018.11.7
99
*/
10-
abstract class GreenBean extends Script {
10+
abstract class Pea extends Script {
1111

1212
public static ArrayList<Pod> pods = new ArrayList<>()
1313

Collapse file

‎…oovy/greenbean/pods/GreenBeanPods.groovy‎ ‎…/main/groovy/pea/pod/PeaPodPlugin.groovy‎plugin/greenbean-pods-plugin/src/main/groovy/greenbean/pods/GreenBeanPods.groovy renamed to plugin/PeaPod/src/main/groovy/pea/pod/PeaPodPlugin.groovy plugin/greenbean-pods-plugin/src/main/groovy/greenbean/pods/GreenBeanPods.groovy renamed to plugin/PeaPod/src/main/groovy/pea/pod/PeaPodPlugin.groovy

Copy file name to clipboardExpand all lines: plugin/PeaPod/src/main/groovy/pea/pod/PeaPodPlugin.groovy
+38-39Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
package greenbean.pods
1+
package pea.pod
22

33
import org.gradle.api.Plugin
44
import org.gradle.api.Project
55
import org.gradle.api.initialization.Settings
66
import org.gradle.api.plugins.PluginAware
7+
import pea.pod.extension.PeaPodExt
78

89
/**
9-
* Green Bean Pods
10+
* PeaPodPlugin
1011
*
11-
* @since 2018.11.7
12-
* @author jacky
12+
* @author JackyWang since 2018.11.7
1313
*/
14-
class GreenBeanPods implements Plugin<PluginAware> {
14+
class PeaPodPlugin implements Plugin<PluginAware> {
1515

16-
private String dslPath = "greenbean.pods/PodsSpec.groovy"
16+
def TAG = "PeaPodPlugin"
17+
def dslPath = "gradle/pea_pod.gradle"
18+
PeaPodExt peaPodExtension
1719

1820
@Override
1921
void apply(PluginAware pluginAware) {
20-
def isInclude = pluginAware instanceof Settings
21-
def isReplace = pluginAware instanceof Project
22-
if (isInclude) {
23-
includePods(pluginAware)
24-
} else if (isReplace) {
25-
replacePods(pluginAware)
22+
peaPodExtension = project.getExtensions().create("PeaPod", PeaPodExt)
23+
if (pluginAware instanceof Settings) {
24+
includeStage(pluginAware)
25+
} else if (pluginAware instanceof Project) {
26+
projectStage(pluginAware)
2627
}
2728
}
2829

29-
/**
30-
* 加载依赖描述
31-
*/
3230
private void evaluateDSL(String path) {
3331
def shell = new GroovyShell(this.getClass().getClassLoader())
3432
// 加载内部DSL
@@ -47,11 +45,11 @@ class GreenBeanPods implements Plugin<PluginAware> {
4745
* @param pluginAware
4846
* @return
4947
*/
50-
void includePods(PluginAware pluginAware) {
48+
def includeStage(PluginAware pluginAware) {
5149
def settings = (Settings) pluginAware
5250
def rootDir = settings.rootDir
53-
evaluateDSL(rootDir.path + File.separator + dslPath)
54-
GreenBean.pods.each { pod ->
51+
// evaluateDSL(rootDir.path + File.separator + dslPath)
52+
peaPodExtension.peaPods.each { pod ->
5553
if (pod.on_off) {
5654
if (pod.path == null && pod.absPath == null) {
5755
return
@@ -67,44 +65,40 @@ class GreenBeanPods implements Plugin<PluginAware> {
6765
def proc = pod.cmd.execute()
6866
def outputStream = new StringBuffer()
6967
proc.waitForProcessOutput(outputStream, System.err)
70-
println "执行Hook命令:" + pod.cmd + " 结果:" + outputStream.toString()
68+
Log.i(TAG, "exec hook cmd:" + pod.cmd + " result:" + outputStream.toString())
7169
}
72-
// 切换分支
70+
// checkout branch.
7371
if (pod.branch != null && !pod.branch.isEmpty()) {
7472
String cmd = "git -C " + path + " checkout " + pod.branch
7573
def proc = cmd.execute()
7674
def outputStream = new StringBuffer()
7775
proc.waitForProcessOutput(outputStream, System.err)
78-
println "模块:" + pod.name + " 检出分支:" + pod.branch + " 结果:" + outputStream.toString()
76+
Log.i(TAG, "module:" + pod.name + " checkout:" + pod.branch + " result:" + outputStream.toString())
7977
}
8078
def projectName = ":" + pod.name
8179
settings.include(projectName)
8280
settings.project(projectName).projectDir = new File(path)
83-
println("被包含的模块 名字:" + pod.name + " 路径:" + path)
81+
Log.i(TAG, "included module name:" + pod.name + " path:" + path)
8482
}
8583
}
8684
}
8785

88-
/**
89-
* 动态替换依赖
90-
* @param pluginAware
91-
* @return
92-
*/
93-
void replacePods(PluginAware pluginAware) {
86+
def projectStage(PluginAware pluginAware) {
9487
def project = (Project) pluginAware
95-
evaluateDSL(project.rootDir.path + File.separator + dslPath)
88+
// evaluateDSL(project.rootDir.path + File.separator + dslPath)
89+
def peaPods = peaPodExtension.peaPods
9690
project.afterEvaluate {
9791
//寻找当前节点
98-
def currentItem = GreenBean.pods.find {
92+
def currentNode = peaPods.find {
9993
project.name == it.name
10094
}
101-
if (currentItem == null) return
95+
if (currentNode == null) return
10296
// 寻找子节点
103-
List<String> seeds = currentItem.seeds
97+
List<String> seeds = currentNode.seeds
10498
if (seeds == null) return
10599
seeds.each { seedName ->
106100
// 寻找子节点
107-
def seed = GreenBean.pods.find {
101+
def seed = peaPods.find {
108102
it.name == seedName
109103
}
110104
if (seed == null) return
@@ -120,18 +114,23 @@ class GreenBeanPods implements Plugin<PluginAware> {
120114
excludeModule = seed.name
121115
map.put("module", excludeModule)
122116
map.put("group", excludeGroup)
123-
project.configurations.compile.exclude(map)
117+
// project.configurations.compile.exclude(map)
118+
project.configurations.each {
119+
it.exclude(map)
120+
}
124121
} else {
125122
seed.excludes.each {
126123
Map<String, String> map = new HashMap<>()
127124
excludeModule = it
128125
map.put("module", excludeModule)
129126
map.put("group", excludeGroup)
130-
project.configurations.compile.exclude(map)
127+
project.configurations.each {
128+
it.exclude(map)
129+
}
131130
}
132131
}
133-
println("Project:" + currentItem.name + " exclude online dependence,group:" + excludeGroup + " module:" + excludeModule)
134-
// 添加本地依赖
132+
Log.i(TAG, "Project:" + currentNode.name + " exclude online dependence, group:" + excludeGroup + " module:" + excludeModule)
133+
// add local module.
135134
StringBuilder buildTypes = new StringBuilder()
136135
if (seed.buildTypes == null || seed.buildTypes.size() == 0) {
137136
buildTypes.append("api")
@@ -142,11 +141,11 @@ class GreenBeanPods implements Plugin<PluginAware> {
142141
if (project.configurations.findByName(buildType) != null) {
143142
project.dependencies.add(buildType, project.dependencies.project([path: ":" + seed.name]))
144143
} else {
145-
System.err.println "Replace dependency error , build type " + buildType + " not exists."
144+
Log.e(TAG, "Replace dependency error , build type " + buildType + " not exists.")
146145
}
147146
}
148147
}
149-
println("Project:" + currentItem.name + " add local dependence,config name:" + buildTypes.toString() + " path:" + seed.name)
148+
Log.i(TAG, "Project:" + currentNode.name + " add local dependence, build type:" + buildTypes.toString() + " path:" + seed.name)
150149
}
151150
}
152151
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.