You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.5 KiB
113 lines
3.5 KiB
import groovy.io.FileType
|
|
import org.jetbrains.CorrectShadowPublishing
|
|
import org.jetbrains.CrossPlatformExec
|
|
|
|
import java.nio.file.Files
|
|
import java.nio.file.StandardCopyOption
|
|
|
|
apply plugin: 'kotlin'
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
sourceCompatibility = 1.8
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
|
kotlinOptions {
|
|
freeCompilerArgs += "-Xjsr305=strict"
|
|
languageVersion = "1.2"
|
|
apiVersion = languageVersion
|
|
jvmTarget = "1.8"
|
|
}
|
|
}
|
|
|
|
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"
|
|
shadow "com.github.olivergondza:maven-jdk-tools-wrapper:0.1"
|
|
}
|
|
|
|
task generatePom() {
|
|
inputs.file(new File(projectDir, "pom.tpl.xml"))
|
|
inputs.property("dokka_version", dokka_version)
|
|
inputs.property("maven_version", maven_version)
|
|
inputs.property("maven_plugin_tools_version", maven_plugin_tools_version)
|
|
outputs.file(new File(buildDir, "pom.xml"))
|
|
doLast {
|
|
final pomTemplate = new File(projectDir, "pom.tpl.xml")
|
|
final pom = new File(buildDir, "pom.xml")
|
|
pom.text = pomTemplate.text.replace("<version>dokka_version</version>", "<version>$dokka_version</version>")
|
|
.replace("<maven.version></maven.version>", "<maven.version>$maven_version</maven.version>")
|
|
.replace("<version>maven-plugin-plugin</version>", "<version>$maven_plugin_tools_version</version>")
|
|
}
|
|
}
|
|
|
|
task mergeClassOutputs doLast {
|
|
def sourceDir = new File(buildDir, "classes/kotlin")
|
|
def targetDir = new File(buildDir, "classes/java")
|
|
|
|
sourceDir.eachFileRecurse FileType.ANY, {
|
|
def filePath = it.toPath()
|
|
def targetFilePath = targetDir.toPath().resolve(sourceDir.toPath().relativize(filePath))
|
|
if (it.isFile()) {
|
|
Files.move(filePath, targetFilePath, StandardCopyOption.REPLACE_EXISTING)
|
|
} else if (it.isDirectory()) {
|
|
targetFilePath.toFile().mkdirs()
|
|
}
|
|
}
|
|
}
|
|
|
|
task pluginDescriptor(type: CrossPlatformExec) {
|
|
workingDir buildDir
|
|
commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor'
|
|
|
|
dependsOn mergeClassOutputs
|
|
}
|
|
|
|
task helpMojo(type: CrossPlatformExec) {
|
|
workingDir buildDir
|
|
commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo'
|
|
|
|
dependsOn mergeClassOutputs
|
|
}
|
|
|
|
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) { MavenPublication publication ->
|
|
artifactId = 'dokka-maven-plugin'
|
|
|
|
artifact sourceJar {
|
|
classifier "sources"
|
|
}
|
|
|
|
CorrectShadowPublishing.configure(publication, project)
|
|
}
|
|
}
|
|
}
|
|
|
|
bintrayPublication(project, ['dokkaMavenPlugin'])
|