-
Notifications
You must be signed in to change notification settings - Fork 71
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
Comments
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 :) |
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? |
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 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 |
I wanna give this a try. 😁 |
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 |
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.
The text was updated successfully, but these errors were encountered: