oliviergauthier / gradle-appcenter-plugin

This gradle plugin allow you to upload each build variant of your android application to separate AppCenter Apps.
MIT License
84 stars 44 forks source link

Plugin Tasks Not Generated #7

Closed lovelejess closed 5 years ago

lovelejess commented 5 years ago

Hello! I'm unable to see the plugin tasks listed in the README. I am able to see other tasks from other plugins like Crashlytics.

I believe that I'm looking for the following tasks:

appCenterUploadAlphaRelease
appCenterUploadBetaRelease
appCenterUploadProdRelease

but I don't find them in the list of tasks when I run the command ./gradlew tasks --all

Here's my build.gradle

buildscript {
    ext.kotlin_version = '1.3.31'
    repositories {
        google()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "gradle.plugin.com.betomorrow.gradle:appcenter-plugin:1.1.4"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Here's my app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.betomorrow.appcenter'

Properties properties = new Properties()
try {
    properties.load(project.rootProject.file("local.properties").newDataInputStream())
} catch(Exception e) {
    // do nothing. if file doesn't exist, then environment variables will be used below.
}

def appVersionCode = Integer.valueOf(properties.getProperty("version.code",System.getenv("SAMPLE_APP_VERSION_CODE")))
def appVersionName = properties.getProperty("version.name",System.getenv("SAMPLE_APP_VERSION_NAME"))
def distributionGroup = properties.getProperty("distributionGroup",System.getenv("DISTRIBUTION_GROUP"))

android {
    signingConfigs {
        sampledistro {
           ...
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "..."
        minSdkVersion 19
        targetSdkVersion 28
        versionCode appVersionCode
        versionName appVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // release notes
            ext.betaDistributionReleaseNotesFilePath="release_notes.txt"
            // add group aliases
            ext.betaDistributionGroupAliases=distributionGroup
            signingConfig signingConfigs.sampledistro
        }
    }
    dataBinding {
        enabled = true
    }
}

buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath "gradle.plugin.com.betomorrow.gradle:appcenter-plugin:1.1.4"
        classpath 'io.fabric.tools:gradle:1.26.1'
    }
}

    flavorDimensions "beta"
    productFlavors {
        beta {
            dimension "beta"
            applicationIdSuffix ".beta"
            versionNameSuffix "-beta"
        }
    }

appcenter {
    apiToken = ""                       // Api Token from AppCenter user profile
    ownerName = ""                          // Owner Name of the AppCenter Application
    distributionGroups = [""]               // Name of the AppCenter Distribution Group
    releaseNotes = file("../../release-notes.md")      // Can be a file or text
    notifyTesters = true                        // Send mail to testers
    apps {                                      // Here we manage 3 AppCenter applications : alpha, beta and prod
        beta {
            dimension = "beta"
            appName = "Sample App Android Beta"
        }
    }
}

Here's the output of the command ./gradlew tasks --all


Tasks runnable from root project

Android tasks

app:androidDependencies - Displays the Android dependencies of the project. app:signingReport - Displays the signing info for the base and test modules app:sourceSets - Prints out all the source sets defined in this project.

Build tasks

app:assemble - Assemble main outputs for all the variants. app:assembleAndroidTest - Assembles all the Test applications. app:build - Assembles and tests this project. app:buildDependents - Assembles and tests this project and all projects that depend on it. app:buildNeeded - Assembles and tests this project and all projects it depends on. app:bundle - Assemble bundles for all the variants. app:clean - Deletes the build directory. app:cleanBuildCache - Deletes the build cache directory. app:compileDebugAndroidTestSources app:compileDebugSources app:compileDebugUnitTestSources app:compileReleaseSources app:compileReleaseUnitTestSources

Build Setup tasks

init - Initializes a new Gradle build. wrapper - Generates Gradle wrapper files.

Cleanup tasks

app:lintFix - Runs lint on all variants and applies any safe suggestions to the source code.

Help tasks

