I’m having some trouble importing Arrow’s refineme...
# arrow
m
I’m having some trouble importing Arrow’s refinement types plugin, can anyone help? Here’s the relevant parts of the gradle file :) :
Copy code
plugins {
    kotlin("jvm") version "1.5.0"
    java
    id("io.arrow-kt.refined-types") version "1.0.1"
}

buildscript {
    repositories {
        mavenCentral()
        maven(url = "<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
}
Copy code
repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib"))
    implementation("io.arrow-kt:arrow-meta:1.0.1")
    implementation("io.arrow-kt:arrow-refined-types:1.0.1")
    implementation("io.arrow-kt:arrow-core:1.0.1")
    ...
}
r
Hi @Milse113 it is no longer available as refinement types. It’s now arrow analysis https://oss.sonatype.org/content/repositories/snapshots/io/arrow-kt/analysis/
still not ready but there is snapshots
We plan a target release in december that supports compiler plugins for Kotlin and Java (Scala next quarter)
It’s much leaner than refined types because it also work at the primitive level, tracking data flow and solving constraints and their violations with an SMT solver that runs alongside the compiler. For example, you don’t need to have PositiveInt and its overhead if you want to have just Int you could do:
Copy code
fun increment(x: Int): Int {
  pre(x > 0) { "value must be positive" }
  return (x + 1).post({ it > 0 }) { "result is positive" }
}
or add those to your PositiveInt.init static initializer or any of its members
While we don’t have a release yet the docs are very through of what it can do, @Alejandro Serrano Mena has done an great job putting all these together
m
I see. I’m still having some trouble importing it
Copy code
plugins {
    kotlin("jvm") version "1.5.0"
    java
    id("io.arrow-kt.analysis") version "1.5.31-SNAPSHOT"
}

buildscript {
    repositories {
        mavenCentral()
        maven(url = "<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
}
...
Here’s my gradle, what am I missing?
(@raulraja)
Also it seems like Analysis is less powerful than refinement types, as it can’t employ predicates. My specific use-case is that I want to create a wrapper around a
String
that ensures the inner string matches a specific regex. Is this possible with the new library?
r
Is the error that it can’y resolve it? We need to update these examples https://github.com/arrow-kt/arrow-meta-examples/blob/main/demos/refined-types-compiler-plugin-demo/build.gradle
but since it’s a snapshot you would need to include the snapshots repository
in the buildscript for gradle to resolve it. Once we publish the stable release this would not be necessary because it will be in the gradle plugin portal
m
@raulraja yes thats the error, but did I not do that already?
r
if you add it like that you have to use the
apply
style for gradle plugins, not the id based in the plugins. If you want to use the plugins section I believe you need to add pluginManagement and those dependencies inside but @Javier may know a better way. We still need to fix all those examples that have not been touched for months and make them part of CI.
j
you need to add the snapshot repository to the repositories block in pluginManagement in your settings gradle file
m
Doing what you suggested @Javier does work, but it actually breaks the resolution of the kotlin plugin. Any idea why that might be?
j
you need to add gradlePluginPortal() too
and maybe mavenCentral
m
That fixed it, I also had to change my Kotlin version to 1.5.31. However, now I’m having this issue:
Copy code
Could not resolve: io.arrow-kt:arrow-analysis-laws:1.5.31-SNAPSHOT
Could not resolve: io.arrow-kt:arrow-analysis-types:1.5.31-SNAPSHOT
Could not resolve: io.arrow-kt:arrow-analysis-laws:1.5.31-SNAPSHOT
Could not resolve: io.arrow-kt:arrow-analysis-types:1.5.31-SNAPSHOT
(@Javier)
j
it should be found if the snapshots repo is in pluginManagement
m
In
settings.gradle.kts
Copy code
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
        maven(url = "<https://oss.sonatype.org/content/repositories/snapshots>")
    }
}
@Javier Any ideas?
it looks correct 😕
not sure if allprojects and/or buildscript block can be causing some inconsistence with this
m
@Javier I had already removed that
j
is it public?
m
My gradle?
j
the project
m
No, its not. What do you need to see?
j
not sure, I would want to try myself to get it working
Can you try the buildscript + apply(plugin = ...) way?
m
Copy code
buildscript {
    repositories {
        gradlePluginPortal()
        mavenCentral()
        maven(url = "<https://oss.sonatype.org/content/repositories/snapshots>")
    }
}

apply(plugin = "io.arrow-kt.analysis:1.5.31-SNAPSHOT")
this?
j
yep
m
That doesn’t work at all; it cant find the plugin
j
maybe the plugin id is the problem
apply(plugin = "io.arrow-kt.analysis")
or
m
Plugin with id 'io.arrow-kt.analysis' not found.
j
Copy code
plugins {
    id("io.arrow-kt.analysis")
}
Copy code
apply(plugin = "io.arrow-kt.analysis:1.5.31-SNAPSHOT")
that is wrong
you shouldnt put the version there
m
not putting it there doesn’t help sadlt
*sadly
same with the plugins block way
even when putting the buildscript block first
i’ve made the most progress with the settings.gradle way
j
I am going to try myself, one second
m
Ok ty
j
are you using buildSrc?
m
buildSrc?
j
then no hahah
it is a gradle special included build
m
ah
Were you able to get it working?
j
Copy code
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
        google()
        maven("<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
}

dependencyResolutionManagement {
    repositories {
        mavenCentral()
        google()
        gradlePluginPortal()
        maven("<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
}
In another project it is being downloaded with that
and this one
Copy code
plugins {
    kotlin("multiplatform")
//    id("com.android.library")
    id("io.arrow-kt.analysis") version "1.5.31-SNAPSHOT"
}
change multiplatform to jvm or whatever you need
I have no repositories in build.gradle.kts, only in settings.gradle.kts
m
Hmm
Why don’t i just send my entire gradle
Copy code
plugins {
    kotlin("jvm") version "1.5.31"
    java
    id("io.arrow-kt.analysis") version "1.5.31-SNAPSHOT"
}

//apply(plugin = "io.arrow-kt.analysis")

group = "wtf.mizu"
version = "1.0-rc1"

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib"))
    implementation("io.arrow-kt:arrow-meta:1.0.1")
    implementation("io.arrow-kt:arrow-core:1.0.1")
    testImplementation(kotlin("test"))
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
}

tasks.getByName<Test>("test") {
    useJUnitPlatform()
}
my build.gradle.kts
Copy code
rootProject.name = "mizu-common"

pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
        google()
        maven("<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
}

dependencyResolutionManagement {
    repositories {
        mavenCentral()
        google()
        gradlePluginPortal()
        maven("<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
}
my settings.gradle.kts
j
that should work
the only difference I have is I have
buildSrc
m
well that sucks 😅
@Javier What is buildsrc?
m
is there any chance the lack of buildSrc could be causing the issue?
j
maybe, but not sure, I think it should be already working with you have
maybe
./gradlew build --refresh-dependencies
?
m
Copy code
* What went wrong:
Execution failed for task ':compileKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlin'
   > Could not resolve all dependencies for configuration ':kotlinCompilerPluginClasspathMain'.
     The project declares repositories, effectively ignoring the repositories you have declared in the settings.
     You can figure out how project repositories are declared by configuring your build to fail on project repositories.
     See <https://docs.gradle.org/7.2/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories> for details.
      > Could not find io.arrow-kt:arrow-analysis-kotlin-plugin:1.5.31-SNAPSHOT.
        Required by:
            project :
j
looks like there are repositories in more places and not only in settings.gradle.kts
maybe one plugin you are using is adding repositories, even if you are not adding them
kover for example was doing that a week ago
you can try to add all those repositories in allprojects { repositories { ... } }
maybe that fix the problem
m
@Javier Yeah nothing is working. While the code itself isn’t open source I’d be happy to add you onto the repo on Github if you want to try to get it working
j
add me, but I will try tomorrow, time to sleep 🙂
m
Will do!
@Javier What’s your github?
j
JavierSegoviaCordoba
a
@Milse113 can you try with something like the follwing?
Copy code
repositories {
    mavenCentral()
    maven(url = "<https://oss.sonatype.org/content/repositories/snapshots/>")
}

buildscript {
    repositories {
        maven(url = "<https://oss.sonatype.org/content/repositories/snapshots/>")
    }
    dependencies {
        classpath("io.arrow-kt.analysis:io.arrow-kt.analysis.gradle.plugin:1.5.31-SNAPSHOT")
    }
}

apply(plugin = "io.arrow-kt.analysis")
this is my test configuration, even though I’m not sure why it works 🤷