Skip to content

Commit e7188d2

Browse files
committed
将修改source文件夹的功能放入gradle插件内
1 parent a2ed1a2 commit e7188d2

File tree

14 files changed

+43
-30
lines changed

14 files changed

+43
-30
lines changed

build-gradle/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repositories {
1515
}
1616

1717
group = 'com.mrzhang.andcomponent'
18-
version = '0.0.1'
18+
version = '0.0.2'
1919

2020
uploadArchives {
2121
repositories {

build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public class ComBuild implements Plugin<Project> {
3131
//对于isRunAlone==true的情况需要根据实际情况修改其值,
3232
// 但如果是false,则不用修改,该module作为一个lib,运行module:assembleRelease则发布aar到中央仓库
3333
boolean isRunAlone = Boolean.parseBoolean((project.properties.get("isRunAlone")))
34+
String mainmodulename = project.rootProject.property("mainmodulename")
3435
if (isRunAlone && assembleTask.isAssemble) {
35-
String mainmodulename = project.rootProject.property("mainmodulename")
3636
//对于要编译的组件和主项目,isRunAlone修改为true,其他组件都强制修改为false
3737
//这就意味着组件不能引用主项目,这在层级结构里面也是这么规定的
3838
if (module.equals(compilemodule) || module.equals(mainmodulename)) {
@@ -46,6 +46,15 @@ public class ComBuild implements Plugin<Project> {
4646
//根据配置添加各种组件依赖,并且自动化生成组件加载代码
4747
if (isRunAlone) {
4848
project.apply plugin: 'com.android.application'
49+
if (!module.equals(mainmodulename)) {
50+
project.android.sourceSets {
51+
main {
52+
manifest.srcFile 'src/main/runalone/AndroidManifest.xml'
53+
java.srcDirs = ['src/main/java', 'src/main/runalone/java']
54+
res.srcDirs = ['src/main/res', 'src/main/runalone/res']
55+
}
56+
}
57+
}
4958
System.out.println("apply plugin is " + 'com.android.application');
5059
if (assembleTask.isAssemble && module.equals(compilemodule)) {
5160
compileComponents(assembleTask, project)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111
dependencies {
1212
classpath 'com.android.tools.build:gradle:2.3.3'
13-
classpath 'com.mrzhang.andcomponent:build-gradle:0.0.1'
13+
classpath 'com.mrzhang.andcomponent:build-gradle:0.0.2'
1414
}
1515
}
1616

readercomponent/build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ android {
2727

2828
resourcePrefix "readerbook_"
2929

30-
sourceSets {
31-
main {
32-
if (isRunAlone.toBoolean()) {
33-
manifest.srcFile 'src/main/runalone/AndroidManifest.xml'
34-
java.srcDirs = ['src/main/java', 'src/main/runalone/java']
35-
res.srcDirs = ['src/main/res', 'src/main/runalone/res']
36-
} else {
37-
manifest.srcFile 'src/main/AndroidManifest.xml'
38-
}
39-
}
40-
}
41-
4230
}
4331

4432
dependencies {
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
252d7568a21fd264f7709b598a3b10ef
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
418b50bada1286b96fba53072b2dd086e8ade4ce
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.mrzhang.andcomponent</groupId>
6+
<artifactId>build-gradle</artifactId>
7+
<version>0.0.2</version>
8+
<dependencies>
9+
<dependency>
10+
<groupId>com.android.tools.build</groupId>
11+
<artifactId>gradle</artifactId>
12+
<version>2.3.2</version>
13+
<scope>compile</scope>
14+
</dependency>
15+
<dependency>
16+
<groupId>org.javassist</groupId>
17+
<artifactId>javassist</artifactId>
18+
<version>3.20.0-GA</version>
19+
<scope>compile</scope>
20+
</dependency>
21+
</dependencies>
22+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ffa35e4a308eef706abf4656eb1f9502
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
66af111017db520230f4cd8890e514a20053cd45

0 commit comments

Comments
 (0)