buildEnvironment - Displays all buildscript dependencies declared in root project 'sample'. androidkitelibrary-debug:buildEnvironment - Displays all buildscript dependencies declared in project ':androidkitelibrary-debug'. app:buildEnvironment - Displays all buildscript dependencies declared in project ':app'. components - Displays the components produced by root project 'sample'. [incubating] androidkitelibrary-debug:components - Displays the components produced by project ':androidkitelibrary-debug'. [incubating] app:components - Displays the components produced by project ':app'. [incubating] dependencies - Displays all dependencies declared in root project 'sample'. androidkitelibrary-debug:dependencies - Displays all dependencies declared in project ':androidkitelibrary-debug'. app:dependencies - Displays all dependencies declared in project ':app'. dependencyInsight - Displays the insight into a specific dependency in root project 'sample'. androidkitelibrary-debug:dependencyInsight - Displays the insight into a specific dependency in project ':androidkitelibrary-debug'. app:dependencyInsight - Displays the insight into a specific dependency in project ':app'. dependentComponents - Displays the dependent components of components in root project 'sample'. [incubating] androidkitelibrary-debug:dependentComponents - Displays the dependent components of components in project ':androidkitelibrary-debug'. [incubating] app:dependentComponents - Displays the dependent components of components in project ':app'. [incubating] help - Displays a help message. androidkitelibrary-debug:help - Displays a help message. app:help - Displays a help message. model - Displays the configuration model of root project 'sample'. [incubating] androidkitelibrary-debug:model - Displays the configuration model of project ':androidkitelibrary-debug'. [incubating] app:model - Displays the configuration model of project ':app'. [incubating] projects - Displays the sub-projects of root project 'sample'. androidkitelibrary-debug:projects - Displays the sub-projects of project ':androidkitelibrary-debug'. app:projects - Displays the sub-projects of project ':app'. properties - Displays the properties of root project 'sample'. androidkitelibrary-debug:properties - Displays the properties of project ':androidkitelibrary-debug'. app:properties - Displays the properties of project ':app'. tasks - Displays the tasks runnable from root project 'sample' (some of the displayed tasks may belong to subprojects). androidkitelibrary-debug:tasks - Displays the tasks runnable from project ':androidkitelibrary-debug'. app:tasks - Displays the tasks runnable from project ':app'.

Install tasks

app:installDebug - Installs the Debug build. app:installDebugAndroidTest - Installs the android (on device) tests for the Debug build. app:installRelease - Installs the Release build. app:uninstallAll - Uninstall all applications. app:uninstallDebug - Uninstalls the Debug build. app:uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build. app:uninstallRelease - Uninstalls the Release build.

Verification tasks
------------------
app:check - Runs all checks.
app:connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
app:connectedCheck - Runs all device checks on currently connected devices.
app:connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
app:deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
app:deviceCheck - Runs all device checks using Device Providers and Test Servers.
app:lint - Runs lint on all variants.
app:lintDebug - Runs lint on the Debug build.
app:lintRelease - Runs lint on the Release build.
app:lintVitalRelease - Runs lint on just the fatal issues in the release build.
app:test - Run unit tests for all variants.
app:testDebugUnitTest - Run unit tests for the debug build.
app:testReleaseUnitTest - Run unit tests for the release build.

Other tasks
-----------
app:assembleDebug - Assembles main output for variant debug
app:assembleDebugAndroidTest - Assembles main output for variant debugAndroidTest
app:assembleDebugUnitTest - Assembles main output for variant debugUnitTest
app:assembleRelease - Assembles main output for variant release
app:assembleReleaseUnitTest - Assembles main output for variant releaseUnitTest
app:buildDebugPreBundle
app:buildReleasePreBundle
app:bundleDebug - Assembles bundle for variant debug
app:bundleDebugAndroidTestClasses
app:bundleDebugAndroidTestResources
app:bundleDebugClasses
app:bundleDebugResources
app:bundleDebugUnitTestClasses
app:bundleRelease - Assembles bundle for variant release
app:bundleReleaseClasses
app:bundleReleaseResources
app:bundleReleaseUnitTestClasses
app:checkDebugAndroidTestDuplicateClasses
app:checkDebugDuplicateClasses
app:checkDebugManifest
app:checkReleaseManifest
clean
app:collectDebugDependencies
app:collectReleaseDependencies
app:compileDebugAidl
app:compileDebugAndroidTestAidl
app:compileDebugAndroidTestJavaWithJavac
app:compileDebugAndroidTestKotlin - Compiles the debugAndroidTest kotlin.
app:compileDebugAndroidTestRenderscript
app:compileDebugAndroidTestShaders
app:compileDebugJavaWithJavac
app:compileDebugKotlin - Compiles the debug kotlin.
app:compileDebugRenderscript
app:compileDebugShaders
app:compileDebugUnitTestJavaWithJavac
app:compileDebugUnitTestKotlin - Compiles the debugUnitTest kotlin.
app:compileLint
app:compileReleaseAidl
app:compileReleaseJavaWithJavac
app:compileReleaseKotlin - Compiles the release kotlin.
app:compileReleaseRenderscript
app:compileReleaseShaders
app:compileReleaseUnitTestJavaWithJavac
app:compileReleaseUnitTestKotlin - Compiles the releaseUnitTest kotlin.
app:configureDebugDependencies
app:configureReleaseDependencies
app:consumeConfigAttr
app:crashlyticsStoreDeobsRelease -         Crashlytics target to be invoked after completing release builds.
        Cleans up Crashlytics-generated resource files. Caches and uploads deobfuscation
        files to Crashlytics servers.
