Vavr: Explain Gradle + Vavr custom pattern ($Patterns/$Unapply)

Created on 16 Jan 2019  路  7Comments  路  Source: vavr-io/vavr

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.

documentation

Most helpful comment

Sorry, I confused Maven鈥檚 compile with Gradle鈥檚 compileOnly.
What I meant was that we might need s.th. like Maven鈥檚 provided in order not to leak vavr-match as transitive dependency.

See
https://blog.gradle.org/introducing-compile-only-dependencies

The important parts:

29287701-7613-4890-9725-826157b07cd4
75f8f935-defb-41cc-a0e3-c7458d29999a

All 7 comments

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.

screenshot 2019-01-26 at 17 04 13

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鈥檚 compile with Gradle鈥檚 compileOnly.
What I meant was that we might need s.th. like Maven鈥檚 provided in order not to leak vavr-match as transitive dependency.

See
https://blog.gradle.org/introducing-compile-only-dependencies

The important parts:

29287701-7613-4890-9725-826157b07cd4
75f8f935-defb-41cc-a0e3-c7458d29999a

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ashrwin picture ashrwin  路  6Comments

liviamoroianu picture liviamoroianu  路  3Comments

ronanM picture ronanM  路  3Comments

HiDAl picture HiDAl  路  3Comments

Vivek-Patil picture Vivek-Patil  路  3Comments