How to add Freemarker to Plugin? (gradle)

Answered

Hi,

i want to use Freemarker to parse templates in my plugin.

But i cant get into my project.

a) first i added as library and then as moduls -> but on build it could not find the reference

b) i added to build.gradle.kts -> but it wasnt found in any of the sources

id("org.freemarker.freemarker") version "2.3.14"
4 comments
Comment actions Permalink

Please post the full snippet of your build.gradle.kts, not just a single line

0
Comment actions Permalink
...
plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.5.0"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "0.6.3"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "0.6.2"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.14.2"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "9.4.1"

id("org.freemarker.freemarker") version "2.3.14"
}
...

// Configure project's dependencies
repositories {
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.14.2")
implementation(kotlin("stdlib-jdk8"))
}
...
0
Comment actions Permalink

You must use "dependencies" block, not "plugins" which defines plugins for Gradle build itself. https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_dependency_management_overview

1
Comment actions Permalink

Thanks...this works for me.

I use an local Dir with a jar and renamed the jar "freemarker.ar" into "2.3.31.jar"


// Configure project's dependencies
repositories {
mavenCentral()
jcenter()
flatDir{
dirs("<YOUR_DIR>/apache-freemarker-2.3.31-bin/")
}
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.14.2")
implementation("org.freemarker.freemarker:2.3.31")
implementation(kotlin("stdlib-jdk8"))
}
0

Please sign in to leave a comment.