Skip to content

Commit 2fd7ef4

Browse files
technoir42bhurling
authored andcommitted
Publish to Gradle Plugin Portal (#429)
* Publish to Gradle Plugin Portal * Bump version for release candidate * Explain installation for kotlin and groovy * Update badge to point to Plugin Portal
1 parent 7ae8900 commit 2fd7ef4

File tree

9 files changed

+114
-103
lines changed

9 files changed

+114
-103
lines changed

.buildscript/deploy_snapshot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
2222
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
2323
else
2424
echo "Deploying snapshot..."
25-
./gradlew uploadArchives
25+
./gradlew publish
2626
echo "Snapshot deployed!"
2727
fi

README.md

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
<img src="https://img.shields.io/travis/Triple-T/gradle-play-publisher/master.svg?style=flat-square" />
1212
</a>
1313
<a href="https://search.maven.org/search?q=g:com.github.triplet.gradle%20AND%20a:play-publisher&core=gav">
14-
<img src="https://maven-badges.herokuapp.com/maven-central/com.github.triplet.gradle/play-publisher/badge.svg" />
14+
<img src="https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/github/triplet/play/com.github.triplet.play.gradle.plugin/maven-metadata.xml.svg?label=Gradle%20Plugins%20Portal" />
1515
</a>
1616
</p>
1717

1818
Gradle Play Publisher is a Gradle plugin that allows you to upload your App Bundle or APK and other
1919
app details to the Google Play Store.
2020

21-
> **Note:** this README targets the `v2.0.0` betas. Documentation for the latest stable release is
21+
> **Note:** this README targets the `v2.0.0` betas and release candidates. Documentation for the latest stable release is
2222
available [here](https://github.com/Triple-T/gradle-play-publisher/blob/1.2.2/README.md).
2323

2424
## Table of contents
@@ -88,54 +88,15 @@ for GPP to work (go to Settings -> Developer account -> Users & permissions):
8888

8989
### Installation
9090

91-
In your root `build.gradle(.kts)` file, add the Gradle Play Publisher dependency:
92-
93-
<details open><summary>Kotlin</summary>
94-
95-
```kt
96-
buildscript {
97-
repositories {
98-
// ...
99-
jcenter()
100-
}
101-
102-
dependencies {
103-
// ...
104-
classpath("com.github.triplet.gradle:play-publisher:2.0.0-beta2")
105-
}
106-
}
107-
```
108-
109-
</details>
110-
111-
<details><summary>Groovy</summary>
112-
113-
```groovy
114-
buildscript {
115-
repositories {
116-
// ...
117-
jcenter()
118-
}
119-
120-
dependencies {
121-
// ...
122-
classpath 'com.github.triplet.gradle:play-publisher:2.0.0-beta2'
123-
}
124-
}
125-
```
126-
127-
</details>
128-
</br>
129-
130-
Then apply it to each individual `com.android.application` module where you want to use GPP.
131-
For example, `app/build.gradle(.kts)` is a commonly used app module:
91+
Apply the plugin to each individual `com.android.application` module where you want to use GPP
92+
through the `plugins {}` DSL:
13293

13394
<details open><summary>Kotlin</summary>
13495

13596
```kt
13697
plugins {
13798
id("com.android.application")
138-
id("com.github.triplet.play")
99+
id("com.github.triplet.play") version "2.0.0-rc2"
139100
}
140101
```
141102

@@ -144,8 +105,10 @@ plugins {
144105
<details><summary>Groovy</summary>
145106

146107
```groovy
147-
apply plugin: 'com.android.application'
148-
apply plugin: 'com.github.triplet.play'
108+
plugins {
109+
id 'com.android.application'
110+
id 'com.github.triplet.play' version '2.0.0-rc2'
111+
}
149112
```
150113

151114
</details>

build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ buildscript {
33
google()
44
jcenter()
55
}
6-
7-
dependencies {
8-
classpath("com.vanniktech:gradle-maven-publish-plugin:0.2.0")
9-
}
106
}
117

128
plugins {

gradle.properties

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,3 @@ org.gradle.jvmargs=-Xmx6g -XX:ReservedCodeCacheSize=2g -Dfile.encoding=UTF-8
22
org.gradle.parallel=true
33
org.gradle.configureondemand=true
44
org.gradle.caching=true
5-
6-
GROUP=com.github.triplet.gradle
7-
VERSION_NAME=2.0.0-rc1
8-
9-
POM_DESCRIPTION=Gradle Plugin to upload APKs and App Bundles to the Google Play Store
10-
11-
POM_URL=https://github.com/Triple-T/gradle-play-publisher
12-
POM_SCM_URL=https://github.com/Triple-T/gradle-play-publisher
13-
POM_SCM_CONNECTION=scm:git@github.com:Triple-T/gradle-play-publisher.git
14-
POM_SCM_DEV_CONNECTION=scm:git@github.com:Triple-T/gradle-play-publisher.git
15-
16-
POM_LICENCE_NAME=The MIT License (MIT)
17-
POM_LICENCE_URL=http://opensource.org/licenses/MIT
18-
POM_LICENCE_DIST=repo
19-
20-
POM_DEVELOPER_ID=Triple-T
21-
POM_DEVELOPER_NAME=Triple-T-Dev

plugin/build.gradle.kts

Lines changed: 94 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import org.codehaus.groovy.runtime.InvokerHelper
21
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
32

43
plugins {
54
`java-gradle-plugin`
65
`kotlin-dsl`
6+
`maven-publish`
77
groovy
8-
id("com.vanniktech.maven.publish")
8+
id("com.gradle.plugin-publish") version "0.10.0"
99
}
1010

1111
dependencies {
@@ -33,29 +33,104 @@ tasks.withType<KotlinJvmCompile> {
3333
}
3434
}
3535

36+
group = "com.github.triplet.gradle"
37+
version = "2.0.0-rc2"
38+
3639
gradlePlugin {
37-
plugins {
38-
create("play") {
39-
id = "com.github.triplet.play"
40-
implementationClass = "com.github.triplet.gradle.play.PlayPublisherPlugin"
41-
}
40+
plugins.create("play") {
41+
id = "com.github.triplet.play"
42+
displayName = "Gradle Play Publisher"
43+
description = "Gradle Play Publisher allows you to upload your App Bundle or APK " +
44+
"and other app details to the Google Play Store."
45+
implementationClass = "com.github.triplet.gradle.play.PlayPublisherPlugin"
4246
}
4347
}
4448

45-
afterEvaluate {
46-
fun PomFilterContainer.removeTestDependencies() {
47-
pom.whenConfigured {
48-
dependencies.removeIf {
49-
// Stolen from JetBrains' own sample at
50-
// https://github.com/JetBrains/kotlin/blob/v1.2.50/buildSrc/src/main/kotlin/plugins/PublishedKotlinModule.kt#L86
51-
InvokerHelper.getMetaClass(it).getProperty(it, "scope") == "test"
49+
pluginBundle {
50+
website = "https://github.com/Triple-T/gradle-play-publisher"
51+
vcsUrl = "https://github.com/Triple-T/gradle-play-publisher"
52+
tags = listOf("android", "google-play")
53+
54+
mavenCoordinates {
55+
groupId = project.group as String
56+
artifactId = "play-publisher"
57+
}
58+
}
59+
60+
publishing {
61+
repositories {
62+
maven {
63+
name = "Snapshots"
64+
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
65+
66+
credentials {
67+
username = project.findProperty("SONATYPE_NEXUS_USERNAME")?.toString()
68+
password = project.findProperty("SONATYPE_NEXUS_PASSWORD")?.toString()
5269
}
5370
}
5471
}
72+
}
73+
74+
val sourcesJar by tasks.registering(Jar::class) {
75+
classifier = "sources"
76+
from(sourceSets["main"].allSource)
77+
dependsOn(tasks["classes"])
78+
}
79+
80+
afterEvaluate {
81+
publishing.publications.named<MavenPublication>("pluginMaven") {
82+
artifactId = "play-publisher"
83+
artifact(sourcesJar.get())
84+
85+
pom {
86+
name.set("Google Play Publisher")
87+
description.set("Gradle Play Publisher is a plugin that allows you to upload your " +
88+
"App Bundle or APK and other app details to the " +
89+
"Google Play Store.")
90+
url.set("https://github.com/Triple-T/gradle-play-publisher")
91+
92+
licenses {
93+
license {
94+
name.set("The MIT License (MIT)")
95+
url.set("http://opensource.org/licenses/MIT")
96+
distribution.set("repo")
97+
}
98+
}
99+
100+
developers {
101+
developer {
102+
id.set("bhurling")
103+
name.set("Björn Hurling")
104+
roles.set(listOf("Owner"))
105+
timezone.set("+2")
106+
}
107+
developer {
108+
id.set("SUPERCILEX")
109+
name.set("Alex Saveau")
110+
email.set("saveau.alexandre@gmail.com")
111+
roles.set(listOf("Developer"))
112+
timezone.set("-8")
113+
}
114+
developer {
115+
id.set("ChristianBecker")
116+
name.set("Christian Becker")
117+
email.set("christian.becker.1987@gmail.com")
118+
roles.set(listOf("Developer"))
119+
timezone.set("+2")
120+
}
121+
developer {
122+
id.set("gtcompscientist")
123+
name.set("Charles Anderson")
124+
roles.set(listOf("Developer"))
125+
timezone.set("-8")
126+
}
127+
}
55128

56-
tasks.withType<Upload> {
57-
repositories.forEach {
58-
(it as? PomFilterContainer)?.removeTestDependencies()
129+
scm {
130+
connection.set("scm:git@github.com:Triple-T/gradle-play-publisher.git")
131+
developerConnection.set("scm:git@github.com:Triple-T/gradle-play-publisher.git")
132+
url.set("https://github.com/Triple-T/gradle-play-publisher")
133+
}
59134
}
60135
}
61136
}
@@ -64,8 +139,6 @@ tasks.withType<Test> {
64139
// Our integration tests need a fully compiled jar
65140
dependsOn("assemble")
66141

67-
// Those tests also need to know which version code was built
68-
project.property("VERSION_NAME")?.let {
69-
systemProperty("VERSION_NAME", it)
70-
}
142+
// Those tests also need to know which version was built
143+
systemProperty("VERSION_NAME", version)
71144
}

plugin/gradle.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.

plugin/src/main/kotlin/com/github/triplet/gradle/play/PlayPublisherPlugin.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.triplet.gradle.play
22

33
import com.android.build.gradle.AppExtension
4+
import com.android.build.gradle.AppPlugin
45
import com.android.build.gradle.internal.api.InstallableVariantImpl
56
import com.github.triplet.gradle.play.internal.PLAY_PATH
67
import com.github.triplet.gradle.play.internal.configure
@@ -26,15 +27,19 @@ import org.gradle.api.Plugin
2627
import org.gradle.api.Project
2728
import org.gradle.api.plugins.ExtensionAware
2829
import org.gradle.kotlin.dsl.the
30+
import org.gradle.kotlin.dsl.withType
2931

3032
@Suppress("unused") // Used by Gradle
3133
class PlayPublisherPlugin : Plugin<Project> {
3234
override fun apply(project: Project) {
3335
validateRuntime()
3436

35-
val android = requireNotNull(project.the<AppExtension>()) {
36-
"The 'com.android.application' plugin is required."
37+
project.plugins.withType<AppPlugin> {
38+
applyInternal(project)
3739
}
40+
}
41+
42+
private fun applyInternal(project: Project) {
3843
val baseExtension: PlayPublisherExtension =
3944
project.extensions.create(PLAY_PATH, PlayPublisherExtension::class.java)
4045
val extensionContainer = project.container(PlayPublisherExtension::class.java)
@@ -68,6 +73,7 @@ class PlayPublisherPlugin : Plugin<Project> {
6873
"Uploads all Play Store in-app products for every variant."
6974
) { extension = baseExtension }
7075

76+
val android = project.the<AppExtension>()
7177
(android as ExtensionAware).extensions.add("playConfigs", extensionContainer)
7278
BootstrapOptionsHolder.reset()
7379
android.applicationVariants.whenObjectAdded {

plugin/src/test/groovy/com/github/triplet/gradle/play/PlayPublisherPluginTest.groovy

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package com.github.triplet.gradle.play
33
import com.github.triplet.gradle.play.internal.ReleaseStatus
44
import com.github.triplet.gradle.play.internal.TrackType
55
import org.gradle.api.ProjectConfigurationException
6-
import org.gradle.api.internal.plugins.PluginApplicationException
7-
import org.gradle.testfixtures.ProjectBuilder
86
import org.junit.Test
97

108
import static DependsOn.dependsOn
@@ -16,13 +14,6 @@ import static org.junit.Assert.assertTrue
1614

1715
class PlayPublisherPluginTest {
1816

19-
@Test(expected = PluginApplicationException.class)
20-
void testThrowsOnLibraryProjects() {
21-
def project = ProjectBuilder.builder().build()
22-
project.apply plugin: 'com.android.library'
23-
project.apply plugin: 'com.github.triplet.play'
24-
}
25-
2617
@Test
2718
void testCreatesDefaultTask() {
2819
def project = TestHelper.evaluatableProject()

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
include(":plugin")
2+
3+
enableFeaturePreview("STABLE_PUBLISHING")

0 commit comments

Comments
 (0)