How again do I use Maven Local from a main.kts scr...
# scripting
v
How again do I use Maven Local from a main.kts script again? I'm pretty sure I did it before, but don't remember how.
m
I've used this in the past:
Copy code
@file:Repository("file:///Users/mbonnin/.m2/repository")
IIRC you also need to add maven central again if doing this because adding any custom repo disables the default one
Copy code
@file:Repository("<https://repo.maven.apache.org/maven2/>")
v
Yeah, just that it doesn't work though, at least anymore.
Copy code
build.main.kts:5:1: warning: file 'io.github.typesafegithub:github-workflows-kt:2.3.1-SNAPSHOT' not found
build.main.kts:5:1: warning: file 'C:\Users\bkautler\.m2\repository\io.github.typesafegithub:github-workflows-kt:2.3.1-SNAPSHOT' not found
build.main.kts:5:1: warning: artifactResolutionException: Could not find artifact io.github.typesafegithub:shared-internal:jar:2.3.1-SNAPSHOT in https___repo.maven.apache.org_maven2_ (<https://repo.maven.apache.org/maven2/>)
sad panda 1
Argh, honestly
m
(installing kotlin on the new laptop... 😅 )
v
Not
Copy code
@file:Repository("file:///C:/Users/bkautler/.m2/repository/")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.3.1-SNAPSHOT")
but
Copy code
@file:Repository("file:///C:/Users/bkautler/.m2/repository/")
@file:DependsOn("io/github/typesafegithub/github-workflows-kt/2.3.1-SNAPSHOT/github-workflows-kt-2.3.1-SNAPSHOT.jar")
or
Copy code
@file:Repository("file:///C:/Users/bkautler/.m2/repository/io/github/typesafegithub/github-workflows-kt/2.3.1-SNAPSHOT/")
@file:DependsOn("github-workflows-kt-2.3.1-SNAPSHOT.jar")
A
file:///
repo is used as flatdir repo
mind blown 2
m
This works on macOS:
Copy code
#! /usr/bin/env kotlin
@file:Repository("file:///Users/mbonnin/.m2/repository")
@file:DependsOn("com.apollographql.apollo:apollo-runtime-jvm:4.0.1-SNAPSHOT")

import com.apollographql.apollo.ApolloClient

println(ApolloClient::class)
Maybe
Copy code
@file:Repository("<file://C>:/Users/bkautler/.m2/repository/")
(only 2
/
)?
v
Tried everything from 0 to 5 slashes, none work as Maven repo
Oh wait, reading helps. In some cases it did complain about a dependency I did not publish to MavenLocal alongside. 🤦
Argh, that was the full problem even in the cases where it did not complain about the dependency. Now that I added the missing dependency it works with 0 to 5 slashes just fine.
Thanks for rubber-ducking
🤦
At least we now know, that you can use it as Maven repo as well as as flatdir repo
👍 1
Where you then of course miss eventual dependencies
m
0 to 5 slashes
"be flexible about what you receive" 😅
Cool that it works in all cases 🙂
v
Ah, nice, this also works (short of the dependencies of course):
Copy code
@file:Repository("file:///D:/Sourcecode/other/github-workflows-kt/")
@file:DependsOn("github-workflows-kt/build/classes/kotlin/main/")
And a file-based repo also seems to not suppress the default MC repo
👍 1
Ah, no, that was because stuff was in maven local already
👍 1
v
Yeah, all fine, just had
shared-internal
not published to maven local
👍 1