Skip to content

Commit

Permalink
Support gradle 6.5, android-gradle-plugin 4.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
6iovan committed Apr 20, 2021
1 parent 6a4d02f commit bc1069c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'com.github.1van'
version '1.0.0'
version '1.1.0'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -20,7 +20,7 @@ repositories {
dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:3.6.3'
compile 'com.android.tools.build:gradle:4.1.3'
}

gradlePlugin {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Mon Apr 27 15:52:21 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
8 changes: 4 additions & 4 deletions src/main/groovy/io/ivan/pipe/GradlePlugin.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.ivan.pipe

import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.internal.api.ApplicationVariantImpl
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.ProjectConfigurationException

class GradlePlugin implements Plugin<Project> {

Expand All @@ -12,7 +12,7 @@ class GradlePlugin implements Plugin<Project> {
@Override
void apply(Project project) {
if (!project.plugins.hasPlugin("com.android.application")) {
throw new ProjectConfigurationException("[pipe]: plugin 'com.android.application' must be apply", null)
throw new GradleException("[pipe]: plugin 'com.android.application' must be apply")
}
applyExtension(project)
applyTask(project)
Expand All @@ -24,7 +24,7 @@ class GradlePlugin implements Plugin<Project> {

private void applyTask(Project project) {
project.afterEvaluate {
project.android.applicationVariants.all { BaseVariant variant ->
project.android.applicationVariants.all { ApplicationVariantImpl variant ->
def variantName = variant.name.capitalize()

Task task = project.tasks.create("pipeAssemble${variantName}", Task) as Task
Expand Down
48 changes: 19 additions & 29 deletions src/main/groovy/io/ivan/pipe/Task.groovy
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
package io.ivan.pipe

import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.internal.api.ApplicationVariantImpl
import com.android.builder.model.SigningConfig
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.ProjectConfigurationException
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction


class Task extends DefaultTask {

private static final String DOT_APK = ".apk"
private static final String PROTECT_TYPE = "360"

@Input
public BaseVariant variant
public ApplicationVariantImpl variant
@Input
public Project targetProject

def jiaguJava
def jiaguFile
def jiaguCommand
String jiaguJava
String jiaguFile
String jiaguCommand

def apksignerFile
def apksignerCommand
String apksignerFile
String apksignerCommand

def vasDollyFile
def vasDollyCommand
String vasDollyFile
String vasDollyCommand

def apkFilePath
def baseApkFilePath
def buildPath
def tempApkPath
def tempDirPath
String apkFilePath
String baseApkFilePath
String buildPath
String tempApkPath
String tempDirPath

void setup() {
def extension = Extension.getConfig(targetProject)
Expand Down Expand Up @@ -76,29 +74,21 @@ class Task extends DefaultTask {
private void checkParameter() {
def extension = Extension.getConfig(project)
if (StringUtils.isEmpty(extension.apkOutputFolder)) {
throw new ProjectConfigurationException("[pipe]: apkOutputFolder is not configured!", null)
throw new GradleException("[pipe]: apkOutputFolder is not configured , please check it !")
}
if (StringUtils.isEmpty(extension.channelFile)) {
throw new ProjectConfigurationException("[pipe]: channelFile is not configured!", null)
throw new GradleException("[pipe]: channelFile is not configured , please check it !")
}
if (StringUtils.isEmpty(extension.toolsPath)) {
throw new ProjectConfigurationException("[pipe]: toolsPath is not configured!", null)
throw new GradleException("[pipe]: toolsPath is not configured , please check it !")
}
if (getSigningConfig() == null) {
throw new GradleException("[pipe]: SigningConfig is null , please check it")
throw new GradleException("[pipe]: SigningConfig is null , please check it !")
}
}

SigningConfig getSigningConfig() {
//return mVariant.buildType.signingConfig == null ? mVariant.mergedFlavor.signingConfig : mVariant.buildType.signingConfig
SigningConfig config = null
try {
config = variant.variantData.variantConfiguration.signingConfig
} catch (Throwable e) {
config = variant.apkVariantData.variantConfiguration.signingConfig
// e.printStackTrace()
}
return config
return variant.buildType.signingConfig == null ? variant.mergedFlavor.signingConfig : variant.buildType.signingConfig
}

private void initPath(File apkFile) {
Expand Down

0 comments on commit bc1069c

Please sign in to comment.