app:crashlyticsUploadDeobsRelease - Uploads stored deobfuscation files to Crashlytics.
app:crashlyticsUploadDistributionDebug - Uploads an APK to Crashlytics for distribution.
app:crashlyticsUploadDistributionRelease - Uploads an APK to Crashlytics for distribution.
app:createDebugCompatibleScreenManifests
app:createMockableJar
app:createReleaseCompatibleScreenManifests
app:dataBindingExportBuildInfoDebug
app:dataBindingExportBuildInfoRelease
app:dataBindingExportFeaturePackageIdsDebug
app:dataBindingExportFeaturePackageIdsRelease
app:dataBindingGenBaseClassesDebug
app:dataBindingGenBaseClassesRelease
app:dataBindingMergeDependencyArtifactsDebug
app:dataBindingMergeDependencyArtifactsRelease
app:dataBindingMergeGenClassesDebug
app:dataBindingMergeGenClassesRelease
app:extractApksForDebug
app:extractApksForRelease
app:extractProguardFiles
app:fabricGenerateResourcesDebug - Injects the build id used by the Fabric SDK.
app:fabricGenerateResourcesRelease - Injects the build id used by the Fabric SDK.
app:generateDebugAndroidTestAssets
app:generateDebugAndroidTestBuildConfig
app:generateDebugAndroidTestResources
app:generateDebugAndroidTestResValues
app:generateDebugAndroidTestSources
app:generateDebugAssets
app:generateDebugBuildConfig
app:generateDebugFeatureMetadata
app:generateDebugFeatureTransitiveDeps
app:generateDebugResources
app:generateDebugResValues
app:generateDebugSources
app:generateDebugUnitTestAssets
app:generateDebugUnitTestResources
app:generateDebugUnitTestSources
app:generateReleaseAssets
app:generateReleaseBuildConfig
app:generateReleaseFeatureMetadata
app:generateReleaseFeatureTransitiveDeps
app:generateReleaseResources
app:generateReleaseResValues
app:generateReleaseSources
app:generateReleaseUnitTestAssets
app:generateReleaseUnitTestResources
app:generateReleaseUnitTestSources
app:javaPreCompileDebug
app:javaPreCompileDebugAndroidTest
app:javaPreCompileDebugUnitTest
app:javaPreCompileRelease
app:javaPreCompileReleaseUnitTest
app:kaptDebugAndroidTestKotlin
app:kaptDebugKotlin
app:kaptDebugUnitTestKotlin
app:kaptGenerateStubsDebugAndroidTestKotlin
app:kaptGenerateStubsDebugKotlin
app:kaptGenerateStubsDebugUnitTestKotlin
app:kaptGenerateStubsReleaseKotlin
app:kaptGenerateStubsReleaseUnitTestKotlin
app:kaptReleaseKotlin
app:kaptReleaseUnitTestKotlin
app:mainApkListPersistenceDebug
app:mainApkListPersistenceDebugAndroidTest
app:mainApkListPersistenceRelease
app:makeApkFromBundleForDebug
app:makeApkFromBundleForRelease
app:mergeDebugAndroidTestAssets
app:mergeDebugAndroidTestJniLibFolders
app:mergeDebugAndroidTestResources
app:mergeDebugAndroidTestShaders
app:mergeDebugAssets
app:mergeDebugJniLibFolders
app:mergeDebugResources
app:mergeDebugShaders
app:mergeDexDebug
app:mergeDexDebugAndroidTest
app:mergeExtDexDebug
app:mergeExtDexDebugAndroidTest
app:mergeReleaseAssets
app:mergeReleaseJniLibFolders
app:mergeReleaseResources
app:mergeReleaseShaders
app:packageDebug
app:packageDebugAndroidTest
app:packageDebugBundle
app:packageDebugUniversalApk
app:packageRelease
app:packageReleaseBundle
app:packageReleaseUniversalApk
app:preBuild
app:preDebugAndroidTestBuild
app:preDebugBuild
app:preDebugUnitTestBuild
app:prepareLintJar
app:prepareLintJarForPublish
app:preReleaseBuild
app:preReleaseUnitTestBuild
app:processDebugAndroidTestJavaRes
app:processDebugAndroidTestManifest
app:processDebugAndroidTestResources
app:processDebugJavaRes
app:processDebugManifest
app:processDebugResources
app:processDebugUnitTestJavaRes
app:processReleaseJavaRes
app:processReleaseManifest
app:processReleaseResources
app:processReleaseUnitTestJavaRes
app:reportBuildArtifactsDebug
app:reportBuildArtifactsRelease
app:reportSourceSetTransformAndroidTest
app:reportSourceSetTransformAndroidTestDebug
app:reportSourceSetTransformDebug
app:reportSourceSetTransformMain
app:reportSourceSetTransformRelease
app:reportSourceSetTransformTest
app:reportSourceSetTransformTestDebug
app:reportSourceSetTransformTestRelease
app:resolveConfigAttr
app:signDebugBundle
app:signingConfigWriterDebug
app:signingConfigWriterDebugAndroidTest
app:signingConfigWriterRelease
app:signReleaseBundle
app:transformClassesAndResourcesWithR8ForRelease
app:transformClassesWithDexBuilderForDebug
app:transformClassesWithDexBuilderForDebugAndroidTest
app:transformNativeLibsWithMergeJniLibsForDebug
app:transformNativeLibsWithMergeJniLibsForDebugAndroidTest
app:transformNativeLibsWithMergeJniLibsForRelease
app:transformResourcesWithMergeJavaResForDebug
app:transformResourcesWithMergeJavaResForDebugAndroidTest
app:transformResourcesWithMergeJavaResForDebugUnitTest
app:transformResourcesWithMergeJavaResForRelease
app:transformResourcesWithMergeJavaResForReleaseUnitTest
app:validateSigningDebug
app:validateSigningDebugAndroidTest
app:validateSigningRelease
app:writeDebugApplicationId
app:writeDebugModuleMetadata
app:writeReleaseApplicationId
app:writeReleaseModuleMetadata

