Skip to content

Instantly share code, notes, and snippets.

@barlog-m
Last active August 23, 2019 13:33
Show Gist options
  • Save barlog-m/3af849da2478441c105fcf35bfa809a2 to your computer and use it in GitHub Desktop.
Save barlog-m/3af849da2478441c105fcf35bfa809a2 to your computer and use it in GitHub Desktop.
Gradle Kotlin DSL generatePom task for create minimal pom.xml to use with eclipse.jdt.ls
import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer.COMPILE
import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer.PROVIDED
val javaVer = JavaVersion.VERSION_12
tasks {
task("generatePom") {
doLast {
maven.conf2ScopeMappings.apply {
addMapping(0, configurations.getByName("implementation"), COMPILE)
addMapping(0, configurations.getByName("compileOnly"), PROVIDED)
}
maven.pom {
withGroovyBuilder {
"project" {
"build" {
"plugins" {
"plugin" {
setProperty("artifactId", "maven-compiler-plugin")
setProperty("version", "3.8.1")
"configuration" {
setProperty("compilerVersion", "$javaVer")
setProperty("source", "$javaVer")
setProperty("target", "$javaVer")
}
}
}
}
}
}
}.writeTo("pom.xml")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment