Last active
August 23, 2019 13:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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