What am I missing? I'm totally new to gradle so please bear with me. Thank you for making this awesome plugin. Excited to use it.

lovelejess commented 5 years ago

Never mind I think I figured it out! haha thanks :)

maverickabhi1991 commented 5 years ago

@lovelejess : Can you please share your solution? I am facing same issue and also new to gradle. I need to call something like this: appCenterUploadBetaRelease.dependsOn runMsBuild Thanks!!!

lovelejess commented 5 years ago

I realized that the app center task I was looking for was wrong. It generates a custom task based on what name you provide in the flavorDimensions in the app/build.gradle (I think).

Since my flavorDimension is Beta, it generated a task called: appCenterUploadBetaRelease

Here's my build.gradle for the app:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.betomorrow.appcenter'

Properties properties = new Properties()
try {
    properties.load(project.rootProject.file("local.properties").newDataInputStream())
} catch(Exception e) {
    // do nothing. if file doesn't exist, then environment variables will be used below.
}

def appVersionCode = Integer.valueOf(properties.getProperty("version.code",System.getenv("CI_PIPELINE_ID")))
def appVersionName = properties.getProperty("version.name",System.getenv("SAMPLE_APP_VERSION_NAME"))
def distributionGroup = properties.getProperty("distributionGroup",System.getenv("DISTRIBUTION_GROUP"))
def appCenterAPIToken = properties.getProperty("appCenterAPIToken",System.getenv("APP_CENTER_API_TOKEN"))

android {
    signingConfigs {
        sampledistro {
              ...
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId ""
        minSdkVersion 19
        targetSdkVersion 28
        versionCode appVersionCode
        versionName appVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // release notes
            ext.betaDistributionReleaseNotesFilePath="release_notes.txt"
            // add group aliases
            ext.betaDistributionGroupAliases=distributionGroup
            signingConfig signingConfigs.sampledistro
        }
    }
    flavorDimensions "beta"
    productFlavors {
        beta {
            dimension "beta"
            applicationIdSuffix ".beta"
            versionNameSuffix "-beta"
        }
    }

    dataBinding {
        enabled = true
    }
}

buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath "gradle.plugin.com.betomorrow.gradle:appcenter-plugin:1.1.4"
        classpath 'io.fabric.tools:gradle:1.26.1'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    api('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true;
    }
    implementation project(':androidkitelibrary-debug')
}

// Generates Plugin Task: appCenterUploadBetaRelease
// Run: ./gradlew appCenterUploadBetaRelease
appcenter {
    apiToken = appCenterAPIToken
    ownerName = "owner"
    distributionGroups = [distributionGroup]
    releaseNotes = file("../release-notes.md")
    notifyTesters = true
    apps {
        beta {
            dimension = "beta"
            appName = "App-Android-Beta"
        }
    }
}

Hope that helps!! Let me know if there's anything I can try to clarify for you. I'm also learning, so apologies if it doesn't totally make sense.