-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay configuration of buf binary configuration until after the tool …
…version is resolvable from the extension (#148) See the (formerly) failing test - `configureBufDependency` grabs the `toolVersion` from the extension at plugin application time today, but this needs to be done after project evaluation in order to get the configured version.
- Loading branch information
1 parent
8dbb4ac
commit 626514c
Showing
5 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 Buf Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package build.buf.gradle | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class BufVersionTest : AbstractBufIntegrationTest() { | ||
@Test | ||
fun `buf version can be specified by the extension`() { | ||
val result = gradleRunner().withArguments("printBufVersion", "-PbufVersion=asdf").build() | ||
|
||
val versionLine = result.output.lines().single { it.startsWith("Resolved") } | ||
|
||
assertThat(versionLine).isEqualTo("Resolved Buf tool version: asdf") | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/resources/BufVersionTest/buf_version_can_be_specified_by_the_extension/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import static build.buf.gradle.BufSupportKt.BUF_BINARY_CONFIGURATION_NAME | ||
|
||
plugins { | ||
id "build.buf" | ||
} | ||
|
||
buf { | ||
toolVersion = "$bufVersion" | ||
} | ||
|
||
tasks.register("printBufVersion") { | ||
def bufConfiguration = project.configurations.named(BUF_BINARY_CONFIGURATION_NAME).get() | ||
bufConfiguration.dependencies.forEach { | ||
logger.quiet("Resolved Buf tool version: ${it.version}") | ||
} | ||
} |