Skip to content
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

Embed the Zipline app in Android app assets #1563

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

JakeWharton
Copy link
Collaborator

This allows the app to function without the server running, or without ever having to had connect to the server in the past. It will also allow automated testing of these applications in the future.

Refs #537

Views:
Screenshot_20231005_123738

Compose UI:
Screenshot_20231005_124117

This allows the app to function without the server running, or without ever having to had connect to the server in the past. It will also allow automated testing of these applications in the future.
@JakeWharton JakeWharton force-pushed the jw.embed-zipline-application.2023-10-05 branch from cb055d8 to 56c31da Compare October 5, 2023 17:48
Comment on lines +63 to +79
// Add a timestamp to the manifest which is required for Zipline to load as an embedded app.
val outputManifest = inputManifest.copy(
unsigned = inputManifest.unsigned.copy(
freshAtEpochMs = System.currentTimeMillis(),
),
)
val outputManifestFile = outputDirectory.file("${appName.get()}.$ZIPLINE_MANIFEST_JSON").asFile
outputManifestFile.writeText(outputManifest.encodeJson())

// Rewrite all .zipline files to their SHA-256 hashes which is how Zipline loads when embedded.
for (module in outputManifest.modules.values) {
val inputFile = checkNotNull(fileMap.remove(module.url)) {
"No ${module.url} file found in input files as specified by the manifest"
}
val outputFile = outputDirectory.file(module.sha256.hex()).asFile
inputFile.copyTo(outputFile)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future change: going to move all this to happen on the production-side rather than the consumer-side so as to support iOS more easily.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And move this to the Zipline Gradle plugin!

/** Bundle a zip with dependencies and startup scripts. */
fun application(name: String, mainClass: String)
/** Bundle a zip with dependencies and startup scripts for a CLI. */
fun cliApplication(name: String, mainClass: String)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how this plugin is structured

@@ -374,4 +376,74 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB
}
}
}

override fun ziplineApplication() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I aught to move this behavior to Zipline itself!

Copy link
Collaborator

@swankjesse swankjesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it.

@swankjesse swankjesse merged commit 149bb02 into trunk Oct 6, 2023
@swankjesse swankjesse deleted the jw.embed-zipline-application.2023-10-05 branch October 6, 2023 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants