Skip to content

Commit

Permalink
Merge pull request #231 from ndtp/209-composite_build-3
Browse files Browse the repository at this point in the history
Replace Plugin-Local with Composite Build
  • Loading branch information
DanielJette authored Sep 4, 2024
2 parents 2d95dd4 + d655231 commit 6698806
Show file tree
Hide file tree
Showing 31 changed files with 121 additions and 111 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Testify Change Log

## 3.2.0

- https://github.com/ndtp/android-testify/pull/231 - Replace Plugin-Local with Composite Build

## 3.1.0

- https://github.com/ndtp/android-testify/pull/226 - Testify will now throw a `LowMemoryException` when attempts to allocate an `IntBuffer` fail. This can help users diagnose AVD configuration problems and reports on the state of the device.
Expand Down
2 changes: 1 addition & 1 deletion Ext/Accessibility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For more information about _Accessibility Checking_, please see https://develope

```groovy
plugins {
id("dev.testify") version "3.1.0" apply false
id("dev.testify") version "3.2.0" apply false
}
```

Expand Down
10 changes: 5 additions & 5 deletions Ext/Accessibility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ ext {
]
}

version = "$project.versions.testify"
version = project.findProperty("testify_version") ?: "0.0.1-SNAPSHOT"
group = pom.publishedGroupId
archivesBaseName = pom.artifact

android {
namespace "dev.testify.accessibility"
compileSdkVersion coreVersions.compileSdk

lintOptions {
abortOnError true
Expand All @@ -35,16 +34,17 @@ android {
}

defaultConfig {
minSdkVersion coreVersions.minSdk
targetSdkVersion coreVersions.targetSdk
compileSdk libs.versions.compileSdk.get().toInteger()
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
kotlinOptions {
allWarningsAsErrors = true
}
}

libraryVariants.all { variant ->
libraryVariants.configureEach { variant ->
variant.outputs.all {
outputFileName = "${archivesBaseName}-${version}.aar"
}
Expand Down
2 changes: 1 addition & 1 deletion Ext/Compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Easily create screenshot tests for `@Composable` functions.

```groovy
plugins {
id("dev.testify") version "3.1.0" apply false
id("dev.testify") version "3.2.0" apply false
}
```

Expand Down
8 changes: 4 additions & 4 deletions Ext/Compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ ext {
]
}

version = "$project.versions.testify"
version = project.findProperty("testify_version") ?: "0.0.1-SNAPSHOT"
group = pom.publishedGroupId
archivesBaseName = pom.artifact

android {
namespace "dev.testify.compose"
compileSdkVersion coreVersions.compileSdk

lintOptions {
abortOnError true
Expand All @@ -35,8 +34,9 @@ android {
}

defaultConfig {
minSdkVersion coreVersions.minSdk
targetSdkVersion coreVersions.targetSdk
compileSdk libs.versions.compileSdk.get().toInteger()
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
kotlinOptions {
Expand Down
2 changes: 1 addition & 1 deletion Ext/Fullscreen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can set a comparison tolerance using [ScreenshotRule.setExactness](../../Lib

```groovy
plugins {
id("dev.testify") version "3.1.0" apply false
id("dev.testify") version "3.2.0" apply false
}
```

Expand Down
8 changes: 4 additions & 4 deletions Ext/Fullscreen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ ext {
]
}

version = "$project.versions.testify"
version = project.findProperty("testify_version") ?: "0.0.1-SNAPSHOT"
group = pom.publishedGroupId
archivesBaseName = pom.artifact

android {
namespace "dev.testify.fullscreen"
compileSdkVersion coreVersions.compileSdk

lintOptions {
abortOnError true
Expand All @@ -35,8 +34,9 @@ android {
}

defaultConfig {
minSdkVersion coreVersions.minSdk
targetSdkVersion coreVersions.targetSdk
compileSdk libs.versions.compileSdk.get().toInteger()
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
kotlinOptions {
Expand Down
11 changes: 5 additions & 6 deletions Library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ ext {
]
}

version = "$project.versions.testify"
version = project.findProperty("testify_version") ?: "0.0.1-SNAPSHOT"
group = pom.publishedGroupId
archivesBaseName = pom.artifact

jacoco { toolVersion = "0.8.10" }

android {
compileSdkVersion coreVersions.compileSdk

kotlinOptions {
jvmTarget = '17'
}
Expand All @@ -37,8 +35,9 @@ android {
}

defaultConfig {
minSdkVersion coreVersions.minSdk
targetSdkVersion coreVersions.targetSdk
compileSdk libs.versions.compileSdk.get().toInteger()
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
kotlinOptions {
Expand All @@ -47,7 +46,7 @@ android {
}
}

libraryVariants.all { variant ->
libraryVariants.configureEach { variant ->
variant.outputs.all {
outputFileName = "${archivesBaseName}-${version}.aar"
}
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To set a dependency reference to the Testify plugin:

```groovy
plugins {
id("dev.testify") version "3.1.0" apply false
id("dev.testify") version "3.2.0" apply false
}
```

Expand Down
40 changes: 15 additions & 25 deletions Plugins/Gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'kotlin'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'jacoco'
}

def gradleProperties = new Properties()
file("../../gradle.properties").withInputStream { gradleProperties.load(it) }

ext {
pom = [
publishedGroupId : 'dev.testify',
Expand All @@ -22,11 +26,18 @@ ext {
]
}

version = "$project.versions.testify"
version = gradleProperties.getProperty('testify_version')
group = pom.publishedGroupId
archivesBaseName = pom.artifact

sourceCompatibility = JavaVersion.VERSION_17
gradlePlugin {
automatedPublishing = false
plugins {
testifyPlugin {
id = 'dev.testify'
implementationClass = 'dev.testify.TestifyPlugin'
}
}
}

test {
jacoco {
Expand Down Expand Up @@ -72,27 +83,6 @@ jar {
}
}

tasks.register('configureLocal') {
doFirst {
version = "local"
jar.manifest.attributes.put("Implementation-Version", version)
}
}

tasks.register('copyLocal', Copy) {
from "$buildDir/libs/${project.name}-local.jar"
into 'jar'
}

tasks.register('assembleLocal') {
dependsOn configureLocal
dependsOn build
dependsOn copyLocal

build.mustRunAfter configureLocal
copyLocal.mustRunAfter build
}

tasks.register('sourcesJar', Jar) {
from sourceSets.main.groovy.srcDirs
archiveClassifier = 'sources'
Expand Down
15 changes: 15 additions & 0 deletions Plugins/Gradle/gradle/libs.versions.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Plugins/Gradle/jar/Plugin-local.jar
Binary file not shown.
25 changes: 25 additions & 0 deletions Plugins/Gradle/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pluginManagement {
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.9.24'
id 'org.jetbrains.dokka' version '1.8.10'
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = 'dev.testify.gradle.plugin'
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ internal data class TestifySettings(
val testPackageId = extension.testPackageId ?: project.inferredDefaultTestVariantId
val targetPackageId = extension.applicationPackageId ?: project.inferredTargetPackageId
val version = TestifySettings::class.java.getPackage().implementationVersion
val autoImplementLibrary = extension.autoImplementLibrary
?: version?.contains("local", ignoreCase = true) == false
val isSnapshot = version?.contains("SNAPSHOT", ignoreCase = true) ?: false
val autoImplementLibrary = extension.autoImplementLibrary ?: !isSnapshot
val useSdCard = extension.useSdCard ?: false
val useTestStorage = extension.useTestStorage ?: false
val installTask = extension.installTask ?: project.inferredInstallTask
Expand Down
9 changes: 7 additions & 2 deletions Plugins/Gradle/src/main/kotlin/dev/testify/TestifyPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ package dev.testify

import dev.testify.TestifyPlugin.Companion.EVALUATED_SETTINGS
import dev.testify.internal.Adb
import dev.testify.internal.AnsiFormat
import dev.testify.internal.android
import dev.testify.internal.isVerbose
import dev.testify.internal.println
import dev.testify.tasks.internal.TaskNameProvider
import dev.testify.tasks.internal.TestifyDefaultTask
import dev.testify.tasks.main.ScreenshotClearTask
Expand Down Expand Up @@ -69,8 +72,10 @@ class TestifyPlugin : Plugin<Project> {
project.addDependencies()

if (settings.autoImplementLibrary) {
val version = javaClass.getPackage().implementationVersion
project.dependencies.add("androidTestImplementation", "dev.testify:testify:$version")
val version = javaClass.getPackage().implementationVersion.orEmpty()
val dependency = "dev.testify:testify:$version"
if (project.isVerbose) println(AnsiFormat.Purple, "Adding androidTestImplementation($dependency)")
project.dependencies.add("androidTestImplementation", dependency)
}

Adb.init(project)
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Testify plugin:

```groovy
plugins {
id("dev.testify") version "3.1.0" apply false
id("dev.testify") version "3.2.0" apply false
}
```

Expand Down
7 changes: 2 additions & 5 deletions Samples/Flix/FlixLibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
buildscript {
dependencies {
classpath files("${project.rootDir.path}/Plugins/Gradle/jar/Plugin-local.jar")
}
ext {
versions = [
'compose': [
Expand All @@ -19,10 +16,9 @@ plugins {
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id 'dev.testify'
}

apply plugin: 'dev.testify'

android {
namespace 'dev.testify.samples.flix.library'
compileSdk 34
Expand Down Expand Up @@ -70,6 +66,7 @@ kapt {
testify {
applicationPackageId "dev.testify.samples.flix.library.test"
testPackageId "dev.testify.samples.flix.library.test"
autoImplementLibrary false
}

dependencies {
Expand Down
12 changes: 6 additions & 6 deletions Samples/Flix/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
buildscript {
dependencies {
classpath files("${project.rootDir.path}/Plugins/Gradle/jar/Plugin-local.jar")
}
ext {
versions = [
'compose': [
Expand All @@ -21,10 +18,9 @@ plugins {
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id 'dev.testify'
}

apply plugin: 'dev.testify'

secrets {
defaultPropertiesFileName = 'local.defaults.properties'
}
Expand Down Expand Up @@ -127,4 +123,8 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.test:rules:1.5.0"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:${versions.compose.ui}"
}
}

testify {
autoImplementLibrary false
}
Loading

0 comments on commit 6698806

Please sign in to comment.