Skip to content

Commit

Permalink
use published buf artifacts (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewparmet authored Oct 11, 2022
1 parent f115e0d commit a5a480a
Show file tree
Hide file tree
Showing 100 changed files with 348 additions and 76 deletions.
7 changes: 6 additions & 1 deletion src/main/kotlin/com/parmet/buf/gradle/BufExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ open class BufExtension {
/**
* Specify the version of Buf.
*/
var toolVersion: String = "1.8.0"
var toolVersion = "1.8.0"

/**
* Specify the version of the Buf executable artifact.
*/
var toolArtifactVersion = "1.0.0"

internal var imageArtifactDetails: ArtifactDetails? = null

Expand Down
29 changes: 13 additions & 16 deletions src/main/kotlin/com/parmet/buf/gradle/BufSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,17 @@ package com.parmet.buf.gradle

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.kotlin.dsl.ivy
import org.gradle.kotlin.dsl.repositories
import java.nio.charset.StandardCharsets

const val BUF_BINARY_CONFIGURATION_NAME = "bufTool"

internal fun Project.configureBufDependency() {
repositories {
ivy("https://github.com") {
patternLayout {
artifact("/[organization]/[module]/releases/download/v[revision]/buf-[classifier]-[ext]")
}
metadataSources { artifact() }
}
}

val os = System.getProperty("os.name").toLowerCase()
val (osPart, archExt) =
val osPart =
when {
os.startsWith("windows") -> "Windows" to ".exe"
os.startsWith("linux") -> "Linux" to ""
os.startsWith("mac") -> "Darwin" to ""
os.startsWith("windows") -> "windows"
os.startsWith("linux") -> "linux"
os.startsWith("mac") -> "osx"
else -> error("unsupported os: $os")
}

Expand All @@ -49,9 +38,17 @@ internal fun Project.configureBufDependency() {
else -> error("unsupported arch: $arch")
}

val extension = getExtension()

createConfigurationWithDependency(
BUF_BINARY_CONFIGURATION_NAME,
"bufbuild:buf:${getExtension().toolVersion}:$osPart@${archPart + archExt}"
mapOf(
"group" to "com.parmet.buf",
"name" to "buf",
"version" to extension.toolArtifactVersion,
"classifier" to "${extension.toolVersion}-$osPart-$archPart",
"ext" to "exe"
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
}

repositories {
mavenCentral()
maven { url 'build/repos/test' }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
imageArtifact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
imageArtifact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ plugins {
id 'maven-publish'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ plugins {
id 'maven-publish'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ plugins {
id 'maven-publish'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ plugins {
id 'maven-publish'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ plugins {
id 'maven-publish'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
imageArtifact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ plugins {
id 'maven-publish'
}

repositories {
mavenCentral()
}

buf {
publishSchema = true
imageArtifact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ plugins {
id 'com.google.protobuf' version "$protobufGradleVersion"
id 'com.parmet.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ plugins {
id 'com.parmet.buf'
id 'com.google.protobuf' version "$protobufGradleVersion"
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ plugins {
id 'java'
id 'com.parmet.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ plugins {
id 'com.parmet.buf'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ plugins {
id 'com.parmet.buf'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ plugins {
id 'com.parmet.buf'
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ plugins {
id 'java'
id 'com.parmet.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ plugins {
id 'com.parmet.buf'
}

repositories {
mavenCentral()
}

buf {
enforceFormat = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ plugins {
id 'java'
id 'com.parmet.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ plugins {
id 'java'
id 'com.parmet.buf'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ buf {
enforceFormat = true
}

repositories { mavenCentral() }
repositories {
mavenCentral()
}

protobuf {
protoc {
Expand Down
Loading

0 comments on commit a5a480a

Please sign in to comment.