buildSrc/src/main/kotlin/AndroidPlayStorePublisher.kt
author Da Risk <da_risk@geekorum.com>
Sat, 22 May 2021 12:04:57 -0400
changeset 799 c8bdc3274161
parent 635 1c1d190b326a
child 846 ac0863af5ef6
permissions -rw-r--r--
build: update gradle play publisher
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
137
5464f07a306c Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents: 54
diff changeset
     1
/*
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     2
 * Geekttrss is a RSS feed reader application on the Android Platform.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     3
 *
611
91b8d76c03cd Update copyrights headers
Da Risk <da_risk@geekorum.com>
parents: 399
diff changeset
     4
 * Copyright (C) 2017-2020 by Frederic-Charles Barthelery.
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     5
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     6
 * This file is part of Geekttrss.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     7
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     8
 * Geekttrss is free software: you can redistribute it and/or modify
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     9
 * it under the terms of the GNU General Public License as published by
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    10
 * the Free Software Foundation, either version 3 of the License, or
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    11
 * (at your option) any later version.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    12
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    13
 * Geekttrss is distributed in the hope that it will be useful,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    16
 * GNU General Public License for more details.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    17
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    18
 * You should have received a copy of the GNU General Public License
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    19
 * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    20
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    21
package com.geekorum.build
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    22
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    23
import com.android.build.gradle.AppExtension
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    24
import com.github.triplet.gradle.play.PlayPublisherExtension
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    25
import org.gradle.api.NamedDomainObjectContainer
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    26
import org.gradle.api.Project
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    27
import org.gradle.api.plugins.ExtensionAware
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    28
import org.gradle.kotlin.dsl.apply
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    29
import org.gradle.kotlin.dsl.configure
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    30
import org.gradle.kotlin.dsl.the
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    31
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    32
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    33
// Configuration for "com.github.triplet.play" plugin
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    34
// This configuration expects the given properties
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    35
// PLAY_STORE_JSON_KEY_FILE: google play console service credentials json file to use
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    36
// PLAY_STORE_TRACK: track to publish the build, default to internal but can be set to alpha, beta or production
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    37
// PLAY_STORE_FROM_TRACK: track from which to promote a build, default to internal but can be set to alpha, beta or production
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    38
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    39
internal fun Project.configureAndroidPlayStorePublisher(): Unit {
635
1c1d190b326a build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents: 611
diff changeset
    40
    apply(plugin = "com.github.triplet.play")
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    41
    configure<PlayPublisherExtension> {
799
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    42
        defaultToAppBundles.set(true)
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    43
        track.set(properties.getOrDefault("PLAY_STORE_TRACK", "internal") as String)
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    44
        fromTrack.set(properties.getOrDefault("PLAY_STORE_FROM_TRACK", "internal") as String)
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    45
        serviceAccountCredentials.set(file(properties["PLAY_STORE_JSON_KEY_FILE"]!!))
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    46
    }
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    47
54
53068a23963e build: update Gradle Play Publisher to 2.1.0
Da Risk <da_risk@geekorum.com>
parents: 40
diff changeset
    48
    val android = the<AppExtension>() as ExtensionAware
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    49
398
164702325c93 build: Update to Gradle Play Publisher 2.3.0
Da Risk <da_risk@geekorum.com>
parents: 142
diff changeset
    50
    android.extensions.configure<NamedDomainObjectContainer<PlayPublisherExtension>> {
164702325c93 build: Update to Gradle Play Publisher 2.3.0
Da Risk <da_risk@geekorum.com>
parents: 142
diff changeset
    51
        register("free") {
799
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    52
            enabled.set(false)
398
164702325c93 build: Update to Gradle Play Publisher 2.3.0
Da Risk <da_risk@geekorum.com>
parents: 142
diff changeset
    53
        }
399
d7616118282e build: publish a prebuild artifact
Da Risk <da_risk@geekorum.com>
parents: 398
diff changeset
    54
        register("google") {
d7616118282e build: publish a prebuild artifact
Da Risk <da_risk@geekorum.com>
parents: 398
diff changeset
    55
            // we always build the release as a separate step when publishing
d7616118282e build: publish a prebuild artifact
Da Risk <da_risk@geekorum.com>
parents: 398
diff changeset
    56
            // use artifactDir to be sure that publish don't rebuild it
799
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    57
            artifactDir.set(file("$buildDir/outputs/bundle/googleRelease"))
399
d7616118282e build: publish a prebuild artifact
Da Risk <da_risk@geekorum.com>
parents: 398
diff changeset
    58
        }
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    59
    }
40
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    60
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    61
    tasks.apply {
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    62
        register("publishToGooglePlayStore") {
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    63
            group = "Continuous Delivery"
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    64
            description = "Publish project to Google play store"
799
c8bdc3274161 build: update gradle play publisher
Da Risk <da_risk@geekorum.com>
parents: 635
diff changeset
    65
            dependsOn(named("publishApps"))
40
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    66
        }
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    67
54
53068a23963e build: update Gradle Play Publisher to 2.1.0
Da Risk <da_risk@geekorum.com>
parents: 40
diff changeset
    68
        // only there for consistent naming scheme
40
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    69
        register("promoteOnGooglePlayStore") {
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    70
            group = "Continuous Delivery"
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    71
            description = "Promote project Google play store"
54
53068a23963e build: update Gradle Play Publisher to 2.1.0
Da Risk <da_risk@geekorum.com>
parents: 40
diff changeset
    72
            dependsOn(named("promoteArtifact"))
40
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    73
        }
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    74
    }
c5ae393af55c Update gradle version to 5.1-milestone-1
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    75
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    76
}