Open sir4ur0n opened 5 years ago
Thanks for the hint, will do!
Do you have (a minimal) Gradle config that I can take as example?
plugins {
java
}
group = "com.sir4ur0n.github"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
val vavrVersion = "0.10.0"
// Provides @Patterns, @Unapply, Tuple0..8
implementation("io.vavr", "vavr", vavrVersion)
// Processes patterns during compilation, outputs them in build/classes by default
annotationProcessor("io.vavr", "vavr-match-processor", vavrVersion)
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
@Sir4ur0n thank you, that helps! I think there also needs to be the additional dependency
compileOnly("io.vavr", "vavr-match", vavrVersion)
Not needed explicitly, it's a transitive dependency of io.vavr:vavr
. Anyway you also need io.vavr:vavr
tu build patterns using Tuple0..8
.
I see. That is interesting because vavr-match should only be a compile time dependency of Vavr. I think the dependency 'leaked' into the library with the PR #2294.
I need to fix that in the next version.
compile
is the default scope in maven if no scope is specified. <scope>compile</scope>
thus should be redundant. See maven docs.
Sorry, I confused Maven’s compile
with Gradle’s compileOnly
.
What I meant was that we might need s.th. like Maven’s provided
in order not to leak vavr-match
as transitive dependency.
See https://blog.gradle.org/introducing-compile-only-dependencies
The important parts:
@Sir4ur0n do you have a working example of using pattern matching with annotation processor with gradle? I've added a dependency but still cannot compile it.
I haven't developed in Java in many years, I won't be able to help you :sweat_smile:
Ok, thanks. Managed to do that on my own ;)
When using Vavr with
$Patterns
/$Unapply
, one must add additional configuration to its dependencies, otherwise Gradle does not process annotations by default.This would be nice to mention this in the documentation.
It seems that
annotationProcessor("io.vavr", "vavr-match-processor", vavrVersion)
does the trick.