question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add gradle plugin configuration example with Kotlin script

See original GitHub issue

Please add Kotlin script equivalent code. Currently it is only in the Groovy:

import gg.jte.ContentType
import java.nio.file.Paths

plugins {
    id 'java'
    id 'gg.jte.gradle' version '${jte.version}'
}

dependencies {
    implementation('gg.jte:jte:${jte.version}')
}

tasks.precompileJte {
    sourceDirectory = Paths.get(project.projectDir.absolutePath, "src", "main", "jte")
    targetDirectory = Paths.get(project.projectDir.absolutePath, "jte-classes")
    compilePath = sourceSets.main.runtimeClasspath
    contentType = ContentType.Html
}

tasks.precompileJte {
    dependsOn(tasks.compileJava)
}

tasks.test {
    dependsOn(tasks.precompileJte)
}

Struggling with converting this part to Kotlin:

tasks.precompileJte {
    sourceDirectory = Paths.get(project.projectDir.absolutePath, "src", "main", "jte")
    targetDirectory = Paths.get(project.projectDir.absolutePath, "jte-classes")
    compilePath = sourceSets.main.runtimeClasspath
    contentType = ContentType.Html
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanPizhenkocommented, Feb 20, 2021

So here is what I ended up with:

plugin {
  id("gg.jte.gradle") version("1.6.0")
}

tasks.precompileJte {
  sourceDirectory = Path.of(project.projectDir.absolutePath, "src", "main", "jte")
  targetDirectory = Path.of(project.projectDir.absolutePath, "build", "resources", "main")
  compilePath = project.the<SourceSetContainer>()["main"].runtimeClasspath
  contentType = gg.jte.ContentType.Html
  shouldRunAfter(tasks.compileKotlin)
}

tasks.test {
  dependsOn(tasks.precompileJte)
}

You may post this one into docs, but edit sourceDirectory and targetDirectory to match your Groovy example, because I have a bit different ones.

1reaction
IvanPizhenkocommented, Feb 20, 2021

What a mess this is. And people complain about maven’s XML structure - lol.

Definitely, this is better and shorter mess than Maven.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developing Custom Gradle Plugins
In our examples, we are going to use Java as the implementation language for standalone plugin project and Groovy or Kotlin in the...
Read more >
Configure a Gradle project - Kotlin
To build a Kotlin project with Gradle, you need to add the Kotlin Gradle plugin to your build script file build.gradle(.kts) and configure...
Read more >
How to write a Gradle plugin in Kotlin | by Rui Rosario - Medium
The first enables the Gradle Dependency Injection capabilities — in our case it injects the name of the configuration to use for our...
Read more >
The New Way of Writing Build Gradle with Kotlin DSL
the basic thing when you change Gradle using Kotlin script is the use of single-quotes to double-quotes. For minSdkVersion and targetSdkVersion is function...
Read more >
How to Create Gradle Plugin in Kotlin - Droids On Roids
There are many tutorials about writing custom Gradle plugins on the Internet. For example this official one. However, most of them use Groovy ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found