import groovy.xml.QName
import org.jetbrains.CrossPlatformExec
apply plugin: 'kotlin'
apply plugin: 'com.github.johnrengelman.shadow'
configurations {
provided
}
tasks.withType(AbstractCompile) {
classpath += configurations.provided
classpath += configurations.shadow
}
dependencies {
shadow project(":runners:fatjar")
shadow "org.apache.maven:maven-core:$maven_version"
shadow "org.apache.maven:maven-model:$maven_version"
shadow "org.apache.maven:maven-plugin-api:$maven_version"
shadow "org.apache.maven:maven-archiver:$maven_archiver_version"
shadow "org.codehaus.plexus:plexus-utils:$plexus_utils_version"
shadow "org.codehaus.plexus:plexus-archiver:$plexus_archiver_version"
shadow "org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version"
}
task generatePom << {
final pomTemplate = new File(projectDir, "pom.tpl.xml")
final pom = new File(buildDir, "pom.xml")
pom.text = pomTemplate.text.replace("dokka_version", "$dokka_version")
.replace("", "$maven_version")
.replace("maven-plugin-plugin", "$maven_plugin_tools_version")
}
task pluginDescriptor(type: CrossPlatformExec) {
workingDir buildDir
commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor'
}
task helpMojo(type: CrossPlatformExec) {
workingDir buildDir
commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo'
}
helpMojo.dependsOn generatePom
sourceSets.main.java.srcDir("$buildDir/generated-sources/plugin")
compileJava.dependsOn helpMojo
pluginDescriptor.dependsOn generatePom
shadowJar {
baseName = 'dokka-maven-plugin'
classifier = ''
}
shadowJar.dependsOn pluginDescriptor
task sourceJar(type: Jar) {
from sourceSets.main.allSource
}
apply plugin: 'maven-publish'
publishing {
publications {
dokkaMavenPlugin(MavenPublication) {
from components.shadow
artifactId = 'dokka-maven-plugin'
artifact sourceJar {
classifier "sources"
}
pom.withXml {
Node root = asNode()
def dependency = new XmlParser().parseText('''
com.sun
tools
1.8.0
system
${toolsjar}
''')
root.children().find {
return ((QName) it.name()).qualifiedName == "dependencies"
}.append(dependency)
def profiles = new XmlParser().parseText('''
default-profile
true
${java.home}/../lib/tools.jar
${java.home}/../lib/tools.jar
mac-profile
false
${java.home}/../Classes/classes.jar
${java.home}/../Classes/classes.jar
''')
root.append(profiles)
}
}
}
}
tasks.withType(GenerateMavenPom) { Task generatePom ->
generatePom.doLast {
}
}
bintrayPublication(project, ['dokkaMavenPlugin'])