-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kscript environment variable substitution for repositories no longer works #402
Comments
Please explain what you mean by "variable substitution for repositories no longer works"? Is it a user code problem or in kscript itself? |
@aartiPl Substitution of environment variables for the username and password components of a repository is a documented feature of kscript. See Lines 419 to 422 in 1c97c21
I've submitted PR #403 to illustrate the two issues I have identified. You will note that both test 4 and test 5 currently fail. Test 4 is at the moment a documentation problem -- the initial implementation of this in kscript used Test 5 illustrates an issue with packaging scripts that use custom auth with env vars. I'm not sure this ever worked. For test 4, the call to the relevant code is kscript/src/main/kotlin/io/github/kscripting/kscript/resolver/DependencyResolver.kt Line 32 in 1c97c21
For test 5, the relevant code is kscript/src/main/kotlin/io/github/kscripting/kscript/code/GradleTemplates.kt Lines 109 to 114 in 1c97c21
|
I submitted 3 PRs to resolve this. Please review. |
The approach I took was to move kscript in a way compatible with Kotlin scripting. An alternate approach would be to keep the syntax as |
Ok, I see. Your approach to changing templates from {{}} to '$' makes sense to me. The only drawback I see now is that IntelliJ will try to resolve a local variable when it finds '$'. So in the code, it will be necessary to escape '$' with a backslash, or IntelliJ will complain about the non-existing variable. Have you tried it? How does it work? Should we escape '$' or not? Regarding the implementation. There is already a code resolving username and password. It is in SectionResolver: The resolution of the URL, username, and password should happen there. I think that the best algorithm would be (for all three parameters):
Please merge all 3 PRs into only one; it's much easier for me to test and review. Also, please write at least a simple Unit Test. And thanks for your great work! 👍 |
Kotlin script appears to require it be unescaped i.e. it reads it as a literal value. Adding the escape bypasses Kotlin script's var resolution. While we will now do the parsing for this before it ever gets to Kotlin Script and could change this behavior, I suggest we stay compatible to the syntax used in Kotlin Script. IDEA will likely be updated at some point to correctly interpret the
Ok.
One tweak to this which will be more powerful as it allows environment variables to compose from properties, and also easier to implement: 2. After env variable resolution, if the name is one of the KSCRIPT_REPOSITORY_* names, then we should use those names as they are now
Done. PR submitted for all these changes #406. |
In kscript 4.2.2, environment variable substitution for repositories no longer works.
The first problem is that the syntax is no longer
{{FOO}}
-- since the backend is now kotlin scripting, the syntax is now$FOO
. SeeMavenDependenciesResolver.addRepository
.Once that is fixed, the next problem is that the gradle script that kscript writes and executes for
--package
contains the literal values$FOO
, ascreateGradleRepositoryCredentials
uses the raw values set for user and password rather than the resolved values.The text was updated successfully, but these errors were encountered: