diff options
-rw-r--r-- | gradle.properties | 4 | ||||
-rw-r--r-- | runners/maven-plugin/build.gradle | 45 |
2 files changed, 34 insertions, 15 deletions
diff --git a/gradle.properties b/gradle.properties index 44e510d6..4d4e40ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,11 +8,11 @@ kotlin_for_gradle_version=1.0.7 ant_version=1.9.6 #Maven plugin dependencies -maven_version=3.0.5 +maven_version=3.5.0 maven_archiver_version=2.5 plexus_utils_version=3.0.22 plexus_archiver_version=3.4 -maven_plugin_tools_version=3.4 +maven_plugin_tools_version=3.5 #For CI mvn=mvn
\ No newline at end of file diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle index bac05b2b..37a79a69 100644 --- a/runners/maven-plugin/build.gradle +++ b/runners/maven-plugin/build.gradle @@ -1,14 +1,18 @@ -import groovy.xml.QName +import groovy.io.FileType import org.jetbrains.CrossPlatformExec +import shadow.org.apache.commons.io.FileUtils + +import java.nio.file.FileVisitResult +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.nio.file.attribute.BasicFileAttributes + apply plugin: 'kotlin' apply plugin: 'com.github.johnrengelman.shadow' -tasks.withType(AbstractCompile) { - classpath += configurations.shadow -} - dependencies { shadow project(":runners:fatjar") shadow "org.apache.maven:maven-core:$maven_version" @@ -28,14 +32,33 @@ task ("generatePom") doLast { .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 @@ -67,6 +90,8 @@ publishing { classifier "sources" } + project.shadow.component(publication) + pom.withXml { Node root = asNode() @@ -81,7 +106,7 @@ publishing { ''') root.children().find { - return ((QName) it.name()).qualifiedName == "dependencies" + return it.name() == "dependencies" }.append(dependency) def profiles = new XmlParser().parseText(''' @@ -115,14 +140,8 @@ publishing { root.append(profiles) } - project.shadow.component(publication) - } - } -} - -tasks.withType(GenerateMavenPom) { Task generatePom -> - generatePom.doLast { + } } } |