delete protobuf stuff, and unused code
This commit is contained in:
parent
16d382db11
commit
7dd7baef34
132 changed files with 16 additions and 57708 deletions
|
|
@ -1,20 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.Directory
|
||||
import org.gradle.api.file.ProjectLayout
|
||||
import org.gradle.api.provider.Provider
|
||||
|
||||
object Constants {
|
||||
const val PBG_SETTINGS_NAME = "pbAndG"
|
||||
const val PBG_TASK_GROUP = PBG_SETTINGS_NAME// "pb-and-g"
|
||||
const val PBG_LIBS_CONF_NAME = "protobufLibrary"
|
||||
const val PBG_TASK_COMPILE = "protobufCompile"
|
||||
|
||||
val Project.pbAndGBuildDir: Provider<Directory>
|
||||
get() = layout.pbAndGBuildDir
|
||||
|
||||
val ProjectLayout.pbAndGBuildDir: Provider<Directory>
|
||||
get() = buildDirectory.dir(PBG_TASK_GROUP)
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg
|
||||
|
||||
import dev.adamko.gradle.pbandg.settings.PBAndGSettings
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
|
||||
|
||||
class ProtobufCompilerDependency(
|
||||
project: Project,
|
||||
pluginSettings: PBAndGSettings,
|
||||
private val conf: Configuration = project.configurations.create("protobufCompiler") {
|
||||
this.description = "Define a single dependency that provides the protoc.exe for this system"
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
isTransitive = false
|
||||
|
||||
defaultDependencies {
|
||||
add(pluginSettings.dependency.get())
|
||||
}
|
||||
}
|
||||
) : Configuration by conf
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.pattern
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.hasPlugin
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.gradle.plugins.ide.idea.GenerateIdeaModule
|
||||
import org.gradle.plugins.ide.idea.IdeaPlugin
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel
|
||||
|
||||
/**
|
||||
* IntelliJ requires source dirs are configured first.
|
||||
*
|
||||
* https://github.com/google/protobuf-gradle-plugin/blob/master/src/main/groovy/com/google/protobuf/gradle/Utils.groovy#L128
|
||||
*/
|
||||
class IntelliJPattern : Plugin<Project> {
|
||||
|
||||
fun isIdeaPluginPresent(project: Project) = project.plugins.hasPlugin(IdeaPlugin::class)
|
||||
|
||||
override fun apply(project: Project) {
|
||||
|
||||
if (!isIdeaPluginPresent(project)) {
|
||||
return
|
||||
}
|
||||
|
||||
val genSrcDir = project.layout.buildDirectory.dir("pbAndG/generated-sources")
|
||||
val ktGenSrc = genSrcDir.map { it.dir("kotlin").asFile }
|
||||
val jGenSrc = genSrcDir.map { it.dir("java").asFile }
|
||||
|
||||
val protoSrc = project.layout.projectDirectory.dir("src/main/proto").asFile
|
||||
|
||||
project.mkdir(ktGenSrc)
|
||||
project.mkdir(jGenSrc)
|
||||
|
||||
project.plugins.withType<IdeaPlugin> {
|
||||
project.extensions.configure<IdeaModel> {
|
||||
module {
|
||||
generatedSourceDirs.add(ktGenSrc.get())
|
||||
generatedSourceDirs.add(jGenSrc.get())
|
||||
sourceDirs.add(protoSrc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.tasks.withType<GenerateIdeaModule> {
|
||||
doFirst {
|
||||
project.mkdir(ktGenSrc)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.pattern
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
|
||||
class KotlinJvmProjectConfiguration : Plugin<Project> {
|
||||
|
||||
override fun apply(project: Project) {
|
||||
addSourceSets(project)
|
||||
}
|
||||
|
||||
private fun addSourceSets(project: Project) {
|
||||
|
||||
project.beforeEvaluate {
|
||||
extensions.findByType<KotlinJvmProjectExtension>()?.apply {
|
||||
extensions.findByType<SourceSetContainer>()
|
||||
?.named(SourceSet.MAIN_SOURCE_SET_NAME)
|
||||
?.configure {
|
||||
java {
|
||||
srcDir(layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
||||
srcDir(layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// val srcSet = project.extensions.getByName<SourceSet>(SourceSet.MAIN_SOURCE_SET_NAME)
|
||||
//
|
||||
// project.tasks
|
||||
// .withType<ProtobufCompileTask>()
|
||||
// .map { it.generatedSources.get() }
|
||||
// .forEach { generatedSourcesDir ->
|
||||
// project.logger.lifecycle("-------\nadding generated sources $generatedSourcesDir\n-------")
|
||||
//
|
||||
// srcSet.java {
|
||||
// srcDir(generatedSourcesDir.dir("java"))
|
||||
// srcDir(generatedSourcesDir.dir("kotlin"))
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.pattern
|
||||
|
||||
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class KotlinMultiplatformProjectConfiguration : Plugin<Project> {
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.afterEvaluate {
|
||||
addSourceSets(project)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addSourceSets(project: Project) {
|
||||
|
||||
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
project.logger.lifecycle("Kotlin Multiplatform source sets: ${sourceSets.joinToString { "${it.name} / ${it.kotlin.sourceDirectories.files.joinToString()}" }}")
|
||||
|
||||
val jvmProto = this.sourceSets.maybeCreate("jvmProto").apply {
|
||||
|
||||
kotlin.srcDir(project.layout.pbAndGBuildDir.get().dir("generated-sources/java"))
|
||||
kotlin.srcDir(project.layout.pbAndGBuildDir.get().dir("generated-sources/kotlin"))
|
||||
|
||||
dependsOn(sourceSets.maybeCreate("jvmMain"))
|
||||
}
|
||||
//
|
||||
val tsProto = this.sourceSets.maybeCreate("tsProto").apply {
|
||||
|
||||
kotlin.srcDir(project.layout.pbAndGBuildDir.get().dir("generated-sources/typescript"))
|
||||
|
||||
dependsOn(sourceSets.maybeCreate("jsMain"))
|
||||
}
|
||||
|
||||
// this.sourceSets.findByName("jvmMain")?.apply {
|
||||
//// protoJvm.dependsOn(this)
|
||||
//// dependsOn(protoJvm)
|
||||
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
||||
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
||||
// }
|
||||
// this.sourceSets.findByName("jsMain")?.apply {
|
||||
//// protoTypescript.dependsOn(this)
|
||||
//// dependsOn(protoTypescript)
|
||||
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
||||
// }
|
||||
|
||||
project.logger.lifecycle("Kotlin Multiplatform source sets: ${sourceSets.joinToString { "${it.name} / ${it.kotlin.sourceDirectories.files.joinToString()}" }}")
|
||||
|
||||
//
|
||||
// targets .forEach {
|
||||
// when (it.platformType){
|
||||
// KotlinPlatformType.jvm -> {}
|
||||
// KotlinPlatformType.js -> {
|
||||
// it.defaultConfigurationName
|
||||
// }
|
||||
// KotlinPlatformType.androidJvm -> {}
|
||||
// KotlinPlatformType.common -> {}
|
||||
// KotlinPlatformType.native -> {}
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg
|
||||
|
||||
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||
import dev.adamko.gradle.pbandg.settings.PBAndGSettings
|
||||
import dev.adamko.gradle.pbandg.task.ProtobufCompileTask
|
||||
import dev.adamko.gradle.pbandg.task.ProtobufPrepareLibrariesTask
|
||||
|
||||
plugins {
|
||||
base
|
||||
}
|
||||
|
||||
// TODO investigate builtBy and sourceDirectorySet?
|
||||
// project.objects.fileCollection().builtBy()
|
||||
// val pbSrcSet = project.objects.sourceDirectorySet("protobuf", "protobuf")
|
||||
|
||||
//if (plugins.hasPlugin(IdeaPlugin::class)) {
|
||||
// IntelliJPattern().apply(project)
|
||||
//}
|
||||
|
||||
//plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||
// logger.info("Configuring Kotlin JVM plugin for PB&G")
|
||||
// KotlinJvmProjectConfiguration().apply(project)
|
||||
//}
|
||||
//
|
||||
//plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
||||
// logger.info("Configuring Kotlin Multiplatform plugin for PB&G")
|
||||
// KotlinMultiplatformProjectConfiguration().apply(project)
|
||||
//}
|
||||
|
||||
val pbAndGSettings =
|
||||
project.extensions.create(Constants.PBG_SETTINGS_NAME, PBAndGSettings::class, project)
|
||||
|
||||
//val protocDep = ProtobufCompilerDependency(project, pbAndGSettings)
|
||||
val protocDep: Configuration = project.configurations.create("protobufCompiler") {
|
||||
this.description = "Define a single dependency that provides the protoc.exe for this system"
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
isTransitive = false
|
||||
|
||||
defaultDependencies {
|
||||
add(pbAndGSettings.dependency.get())
|
||||
}
|
||||
}
|
||||
|
||||
val protobufLibraryDependencies: Configuration =
|
||||
project.configurations.create(Constants.PBG_LIBS_CONF_NAME) {
|
||||
isVisible = true
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
isTransitive = false
|
||||
}
|
||||
|
||||
project.dependencies {
|
||||
protobufLibraryDependencies("com.google.protobuf:protobuf-javalite:3.19.1") {
|
||||
because("This dep contains common Google .proto files that will be extracted")
|
||||
}
|
||||
}
|
||||
|
||||
val protobufPrepareLibrariesTask =
|
||||
project.tasks.register<ProtobufPrepareLibrariesTask>("protobufPrepareLibraries") {
|
||||
librarySources.set(protobufLibraryDependencies)
|
||||
}
|
||||
|
||||
project.tasks.withType<ProtobufCompileTask> {
|
||||
dependsOn(protocDep, protobufPrepareLibrariesTask)
|
||||
protobufLibraryDirectories.add(protobufPrepareLibrariesTask.flatMap { it.librariesDirectory })
|
||||
|
||||
val exe = protocDep.singleFile
|
||||
logger.debug("Configuring Protobuf task with protoc.exe: $exe")
|
||||
protocExecutable.set(exe)
|
||||
}
|
||||
|
||||
val aggregateTask = project.tasks.register<Sync>("protobufCompileAll") {
|
||||
group = Constants.PBG_TASK_GROUP
|
||||
|
||||
val pbCompileTasks = tasks.withType<ProtobufCompileTask>()
|
||||
dependsOn(pbCompileTasks)
|
||||
|
||||
val genSrcDir = project.layout.pbAndGBuildDir.map { it.dir("generated-sources") }
|
||||
|
||||
from(pbCompileTasks.map { it.temporaryDir })
|
||||
into(genSrcDir)
|
||||
includeEmptyDirs = false
|
||||
|
||||
}
|
||||
|
||||
project.tasks.assemble { dependsOn(aggregateTask) }
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.settings
|
||||
|
||||
|
||||
import java.util.function.Supplier
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.kotlin.dsl.create
|
||||
import org.gradle.kotlin.dsl.property
|
||||
import org.gradle.nativeplatform.platform.Architecture
|
||||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
|
||||
import org.gradle.nativeplatform.platform.internal.DefaultOperatingSystem
|
||||
|
||||
abstract class PBAndGSettings(private val project: Project) {
|
||||
|
||||
val protocWorkingDir: DirectoryProperty =
|
||||
project.objects.directoryProperty()
|
||||
.convention(project.rootProject.layout.projectDirectory.dir(".gradle/protoc"))
|
||||
|
||||
val protocVersion: Property<String> =
|
||||
project.objects.property(String::class).convention("3.19.1")
|
||||
|
||||
val protocGroup: Property<String> =
|
||||
project.objects.property(String::class).convention("com.google.protobuf")
|
||||
|
||||
val protocArtifactName: Property<String> =
|
||||
project.objects.property(String::class).convention("protoc")
|
||||
|
||||
val protocArtifactExtension: Property<String> =
|
||||
project.objects.property(String::class).convention("exe")
|
||||
|
||||
val operatingSystemProvider: Property<Supplier<DefaultOperatingSystem>> =
|
||||
project.objects.property<Supplier<DefaultOperatingSystem>>()
|
||||
.convention { DefaultNativePlatform.getCurrentOperatingSystem() }
|
||||
|
||||
/**
|
||||
* Should return one of
|
||||
*
|
||||
* * `linux`
|
||||
* * `osx`
|
||||
* * `windows`
|
||||
*/
|
||||
val operatingSystemName: Property<String> =
|
||||
project.objects
|
||||
.property<String>()
|
||||
.convention(operatingSystemProvider.map { it.get().toFamilyName() })
|
||||
|
||||
private val architectureProvider: Provider<Architecture> =
|
||||
project.provider { DefaultNativePlatform.getCurrentArchitecture() }
|
||||
|
||||
/**
|
||||
* Should return one of
|
||||
*
|
||||
* * `aarch_64`
|
||||
* * `ppcle_64`
|
||||
* * `x86_32`
|
||||
* * `x86_64`
|
||||
*/
|
||||
val architectureName: Property<String> =
|
||||
project.objects
|
||||
.property<String>()
|
||||
.convention(architectureProvider.map { it.name.replace("-", "_") })
|
||||
|
||||
private val classifierProvider: Provider<String> =
|
||||
project.provider { "${operatingSystemName.get()}-${architectureName.get()}" }
|
||||
|
||||
/**
|
||||
* Default: concatenate [operatingSystemName] and [architectureName]
|
||||
*
|
||||
* Should return one of:
|
||||
*
|
||||
* * `linux-aarch_64`
|
||||
* * `linux-ppcle_64`
|
||||
* * `linux-x86_64`
|
||||
* * `osx-x86_32`
|
||||
* * `osx-x86_64`
|
||||
* * `windows-x86_32`
|
||||
*/
|
||||
val classifier: Property<String> =
|
||||
project.objects
|
||||
.property<String>()
|
||||
.convention(classifierProvider)
|
||||
|
||||
|
||||
private val dependencyProvider: Provider<ExternalModuleDependency> =
|
||||
project.provider {
|
||||
project.dependencies.create(
|
||||
group = protocGroup.get(),
|
||||
name = protocArtifactName.get(),
|
||||
version = protocVersion.get(),
|
||||
classifier = classifierProvider.get(),
|
||||
ext = protocArtifactExtension.get(),
|
||||
)
|
||||
}
|
||||
|
||||
val dependency: Property<ExternalModuleDependency> =
|
||||
project.objects
|
||||
.property<ExternalModuleDependency>()
|
||||
.convention(dependencyProvider)
|
||||
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.task
|
||||
|
||||
import dev.adamko.gradle.pbandg.Constants
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.Directory
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.kotlin.dsl.property
|
||||
|
||||
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||
|
||||
abstract class ProtobufCompileTask : DefaultTask() {
|
||||
|
||||
@get:InputFile
|
||||
abstract val protocExecutable: RegularFileProperty
|
||||
|
||||
@get:InputFiles
|
||||
abstract val protobufLibraryDirectories: ListProperty<Directory>
|
||||
|
||||
// @get:Input
|
||||
// abstract val protocOutputs: DomainObjectSet<ProtocOutput>
|
||||
// = project.objects.domainObjectSet(ProtocOutput::class.java)
|
||||
|
||||
@get:Input
|
||||
abstract val cliArgs: ListProperty<String>
|
||||
|
||||
@get:InputFile
|
||||
abstract val protoFile: RegularFileProperty
|
||||
|
||||
@get:Input
|
||||
val cliParamProtoPath: Property<String> =
|
||||
project.objects.property<String>().convention("--proto_path=")
|
||||
|
||||
@get:OutputDirectory
|
||||
val outputDir: RegularFileProperty =
|
||||
project.objects.fileProperty().convention { temporaryDir }
|
||||
|
||||
// @get:Internal
|
||||
// val outputPath: Provider<String> = outputDir.map { it.asFile.canonicalPath }
|
||||
|
||||
init {
|
||||
group = Constants.PBG_TASK_GROUP
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun compile() {
|
||||
// prepare directories
|
||||
project.mkdir(outputDir)
|
||||
|
||||
project.exec {
|
||||
executable(protocExecutable.asFile.get())
|
||||
workingDir(outputDir.asFile.get())
|
||||
|
||||
// val mapOutputsToOutputDir =
|
||||
// protocOutputs.associateWith { outputDir.get().asFile.resolve(it.outputDirectoryName) }
|
||||
// mapOutputsToOutputDir.values.forEach { project.mkdir(it) }
|
||||
//
|
||||
// // set args
|
||||
// mapOutputsToOutputDir
|
||||
// .map { (opt, dir) ->
|
||||
// val optionsSuffix = if (opt.protocOptions.isBlank()) "" else ":"
|
||||
// "${opt.cliParam}=${opt.protocOptions}$optionsSuffix$dir"
|
||||
// }
|
||||
// .also { args(it) }
|
||||
args(cliArgs.get())
|
||||
|
||||
val protoPath = cliParamProtoPath.get()
|
||||
val libArgs = protobufLibraryDirectories.get().map { "$protoPath${it.asFile}" }
|
||||
args(libArgs)
|
||||
|
||||
val targetProtoFile = protoFile.get().asFile
|
||||
args("$protoPath${targetProtoFile.parentFile}")
|
||||
args("$targetProtoFile")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.task
|
||||
|
||||
import dev.adamko.gradle.pbandg.Constants
|
||||
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.kotlin.dsl.property
|
||||
|
||||
/** Download protobuf libs */
|
||||
abstract class ProtobufPrepareLibrariesTask : DefaultTask() {
|
||||
|
||||
@get:InputFiles
|
||||
val librarySources: Property<Configuration> = project.objects.property()
|
||||
|
||||
@OutputDirectory
|
||||
val librariesDirectory: DirectoryProperty = project.objects.directoryProperty()
|
||||
.convention(project.pbAndGBuildDir.map { it.dir("libs") })
|
||||
|
||||
init {
|
||||
group = Constants.PBG_TASK_GROUP
|
||||
description = "Download and extract protobuf libs"
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun doTask() {
|
||||
project.sync {
|
||||
includeEmptyDirs = false
|
||||
from(librarySources.map { conf -> conf.map { project.zipTree(it) } })
|
||||
into(librariesDirectory)
|
||||
include("**/*.proto")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.task
|
||||
|
||||
|
||||
import dev.adamko.gradle.pbandg.settings.PBAndGSettings
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
|
||||
abstract class ProtocPrepareTask : DefaultTask() {
|
||||
|
||||
@Internal
|
||||
val protocPluginConfig: Provider<PBAndGSettings> = project.provider {
|
||||
project.extensions.getByType<PBAndGSettings>()
|
||||
}
|
||||
|
||||
@get:OutputDirectory
|
||||
val outputDirectory: DirectoryProperty = project.objects.directoryProperty()
|
||||
.convention(protocPluginConfig.flatMap { it.protocWorkingDir })
|
||||
|
||||
@Internal
|
||||
val protocOutput: RegularFileProperty = project.objects.fileProperty()
|
||||
|
||||
@Internal
|
||||
val protocDependency: Provider<ExternalModuleDependency> =
|
||||
protocPluginConfig.flatMap { it.dependency }
|
||||
|
||||
init {
|
||||
super.setGroup("protobuf")
|
||||
outputs.dir(outputDirectory)
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun action() {
|
||||
|
||||
val protocDep: Configuration = project.configurations.create("protoc") {
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
isTransitive = false
|
||||
|
||||
defaultDependencies {
|
||||
add(protocDependency.get())
|
||||
}
|
||||
}
|
||||
|
||||
logger.lifecycle("Downloading protoc")
|
||||
val resolvedProtocDep = protocDep.singleFile
|
||||
logger.lifecycle("Downloaded $resolvedProtocDep")
|
||||
|
||||
project.sync {
|
||||
from(resolvedProtocDep)
|
||||
into(outputDirectory)
|
||||
logger.lifecycle("Syncing from $resolvedProtocDep to ${outputDirectory.asFile.get().canonicalPath}")
|
||||
protocOutput.set(outputDirectory.asFileTree.singleFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package dev.adamko.gradle.pbandg.task.options
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
interface ProtocOutput : Serializable {
|
||||
val cliParam: String
|
||||
val protocOptions: String
|
||||
val outputDirectoryName: String
|
||||
|
||||
data class KotlinOutput(
|
||||
override val protocOptions: String = "lite",
|
||||
override val outputDirectoryName: String = "kotlin",
|
||||
) : ProtocOutput {
|
||||
override val cliParam: String = "--kotlin_out"
|
||||
}
|
||||
|
||||
data class JavaOutput(
|
||||
override val protocOptions: String = "lite",
|
||||
override val outputDirectoryName: String = "java",
|
||||
) : ProtocOutput {
|
||||
override val cliParam: String = "--java_out"
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue