Skip to content
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

Improve Kotlin DSL Support #17

Closed
Legion2 opened this issue Jan 13, 2022 · 8 comments
Closed

Improve Kotlin DSL Support #17

Legion2 opened this issue Jan 13, 2022 · 8 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Legion2
Copy link

Legion2 commented Jan 13, 2022

The gitlab extension cannot directly be used in build.gradle.kts files, configure<>() must be used. also the dls function which get a class type as argument should support kotlin reified type parameter.

@aepfli aepfli added the enhancement New feature or request label Jan 13, 2022
@aepfli
Copy link
Owner

aepfli commented Jan 13, 2022

Thank you, and i also have to apologize for the rather poor kotlin support so far. Just to be on the save side - i am curious what exactly would be the desired outcome :) - always easier to meet expectations with examples.

currently i am testing against https://github.com/aepfli/gradle-gitlab-repositories/blob/main/src/functionalTest/resources/build.gradle.kts

what would be the desired look of it? i will try to take care of this as soon as possible (also the tokens are currently reworked, just had no time to merge it so far :), it should increase the usability for tokens at least like https://github.com/aepfli/gradle-gitlab-repositories/blob/a5de003f8a7515043b1d8025c9346d61a7bb61f3/src/functionalTest/resources/build.gradle.kts)

@aepfli
Copy link
Owner

aepfli commented Jan 13, 2022

something like this?

gitLab {
   tokens {
      create("tokenIgnoredNoValue") {
          type.set("private")
          value.set("")
      }
   }
}

or

gitLabTokens {
      create("tokenIgnoredNoValue") {
          type.set("private")
          value.set("")
      }
   }

@Legion2
Copy link
Author

Legion2 commented Jan 13, 2022

Yes, your examples look good. Maybe the type is a second parameter in the create function, because it must always be provided. This parameter could also be optional and set in the action block.

I also encountered a problem when I tried to configure the repositories for all projects or all subprojects using the allprojects {} subprojects {} blocks in the root project. I applied and configured the plugin in the settings.gradle.kts:

plugins {
    id("at.schrottner.gitlab-repositories") version "0.5.0"
}

and then tried to use val gitLab = the<at.schrottner.gradle.GitlabRepositoriesExtension>() in the subprojects.repositories block and get Extension of type 'GitlabRepositoriesExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension] error. If I apply the plugin also in the sub projects I get Cannot add extension with name 'gitLab', as there is an extension already registered with that name.

@Legion2
Copy link
Author

Legion2 commented Jan 17, 2022

@aepfli should I open a second issue for my problems with allprojects and subprojects?

@aepfli
Copy link
Owner

aepfli commented Jan 17, 2022

i think this would be a good idea - to keep those separate and reduce the amount of changes for one.

Just as a headsup - i am currently a little bit short on free time, so i will be most likely end of january february that i can start on those topics. but i will try my best to squeeze them in earlier - at least i will focus on Tests first, so somebody can work easier on them.

Thank you for the input!

@Legion2
Copy link
Author

Legion2 commented Jan 23, 2022

I created #19

@aepfli aepfli added the help wanted Extra attention is needed label Jan 24, 2022
@aepfli
Copy link
Owner

aepfli commented Jan 27, 2022

in the first iteration i removed the classes and we do have strings now, for easier handling

@Legion2
Copy link
Author

Legion2 commented Mar 11, 2022

I tested 0.6.1 and the following works in the gradle.build.kts:

plugins {
    id("at.schrottner.gitlab-repositories") version "0.6.1"
}

gitLab {
    token("private") {
        val gitLabPrivateToken: String? by project
        key = "gitLabPrivateToken"
        value = gitLabPrivateToken
    }
}

I will close this, because all my points of the kotlin support are improved.

@Legion2 Legion2 closed this as completed Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants