Skip to content

Commit

Permalink
Fix bad composite build design (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
SUPERCILEX authored Nov 14, 2019
1 parent d30baab commit 05ecea8
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 36 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ jobs:
mkdir -p $HOME/.gradle
echo "gradle.publish.key=$PUBLISH_KEY" > $HOME/.gradle/gradle.properties
echo "gradle.publish.secret=$PUBLISH_SECRET" >> $HOME/.gradle/gradle.properties
./gradlew -Dbootstrap publishToMavenLocal
./gradlew publishToMavenLocal
- run:
name: Build
command: ./gradlew clean ciBuild --stacktrace
command: |
./gradlew clean ciBuild --full-stacktrace
(cd testapp && ../gradlew help -PskipValidation)
- store_test_results:
path: play/plugin/build/test-results
- save_cache:
Expand Down
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

### Building the plugin

1. Run `./gradlew publishToMavenLocal -Dbootstrap`
1. Run `./gradlew publishToMavenLocal`
1. Make your changes
1. Test them live by running `./gradlew t[StandardTaskName]`, e.g. `./gradlew tPublishBundle`
1. Run the tests with `./gradlew test`
1. Ensure your changes work in a live environment: `(cd testapp && ../gradlew taskName)`, e.g.
`(cd testapp && ../gradlew publishBundle)`

### Adding new features

Expand Down
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,3 @@ allprojects {
}
}
}

apply(from = "testapp-setup.gradle.kts")
5 changes: 0 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@ include(

":play:plugin", ":play:android-publisher"
)

// Since the test app needs ./gradlew publishToMavenLocal to work, this enables bootstrapping it.
if (System.getProperty("bootstrap") == null) {
includeBuild("testapp")
}
25 changes: 0 additions & 25 deletions testapp-setup.gradle.kts

This file was deleted.

37 changes: 37 additions & 0 deletions testapp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import com.android.build.gradle.BaseExtension
import com.github.triplet.gradle.common.utils.orNull
import com.github.triplet.gradle.common.utils.safeCreateNewFile
import com.github.triplet.gradle.play.PlayPublisherExtension
import com.google.common.hash.Hashing
import com.google.common.io.Files
import java.io.FileInputStream
import java.util.Properties

Expand All @@ -18,6 +22,11 @@ buildscript {
}
}

buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}

allprojects {
repositories {
google()
Expand Down Expand Up @@ -85,3 +94,31 @@ dependencies {
"implementation"("androidx.multidex:multidex:2.0.1")
"implementation"("androidx.constraintlayout:constraintlayout:1.1.3")
}

abstract class BuildReadinessValidator : DefaultTask() {
@TaskAction
fun validate() {
if (project.hasProperty("skipValidation")) return

val playChecksumFile = project.layout.buildDirectory
.file("build-validator/play").get().asFile
val playPlugin = File(project.rootDir.parentFile, "play/plugin/build/libs")

val oldHashes = playChecksumFile.orNull()?.readLines().orEmpty().toSet()
val newHashes = playPlugin.listFiles().orEmpty().map {
Files.asByteSource(it).hash(Hashing.sha256()).toString()
}.toSet()

check(oldHashes == newHashes) {
playChecksumFile.safeCreateNewFile().writeText(newHashes.joinToString("\n"))

"Plugin updated. Rerun command to finish build."
}
}
}

val ready = tasks.register<BuildReadinessValidator>("validateBuildReadiness") {
dependsOn(gradle.includedBuild("gradle-play-publisher")
.task(":play:plugin:publishToMavenLocal"))
}
tasks.matching { it.name != "validateBuildReadiness" }.configureEach { dependsOn(ready) }
Binary file added testapp/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions testapp/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 5 additions & 0 deletions testapp/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins {
`gradle-enterprise`
}

includeBuild("..")

0 comments on commit 05ecea8

Please sign in to comment.