Skip to content

Commit

Permalink
Add artifact version resolution support to gradle plugin (#107)
Browse files Browse the repository at this point in the history
* add artifact version resolution via gradle plugin

* update version and add note to example project
  • Loading branch information
marcoferrer authored Feb 4, 2020
1 parent 7b6e0f5 commit e39cfe7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ _2020-02-03_
#### Proto Builders (DSL)
* Fix: Dsl marker interfaces are properly omitted from generated code when disabled [PR-106](https://github.com/marcoferrer/kroto-plus/pull/106)

#### Gradle Plugin
* New: Automatically configure artifact version for project kroto dependencies with missing version [PR-107](https://github.com/marcoferrer/kroto-plus/pull/107) Thanks to @Fleshgrinder

## Version 0.6.0
_2019-12-26_
* New: Update to Kotlin `1.3.61` [PR-97](https://github.com/marcoferrer/kroto-plus/pull/97)
Expand Down
6 changes: 4 additions & 2 deletions example-project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
id 'idea'
id 'com.google.protobuf' version '0.8.8'
id "org.jetbrains.kotlin.jvm" version "1.3.50"
id "com.github.marcoferrer.kroto-plus" version "0.6.0"
id "com.github.marcoferrer.kroto-plus" version "0.6.1"
}

group = 'com.github.marcoferrer.krotoplus'
Expand Down Expand Up @@ -62,10 +62,12 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}"
implementation "com.google.protobuf:protobuf-java:${versions.protobuf}"
implementation "com.github.marcoferrer.krotoplus:kroto-plus-coroutines:${versions.krotoplus}"
implementation "com.github.marcoferrer.krotoplus:kroto-plus-test:${versions.krotoplus}"
implementation "com.github.marcoferrer.krotoplus:kroto-plus-message:${versions.krotoplus}"

// Alternatively you can omit the artifact version if the Kroto+ gradle plugin is applied.
implementation "com.github.marcoferrer.krotoplus:kroto-plus-coroutines"

implementation "io.grpc:grpc-protobuf:${versions.grpc}",
"io.grpc:grpc-stub:${versions.grpc}",
"io.grpc:grpc-netty:${versions.grpc}"
Expand Down
10 changes: 8 additions & 2 deletions kroto-plus-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ protobuf {
generateProtoTasks {
def krotoConfig = file("krotoPlusConfig.asciipb")

all().each{ task ->
all().each { task ->
task.dependsOn ':kroto-plus-gradle-plugin:gen-config-dsl:jar'
configProtoTaskWithKroto(task, krotoConfig)
}
}

}
}

tasks.withType(Jar).each { task ->
task.manifest {
attributes 'Implementation-Version': project.version
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,23 @@ class KrotoPlusGradlePlugin : Plugin<Project> {
}
}
}

project.configurations.all { config ->
config.resolutionStrategy.eachDependency { details ->
if(details.requested.group == "com.github.marcoferrer.krotoplus" &&
details.requested.version.isNullOrBlank()) {

details.useVersion(Manifest.implVersion)
}
}
}
}

companion object {
private const val PROTOBUF_PLUGIN_ID = "com.google.protobuf"
}
}

object Manifest {
val implVersion = this::class.java.`package`.implementationVersion.orEmpty()
}

0 comments on commit e39cfe7

Please sign in to comment.