fix error build
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.id="ModulePlugin" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":" />
|
||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
||||
<option name="BUILDABLE" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
* 一定要注意,配置阶段不仅执行build.gradle中的语句,还包括了Task中的配置语句。从上面执行结果中可以看到,在执行了dependencies的闭包后,直接执行的是任务test中的配置段代码(Task中除了Action外的代码段都在配置阶段执行)。
|
||||
* 另外一点,无论执行Gradle的任何命令,初始化阶段和配置阶段的代码都会被执行。
|
||||
* 同样是上面那段Gradle脚本,我们执行帮助任务gradle help,任然会打印出上面的执行结果。我们在排查构建速度问题的时候可以留意,是否部分代码可以写成任务Task,从而减少配置阶段消耗的时间
|
||||
*/
|
||||
println 'build.gradle的配置阶段'
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
@@ -27,4 +34,21 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
println 'dependencies中执行的代码'
|
||||
}
|
||||
|
||||
// 创建一个Task
|
||||
task test1() {
|
||||
println 'Task中的配置代码'
|
||||
// 定义一个闭包
|
||||
def a = {
|
||||
println 'Task中的配置代码2'
|
||||
}
|
||||
// 执行闭包
|
||||
a()
|
||||
doFirst {
|
||||
println '这段代码配置阶段不执行'
|
||||
}
|
||||
}
|
||||
|
||||
println '我是顺序执行的'
|
||||
|
||||
38
build.gradle
38
build.gradle
@@ -1,5 +1,42 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
/**
|
||||
* 初始化阶段
|
||||
*/
|
||||
gradle.addBuildListener(new BuildListener() {
|
||||
|
||||
@Override
|
||||
void buildStarted(Gradle gradle) {
|
||||
println 'gradle 开始构建'
|
||||
}
|
||||
|
||||
@Override
|
||||
void settingsEvaluated(Settings settings) {
|
||||
println 'settings评估完成(settins.gradle中代码执行完毕)'
|
||||
}
|
||||
|
||||
@Override
|
||||
void projectsLoaded(Gradle gradle) {
|
||||
println '项目结构加载完成(初始化阶段结束)'
|
||||
println '初始化结束,可访问根项目:' + var1.gradle.rootProject
|
||||
}
|
||||
|
||||
@Override
|
||||
void projectsEvaluated(Gradle gradle) {
|
||||
println '所有子project项目评估完成(配置阶段结束)'
|
||||
}
|
||||
|
||||
@Override
|
||||
void buildFinished(BuildResult buildResult) {
|
||||
//在 projectsEvaluated 运行完 之后进入执行阶段
|
||||
println 'Gradle.taskGraph.beforeTask '
|
||||
println '执行 task action '
|
||||
println 'Gradle.taskGraph.afterTask '
|
||||
println '构建结束 '
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
@@ -28,3 +65,4 @@ task clean(type: Delete) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
apply plugin: 'com.android.module'
|
||||
|
||||
android {
|
||||
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.1"
|
||||
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 29
|
||||
@@ -36,4 +36,7 @@ dependencies {
|
||||
componentBuild {
|
||||
applicationName = 'com.plugin.library.LibraryApplication'
|
||||
isRegisterComponentAuto = true
|
||||
runAlone = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.Light">
|
||||
|
||||
<activity android:name=".LibraryMainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Sat Jul 27 12:59:09 CST 2019
|
||||
#Mon Jul 29 09:42:24 CST 2019
|
||||
ndk.dir=/Users/yummy/Library/Android/sdk/ndk-bundle
|
||||
sdk.dir=/Users/yummy/Library/Android/sdk
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
implementation-class=com.plugin.module.ModulePlugin
|
||||
implementation-class=com.plugin.module.alone.AlonePlugin
|
||||
@@ -14,5 +14,5 @@ class AloneExtension {
|
||||
*/
|
||||
String applicationName
|
||||
|
||||
boolean runAlone = false
|
||||
boolean runAlone = true
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* 编写 AlonePlugin 插件
|
||||
* ./gradlew --no-daemon checkGradleDependencies -Dorg.gradle.debug=true
|
||||
*/
|
||||
class AlonePlugin implements Plugin<Project> {
|
||||
|
||||
@@ -18,6 +19,7 @@ class AlonePlugin implements Plugin<Project> {
|
||||
//解析ComExtension属性
|
||||
AloneExtension extension = project.extensions.create(Constants.EXTENSION_NAME, AloneExtension)
|
||||
|
||||
|
||||
//获取运行task名称
|
||||
String taskNames = project.gradle.startParameter.taskNames.toString()
|
||||
Utils.buildOutput("taskNames is " + taskNames)
|
||||
@@ -39,11 +41,11 @@ class AlonePlugin implements Plugin<Project> {
|
||||
throw new RuntimeException("you should set isRunAlone in " + module + "'s gradle.properties")
|
||||
}
|
||||
|
||||
boolean isRunAlone = extension.runAlone
|
||||
// boolean isRunAlone = extension.runAlone
|
||||
|
||||
|
||||
|
||||
// String mainModuleName = project.rootProject.property(Constants.PROPERTIES_MAIN_MODULE_NAME)
|
||||
boolean isRunAlone = Boolean.parseBoolean((project.properties.get("isRunAlone")))
|
||||
String mainModuleName = project.rootProject.property(Constants.PROPERTIES_MAIN_MODULE_NAME)
|
||||
|
||||
|
||||
//当且仅当 isRunAlone 为ture需要判断
|
||||
@@ -64,17 +66,16 @@ class AlonePlugin implements Plugin<Project> {
|
||||
Utils.buildOutput("project.apply plugin: com.android.application")
|
||||
|
||||
//对于组件,则需要读取alone目录进行运行
|
||||
// if (!module.equals(mainModuleName)) {
|
||||
if (!module.equals(mainModuleName)) {
|
||||
|
||||
// }
|
||||
|
||||
project.android.sourceSets {
|
||||
main {
|
||||
manifest.srcFile Constants.AFTER_MANIFEST_PATH
|
||||
java.srcDirs = [Constants.JAVA_PATH, Constants.AFTER_JAVA_PATH]
|
||||
res.srcDirs = [Constants.RES_PATH, Constants.AFTER_RES_PATH]
|
||||
assets.srcDirs = [Constants.ASSETS_PATH, Constants.AFTER_ASSETS_PATH]
|
||||
jniLibs.srcDirs = [Constants.JNILIBS_PATH, Constants.AFTER_JNILIBS_PATH]
|
||||
project.android.sourceSets {
|
||||
main {
|
||||
manifest.srcFile Constants.AFTER_MANIFEST_PATH
|
||||
java.srcDirs = [Constants.JAVA_PATH, Constants.AFTER_JAVA_PATH]
|
||||
res.srcDirs = [Constants.RES_PATH, Constants.AFTER_RES_PATH]
|
||||
assets.srcDirs = [Constants.ASSETS_PATH, Constants.AFTER_ASSETS_PATH]
|
||||
jniLibs.srcDirs = [Constants.JNILIBS_PATH, Constants.AFTER_JNILIBS_PATH]
|
||||
}
|
||||
}
|
||||
}
|
||||
if (assembleTask.isAssemble && module.equals(compileModule)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.plugin.module.mis.task
|
||||
|
||||
import com.plugin.module.mis.extension.Publication
|
||||
import com.plugin.module.mis.extension.PublicationManager
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
implementation-class=com.plugin.module.alone.AlonePlugin.java
|
||||
implementation-class=com.plugin.module.alone.AlonePlugin
|
||||
Reference in New Issue
Block a user