Skip to content

Commit

Permalink
Urlencode extension classpath entries
Browse files Browse the repository at this point in the history
This allows `:` in the classpath entries, which is typical - but not exclusive - to Windows OSs.
  • Loading branch information
ogolberg authored Mar 17, 2021
1 parent 131321b commit 1f03e07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
import com.google.protobuf.gradle.remove
import java.io.File
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.plugins.JavaPluginConvention
Expand Down Expand Up @@ -84,7 +86,7 @@ private fun extraClasspath(project: Project, task: GenerateProtoTask): String {
extensions += project.configurations.getByName(TEST_EXTENSIONS)
}

return extensions.asPath.replace(':', ';')
return extensions.joinToString(";") { URLEncoder.encode(it.path, StandardCharsets.UTF_8) }
}

private fun configureSources(project: Project, generatedSourcesPath: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ import com.toasttab.protokt.gradle.KOTLIN_EXTRA_CLASSPATH
import com.toasttab.protokt.gradle.ONLY_GENERATE_GRPC
import com.toasttab.protokt.gradle.RESPECT_JAVA_PACKAGE
import com.toasttab.protokt.util.getProtoktVersion
import java.net.URLDecoder
import java.nio.charset.StandardCharsets

class ProtocolContext(
val fdp: FileDescriptorProto,
val allPackagesByTypeName: Map<String, PPackage>,
params: Map<String, String>
) {
val classpath = params.getOrDefault(KOTLIN_EXTRA_CLASSPATH, "").split(";")
val classpath = params.getOrDefault(KOTLIN_EXTRA_CLASSPATH, "").split(";").map {
URLDecoder.decode(it, StandardCharsets.UTF_8)
}

val respectJavaPackage = respectJavaPackage(params)
val generateGrpc = params.getValue(GENERATE_GRPC).toBoolean()
val onlyGenerateGrpc = params.getValue(ONLY_GENERATE_GRPC).toBoolean()
Expand Down

0 comments on commit 1f03e07

Please sign in to comment.