-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull out SDK into its own module #1462
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
public final class app/cash/paparazzi/InstantAnimationsRule : org/junit/rules/TestRule { | ||
public static final field $stable I | ||
public fun <init> ()V | ||
public fun apply (Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement; | ||
} | ||
|
||
public final class app/cash/paparazzi/Paparazzi : org/junit/rules/TestRule { | ||
public static final field $stable I | ||
public fun <init> ()V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;Z)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZD)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;Ljava/util/Set;)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;Ljava/util/Set;Z)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;Ljava/util/Set;ZZ)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;Ljava/util/Set;ZZZ)V | ||
public fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;Ljava/util/Set;ZZZZ)V | ||
public synthetic fun <init> (Lapp/cash/paparazzi/Environment;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ZDLapp/cash/paparazzi/SnapshotHandler;Ljava/util/Set;ZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
public fun apply (Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement; | ||
public final fun close ()V | ||
public final fun getContext ()Landroid/content/Context; | ||
public final fun getLayoutInflater ()Landroid/view/LayoutInflater; | ||
public final fun getResources ()Landroid/content/res/Resources; | ||
public final fun gif (Landroid/view/View;)V | ||
public final fun gif (Landroid/view/View;Ljava/lang/String;)V | ||
public final fun gif (Landroid/view/View;Ljava/lang/String;J)V | ||
public final fun gif (Landroid/view/View;Ljava/lang/String;JJ)V | ||
public final fun gif (Landroid/view/View;Ljava/lang/String;JJI)V | ||
public static synthetic fun gif$default (Lapp/cash/paparazzi/Paparazzi;Landroid/view/View;Ljava/lang/String;JJIILjava/lang/Object;)V | ||
public final fun inflate (I)Landroid/view/View; | ||
public final fun prepare (Lorg/junit/runner/Description;)V | ||
public final fun snapshot (Landroid/view/View;)V | ||
public final fun snapshot (Landroid/view/View;Ljava/lang/String;)V | ||
public final fun snapshot (Landroid/view/View;Ljava/lang/String;J)V | ||
public final fun snapshot (Ljava/lang/String;Lkotlin/jvm/functions/Function2;)V | ||
public static synthetic fun snapshot$default (Lapp/cash/paparazzi/Paparazzi;Landroid/view/View;Ljava/lang/String;JILjava/lang/Object;)V | ||
public static synthetic fun snapshot$default (Lapp/cash/paparazzi/Paparazzi;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V | ||
public final fun unsafeUpdateConfig (Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;)V | ||
public static synthetic fun unsafeUpdateConfig$default (Lapp/cash/paparazzi/Paparazzi;Lapp/cash/paparazzi/DeviceConfig;Ljava/lang/String;Lcom/android/ide/common/rendering/api/SessionParams$RenderingMode;ILjava/lang/Object;)V | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import com.android.build.gradle.internal.publishing.AndroidArtifacts | ||
|
||
apply plugin: 'org.jetbrains.kotlin.jvm' | ||
apply plugin: 'org.jetbrains.kotlin.plugin.compose' | ||
apply plugin: 'org.jetbrains.dokka' | ||
apply plugin: 'com.vanniktech.maven.publish' | ||
apply plugin: 'aar2jar' | ||
|
||
configurations { | ||
layoutlibRuntime { | ||
canBeConsumed = false | ||
attributes.attribute(AndroidArtifacts.ARTIFACT_TYPE, ArtifactTypeDefinition.DIRECTORY_TYPE) | ||
} | ||
layoutlibResources { | ||
canBeConsumed = false | ||
attributes.attribute(AndroidArtifacts.ARTIFACT_TYPE, ArtifactTypeDefinition.DIRECTORY_TYPE) | ||
} | ||
} | ||
|
||
aar2jar.configureForConfiguration("compileOnly") | ||
aar2jar.configureForConfiguration("testImplementation") | ||
|
||
dependencies { | ||
registerTransform(org.gradle.api.internal.artifacts.transform.UnzipTransform) { | ||
from.attribute(AndroidArtifacts.ARTIFACT_TYPE, ArtifactTypeDefinition.JAR_TYPE) | ||
to.attribute(AndroidArtifacts.ARTIFACT_TYPE, ArtifactTypeDefinition.DIRECTORY_TYPE) | ||
} | ||
} | ||
|
||
dependencies { | ||
testImplementationAarAsJar libs.androidx.compose.ui.android | ||
compileOnlyAarAsJar libs.androidx.compose.ui.android | ||
compileOnlyAarAsJar libs.androidx.compose.runtime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calling out this switcheroo; replacing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, much better dependency |
||
api projects.paparazziSdk | ||
api libs.junit | ||
api platform(libs.kotlin.bom) | ||
|
||
def osName = System.getProperty("os.name").toLowerCase(Locale.US) | ||
def osLabel | ||
if (osName.startsWith("mac")) { | ||
def osArch = System.getProperty("os.arch").toLowerCase(Locale.US) | ||
if (osArch.startsWith("x86")) { | ||
osLabel = 'mac' | ||
} else { | ||
osLabel = 'mac-arm' | ||
} | ||
} else if (osName.startsWith("windows")) { | ||
osLabel = 'win' | ||
} else { | ||
osLabel = 'linux' | ||
} | ||
layoutlibRuntime variantOf(libs.tools.layoutlib.runtime) { classifier(osLabel) } | ||
layoutlibResources libs.tools.layoutlib.resources | ||
|
||
testImplementation libs.truth | ||
} | ||
|
||
tasks.named("dokkaGfm").configure { | ||
outputDirectory = rootProject.file("docs/1.x") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amazing that you did all this while keeping 1.x 👏🏻 |
||
|
||
dokkaSourceSets.named("main") { | ||
configureEach { | ||
reportUndocumented = false | ||
skipDeprecated = true | ||
jdkVersion = 8 | ||
perPackageOption { | ||
prefix = "app.cash.paparazzi.internal" | ||
suppress = true | ||
} | ||
} | ||
} | ||
} | ||
|
||
def generateTestConfig = tasks.register("generateTestConfig") { | ||
def resources = layout.buildDirectory.file('intermediates/paparazzi/resources.json') | ||
outputs.file(resources) | ||
|
||
doLast { | ||
File configFile = resources.get().asFile | ||
configFile.write("""{ | ||
"mainPackage": "app.cash.paparazzi", | ||
"mergeResourcesOutputDir": ".", | ||
"targetSdkVersion": "34", | ||
"mergeAssetsOutputDir": ".", | ||
"resourcePackageNames": ["app.cash.paparazzi"], | ||
"projectResourceDirs": [], | ||
"moduleResourceDirs": [], | ||
"aarExplodedDirs": [], | ||
"projectAssetDirs": [], | ||
"aarAssetDirs": [] | ||
}""") | ||
} | ||
} | ||
|
||
tasks.withType(Test).configureEach { | ||
dependsOn(generateTestConfig) | ||
systemProperty( | ||
"paparazzi.test.resources", | ||
generateTestConfig.map { it.outputs.files.singleFile }.get().path | ||
) | ||
systemProperty( | ||
"paparazzi.project.dir", | ||
project.layout.projectDirectory.toString() | ||
) | ||
systemProperty( | ||
"paparazzi.build.dir", | ||
project.layout.buildDirectory.get().toString() | ||
) | ||
systemProperty( | ||
"paparazzi.report.dir", | ||
project.extensions.getByType(ReportingExtension).baseDirectory.dir("paparazzi").get().toString() | ||
) | ||
systemProperty( | ||
"paparazzi.snapshot.dir", | ||
project.layout.projectDirectory.dir("src/test/snapshots").toString() | ||
) | ||
systemProperty( | ||
"paparazzi.artifacts.cache.dir", | ||
project.gradle.gradleUserHomeDir.path | ||
) | ||
systemProperty( | ||
"paparazzi.layoutlib.runtime.root", | ||
configurations.layoutlibRuntime.singleFile.absolutePath | ||
) | ||
systemProperty( | ||
"paparazzi.layoutlib.resources.root", | ||
configurations.layoutlibResources.singleFile.absolutePath | ||
) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a bit unfortunate that both the sdk and junit rule needs this; but it makes sense, the actual config in practice would come from the (gradle) plugin. might make sense to evolve the sdk into a builder pattern; i'll mess around with this in a follow-up. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you intentionally keep the Consider publishing the -junit4 from the -junit4 module and reintroduce a |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,5 @@ | ||||||
@file:Suppress("invisible_reference", "invisible_member") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using all uppercase to highlight that you're suppressing compiler errors
Suggested change
|
||||||
|
||||||
package app.cash.paparazzi | ||||||
|
||||||
import android.content.Context | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@file:Suppress("invisible_reference", "invisible_member") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allows "friend references", i.e., extending internal access across cross project-modules. By default, kotlin only allows code within the same module to access There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not K2 friendly: https://youtrack.jetbrains.com/issue/KT-67920 Maybe it is possible to befriend another module's sourceSet with this? |
||
|
||
package app.cash.paparazzi.accessibility | ||
|
||
import android.content.Context | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,6 @@ dependencies { | |
api libs.tools.ninepatch | ||
api libs.tools.sdkCommon | ||
api libs.kxml2 | ||
api libs.junit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
api libs.androidx.annotations | ||
api libs.guava | ||
api libs.kotlinx.coroutines.android | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POM_ARTIFACT_ID=paparazzi-sdk | ||
POM_NAME=Paparazzi SDK | ||
POM_DESCRIPTION=An SDK to render your application screens without a physical device or emulator | ||
POM_PACKAGING=jar |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
*/ | ||
package app.cash.paparazzi.internal | ||
|
||
import app.cash.paparazzi.Paparazzi | ||
import app.cash.paparazzi.PaparazziSdk | ||
import com.android.ide.common.rendering.api.ILayoutLog | ||
import com.android.utils.ILogger | ||
import java.io.PrintStream | ||
|
@@ -28,7 +28,7 @@ import java.util.logging.Logger.getLogger | |
* This logger delegates to java.util.Logging. | ||
*/ | ||
internal class PaparazziLogger : ILayoutLog, ILogger { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename class to match module/logger? |
||
private val logger: Logger = getLogger(Paparazzi::class.java.name) | ||
private val logger: Logger = getLogger(PaparazziSdk::class.java.name) | ||
private val errors = mutableListOf<Throwable>() | ||
|
||
override fun error( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deliberate for now. can query gradle extension config for junit4 vs junit5, but not sure how to keep it generic for other 3rd party wrappers.