Skip to content

Commit

Permalink
use Google's published layoutlib
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielittner committed Jan 13, 2024
1 parent 23f0dcd commit f4f9e51
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 279 deletions.
15 changes: 5 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ ktlint = "0.50.0"
moshi = "1.15.0"

minSdk = "25"
compileSdk = "33"
compileSdk = "34"

# Maps to this commit: https://android.googlesource.com/platform/prebuilts/studio/layoutlib/+/5e972ea
layoutlib = "2022.3.1-5e972ea"
layoutlibPrebuiltSha = "5e972ea"
layoutlib = "14.0.1"

[libraries]
androidx-annotations = { module = "androidx.annotation:annotation", version = "1.7.1" }
Expand Down Expand Up @@ -45,11 +43,6 @@ ktlint = { module = "com.pinterest.ktlint:ktlint-rule-engine", version.ref = "kt

kxml2 = { module = "kxml2:kxml2", version = "2.3.0" }

layoutlib-native-jdk11 = { module = "app.cash.paparazzi:layoutlib-native-jdk11", version.ref = "layoutlib" }
layoutlib-native-linux = { module = "app.cash.paparazzi:layoutlib-native-linux", version.ref = "layoutlib" }
layoutlib-native-macArm = { module = "app.cash.paparazzi:layoutlib-native-macarm", version.ref = "layoutlib" }
layoutlib-native-macOsX = { module = "app.cash.paparazzi:layoutlib-native-macosx", version.ref = "layoutlib" }
layoutlib-native-windows = { module = "app.cash.paparazzi:layoutlib-native-win", version.ref = "layoutlib" }

moshi-adapters = { module = "com.squareup.moshi:moshi-adapters", version.ref = "moshi" }
moshi-core = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
Expand All @@ -58,7 +51,9 @@ moshi-kotlinCodegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", vers
okio = { module = "com.squareup.okio:okio", version = "3.7.0" }

tools-common = { module = "com.android.tools:common", version.ref = "androidTools" }
tools-layoutlib = { module = "com.android.tools.layoutlib:layoutlib-api", version = "31.1.1" }
tools-layoutlib-api = { module = "com.android.tools.layoutlib:layoutlib-api", version = "31.4.0-alpha03" }
tools-layoutlib = { module = "com.android.tools.layoutlib:layoutlib", version.ref = "layoutlib" }
tools-layoutlib-runtime = { module = "com.android.tools.layoutlib:layoutlib-runtime", version.ref = "layoutlib" }
tools-ninepatch = { module = "com.android.tools:ninepatch", version.ref = "androidTools" }
tools-sdkCommon = { module = "com.android.tools:sdk-common", version.ref = "androidTools" }

Expand Down
54 changes: 0 additions & 54 deletions libs/README.md

This file was deleted.

1 change: 0 additions & 1 deletion libs/build.gradle

This file was deleted.

61 changes: 0 additions & 61 deletions libs/layoutlib/build.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions libs/layoutlib/gradle.properties

This file was deleted.

26 changes: 0 additions & 26 deletions libs/native-linux/build.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions libs/native-linux/gradle.properties

This file was deleted.

26 changes: 0 additions & 26 deletions libs/native-macarm/build.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions libs/native-macarm/gradle.properties

This file was deleted.

26 changes: 0 additions & 26 deletions libs/native-macosx/build.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions libs/native-macosx/gradle.properties

This file was deleted.

26 changes: 0 additions & 26 deletions libs/native-win/build.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions libs/native-win/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ class PaparazziPlugin : Plugin<Project> {
val nativeLibraryArtifactId = when {
operatingSystem.isMacOsX -> {
val osArch = System.getProperty("os.arch").lowercase(Locale.US)
if (osArch.startsWith("x86")) "macosx" else "macarm"
if (osArch.startsWith("x86")) "mac" else "mac-arm"
}
operatingSystem.isWindows -> "win"
else -> "linux"
}

val nativePlatformConfiguration = configurations.create("nativePlatform")
nativePlatformConfiguration.dependencies.add(
dependencies.create("app.cash.paparazzi:layoutlib-native-$nativeLibraryArtifactId:$NATIVE_LIB_VERSION")
dependencies.create("com.android.tools.layoutlib:layoutlib-runtime:$NATIVE_LIB_VERSION:$nativeLibraryArtifactId")
)
dependencies.registerTransform(UnzipTransform::class.java) { transform ->
transform.from.attribute(ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.JAR_TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ class PaparazziPluginTest {

val resourceFileContents = resourcesFile.readLines()
assertThat(resourceFileContents[2]).isEqualTo("33")
assertThat(resourceFileContents[3]).isEqualTo("platforms/android-33/")
assertThat(resourceFileContents[3]).isEqualTo("platforms/android-34/")
}

@Test
Expand All @@ -1160,7 +1160,7 @@ class PaparazziPluginTest {

val resourceFileContents = resourcesFile.readLines()
assertThat(resourceFileContents[2]).isEqualTo("29")
assertThat(resourceFileContents[3]).isEqualTo("platforms/android-33/")
assertThat(resourceFileContents[3]).isEqualTo("platforms/android-34/")
}

@Test
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions paparazzi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ dependencies {
implementation libs.bytebuddy.agent
implementation libs.bytebuddy.core
implementation libs.trove4j
api libs.layoutlib.native.jdk11
api libs.tools.common
api libs.tools.layoutlib
api libs.tools.layoutlib.api
api libs.tools.ninepatch
api libs.tools.sdkCommon
api libs.kxml2
Expand All @@ -64,14 +64,14 @@ dependencies {
if (osName.startsWith("mac")) {
def osArch = System.getProperty("os.arch").toLowerCase(Locale.US)
if (osArch.startsWith("x86")) {
unzip libs.layoutlib.native.macOsX
unzip variantOf(libs.tools.layoutlib.runtime) { classifier("mac") }
} else {
unzip libs.layoutlib.native.macArm
unzip variantOf(libs.tools.layoutlib.runtime) { classifier("mac-arm") }
}
} else if (osName.startsWith("windows")) {
unzip libs.layoutlib.native.windows
unzip variantOf(libs.tools.layoutlib.runtime) { classifier("win") }
} else {
unzip libs.layoutlib.native.linux
unzip variantOf(libs.tools.layoutlib.runtime) { classifier("linux") }
}

testImplementation libs.truth
Expand Down Expand Up @@ -104,8 +104,8 @@ def generateTestConfig = tasks.register("generateTestConfig") {
configFile.withWriter('utf-8') { writer ->
writer.writeLine("app.cash.paparazzi")
writer.writeLine(".")
writer.writeLine("31")
writer.writeLine("platforms/android-31/")
writer.writeLine("34")
writer.writeLine("platforms/android-34/")
writer.writeLine(".")
writer.writeLine("app.cash.paparazzi")
writer.writeLine("")
Expand Down
Loading

0 comments on commit f4f9e51

Please sign in to comment.