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

Convert buildSrc/build.gradle to Kotlin #282

Open
Bukama opened this issue Jun 20, 2020 · 5 comments
Open

Convert buildSrc/build.gradle to Kotlin #282

Bukama opened this issue Jun 20, 2020 · 5 comments

Comments

@Bukama
Copy link
Member

Bukama commented Jun 20, 2020

In #262 we provided a buildSrc/build.gradle script to add IDE specific support for IntelliJ.

This should be converted to Kotlin as the build.gradle.kts script in root folder.

@aepfli
Copy link
Member

aepfli commented Jul 13, 2020

are we sure about that? i know that we use kotlin in the other scripts - but groovy has its peaks, and in this case, as we are manipulating XML it is way easier to do that with groovy and the DSL for that. Yes we can exclude it into own tasks, but i am not sure it is really worth the effort. maybe the linked tasks of #262 will be soon resolved or there will be a different way. But implementation wise, it will (imho) never be as clean as it is with groovy.

The only thing i could think of, is extracting this into own tasks written in groovy, but i am not sure about this :)

@Bukama
Copy link
Member Author

Bukama commented Jul 14, 2020

The topic came up at @nicolaiparlog Midsummer Hackathon and the idea was to align the Gradle scripts to one language. As I don't know much about Gradle: Gradle supports both: Kotlin and Groovy, right?

@aepfli
Copy link
Member

aepfli commented Jul 14, 2020

yes, but gradle and kotlin are quiet different in their nature and DSL support. I did not find a nice way to manipulate XML with kotlin

kotlin

    val xmlFile = File("file.xml")
 
    val dbFactory = DocumentBuilderFactory.newInstance()
    val dBuilder = dbFactory.newDocumentBuilder()
    val xmlInput = InputSource(StringReader(xmlFile.readText()))
    val doc = dBuilder.parse(xmlInput)

groovy

def xmlFile = new File("file.xml")
def xml = new XmlSlurper().parse(xmlFile)

and that is just reading - when manipulating it, it gets more and more complicated in kotlin. in groovy i can just access the element with their tag name like xml.element and i even can easier maniuplate it, and/or search through all of them.

It is just way easier to manipulate the xml in groovy as in kotlin. But as said, maybe we want to just extract the script than into a groovy script and apply it in the build.gradle

@nipafx
Copy link
Member

nipafx commented Oct 27, 2020

I wanna give this a try. 😁

@nipafx nipafx self-assigned this Oct 27, 2020
@Bukama Bukama added this to Next up in Exploring Io Oct 27, 2020
@nipafx nipafx removed their assignment Feb 28, 2021
@Bukama Bukama added this to Ready to get started in Up for grabs... Apr 13, 2021
@nipafx nipafx removed this from Next up in Exploring Io May 4, 2021
@keturn
Copy link

keturn commented May 4, 2021

Hmm, yeah, if you only have a single function in there and it's using Groovy's XmlSlurper, there's not really a pressing argument to convert it to Kotlin.

Ideally this would be supported by gradle-idea-ext and then you wouldn't have to have this code that makes assumptions about some other application's internal storage format. Sounds like you've already looked in to that: JetBrains/gradle-idea-ext-plugin#88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Up for grabs...
Ready to get started
Development

No branches or pull requests

4 participants