-
Notifications
You must be signed in to change notification settings - Fork 124
Add support for @file:MavenCredentials() annotation #214
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
Add support for @file:MavenCredentials() annotation #214
Conversation
Thanks. However, didn't we agree that it would be better style to put them into a config as described in #143. What about testing? Is there a public repo we could use for regression testing? In general I think it might be better to add optional parameters to @mavenrepository in https://github.com/holgerbrandl/kscript-annotations/blob/master/src/main/kotlin/ScriptDirectives.kt#L47 With your the current impl, we could for instance not have differing credentials for multiple repos in the same script. |
Since I wanted to use the credentials from our Build environment and have the credentials be passed, but not be saved, I thought it would be a better solution to set the properties through environment variables in the script directly. I think having the option to use either saved credentials through a config or through direct credentials would be ideal.
I am unsure how we could test this other then verifying we pass the right config to aether as I did in the unittests. I tested it from my own environment of course, but I can do some research if there is some public repository that requires credentials for you/others to test on.
I tried that first, but found it rather ugly passing 4 unnamed string-parameters. And since the Maven xml settings require a
That is true, but is also true for the maven implementation. Unless I missed something in the maven implementation of course. |
So I searched around, but I couldn't find a publicly available test-artifactory or anything similar we could use. So in my opinion we have three options:
Option 3 would be best in my opinion, but is also harder to maintain and would make the travis-tests really slow. I don't know if this is acceptable in your view. |
I think using environment properties for the build environment is another feature (and should imho be a different PR). Let's focus on the annoations first if this fine with you. You can have named annoations arguments in kotlin, so we can do
which is legit and much more elegant compared to having the credentials free-floating around and being ambiguous. To build a complete PR, we/you need to also adjust https://github.com/holgerbrandl/kscript-annotations accordingly for correct tooling and completion. Actually this must be the first step otherwise kscript will not compile the user-script. (... which makes me curious how you tested the PR in the first place?). For testing optio 3 may work because we could simply use a dockerized artifactory in travis. But this would be a lot of work. So maybe we start withmanual tests (option 1) which are based on some docker-artifcatory which the developer would need to launch manually. I'd take care of the travis-ci inclusion later. Does this sound reasonable to you? |
6a21ae1
to
fba256b
Compare
I did not know about the named annotations arguments. That is way more elegant! I rewrote my PR to use the named arguments as you suggested, and added a PR in kscript-annotations as well: kscripting/kscript-annotations#1
I could test the resolving of the dependencies and their download with credentials through my company's Artifactory, but the missing annotation made the compiling of the script fail after the download of course.
I agree and will write a manual testing how-to next. P.S. The build fails because I updated the version to |
I've updated and released the annotations v1.3. Could you test your PR against it or should it work already? Please note that I have changed Since I have no pw-protected repo at my disposal, I'd be glad if you could outline how I could spin one up via docker or use public one (with some secret credentials which would not go into this repo). I think we're on a very good track here. :-) |
fba256b
to
d87fa26
Compare
Spinning up an Artifactory instance with credential-protected Artifacts, that works without manual configuration was more of a pain than I realized, but I got it to work. I put a description and the relevant commands, with some reference links in the test/TestReadme.md. The description is almost a script already, so hopefully you can integrate it in your automatic tests without to much additional work. |
6dcc05c
to
2dd4afa
Compare
Two of the tests fail, because the
|
The problem appears to be a missing annotation. Created PR: kscripting/kscript-annotations#2 |
Fixed issue with kscript-annotations. The new version is v1.4 as suggested in your PR. |
The adding credentials with the following syntax is supported through this commit: @file:MavenRepository("id", "url", user="username", password="password") A descripting of how to test it is added under test/TestsReadme.md
2dd4afa
to
240693c
Compare
I upgraded the kscript-annotations to 1.4 and it all seems to work now. |
Could you take a little time to check this PR? I'd like to use this in our Build-Environment and currently have to ask my Devs to patch their installation locally. |
Sorry for the delay. I plan to work on it this weekend if my wife allows it. :-) |
Is there anything I can do to speed this up? It would be really useful for us to be able to reference internal libraries in scripts |
Thanks for your patience and even more so for providing this great PR. The provided manual test instructions worked well for me, all tests seemed fine, so I've merged the PR and released it in v2.8.0. |
I've added rudimentary support for supplying credentials to a MavenRepository.
The basic usage is to define a new Annotation
@file:MavenCredentials()
supplying anid
, ausername
and apassword
. The credentials are then applied on allMavenRepository
definitions that have the same ID. Analog to how Maven links the credentials to repositories.This fixes #143
The Annotation needs to be added to https://github.com/holgerbrandl/kscript-annotations to make the scripts compile. The download already runs successfully.