kscripting / kscript

Scripting enhancements for Kotlin
MIT License
2.08k stars 126 forks source link

Maven Repo support http url #336

Closed wuseal closed 2 years ago

wuseal commented 2 years ago

Hi, @holgerbrandl When I config maven repo with annotation:

@file:MavenRepository("inner-repo","http://xxx.xxx.xxx/repository/maven-public/" )

When execute the script, It report error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://xxx.xxx.xxx/repository/maven-public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.3.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

As i saw the @file:MavenRepository there is no such config to enable allowInsecureProtocol

I want to know is there any workaround to let maven repo config a url that is not start with https after gradle 7.0?

holgerbrandl commented 2 years ago

I'd strongly believe that https repos are supported out of the box. See https://github.com/holgerbrandl/kscript/blob/919ce1f445f90e6b30af1a3fbf5fd723a3734a0a/src/main/kotlin/kscript/app/resolver/DependencyResolver.kt#L19-L19 So it's the default way to talk to maven-central in kscript.

Are you sure that you do not need any credentials?

gradle is not used by kscript to resolve dependencies. It's binding against the kotlin-scripting APIs to do so. So one possible source might be that kotlin API's have changed. Could you run kscript --version and report the JVM and kotlin versions in here?

wuseal commented 2 years ago

Hi, @holgerbrandl My kscript info:

Copyright : 2020 Holger Brandl
License   : MIT
Version   : v3.1.0
Website   : https://github.com/holgerbrandl/kscript
Kotlin    : 1.6.0-release-798
Java      : JRE 11.0.11+9

Thank you for reminding me that kscript not using gradle resolve dependencies ❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️👍👍👍👍👍👍

wuseal commented 2 years ago

Sorry @holgerbrandl , This is my problem, The error report in IDEA, not from the kscript, I change the IDEA's project's gradle version to 6.9.1 then it works.