Skip to content

Commit

Permalink
try another way to extract executable (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewparmet authored Oct 10, 2023
1 parent 31a8c00 commit 473af7f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
package protokt.v1.gradle

import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency

private const val CODEGEN_CONFIGURATION = "protoktCodegen"

internal fun binaryFromArtifact(project: Project): String {
configureArtifact(project)

project.afterEvaluate {
installBinary(project, configureArtifact(project))
installBinary(project)
}

return "${getTargetDirectory(project)}/bin/$CODEGEN_NAME"
}

private fun installBinary(project: Project, artifact: Dependency) {
private fun installBinary(project: Project) {
val targetDir = getTargetDirectory(project)

if (PROTOKT_VERSION.endsWith("-SNAPSHOT") || !targetDir.exists()) {
Expand All @@ -37,7 +38,6 @@ private fun installBinary(project: Project, artifact: Dependency) {
val toolsArchive = project.zipTree(
project.configurations
.getByName(CODEGEN_CONFIGURATION)
.fileCollection(artifact)
.singleFile
)

Expand All @@ -48,10 +48,10 @@ private fun installBinary(project: Project, artifact: Dependency) {
}
}

private fun configureArtifact(project: Project): Dependency {
private fun configureArtifact(project: Project) {
project.configurations.create(CODEGEN_CONFIGURATION)

return project.dependencies.add(
project.dependencies.add(
CODEGEN_CONFIGURATION,
mapOf(
"group" to "com.toasttab.protokt",
Expand All @@ -60,7 +60,7 @@ private fun configureArtifact(project: Project): Dependency {
"classifier" to "dist",
"ext" to "zip"
)
)!!
)
}

private fun getTargetDirectory(project: Project) =
Expand Down

0 comments on commit 473af7f

Please sign in to comment.