diff --git a/src/main/kotlin/scientifik/ScientifikJVMPlugin.kt b/src/main/kotlin/scientifik/ScientifikJVMPlugin.kt index 89a4777..c84ba7b 100644 --- a/src/main/kotlin/scientifik/ScientifikJVMPlugin.kt +++ b/src/main/kotlin/scientifik/ScientifikJVMPlugin.kt @@ -17,7 +17,6 @@ open class ScientifikJVMPlugin : Plugin { with(project) { plugins.apply("org.jetbrains.kotlin.jvm") - plugins.apply("maven-publish") repositories.applyRepos() @@ -49,38 +48,43 @@ open class ScientifikJVMPlugin : Plugin { from(sourceSet.kotlin.srcDirs.first()) } - configure { - publications { - register("jvm", MavenPublication::class) { - from(components["java"]) - artifact(sourcesJar.get()) + pluginManager.withPlugin("maven-publish") { + + configure { + publications { + register("jvm", MavenPublication::class) { + from(components["java"]) + artifact(sourcesJar.get()) + } + } + } + + pluginManager.withPlugin("org.jetbrains.dokka") { + val dokka by tasks.getting(DokkaTask::class) { + outputFormat = "html" + outputDirectory = "$buildDir/javadoc" + } + + val kdocJar by tasks.registering(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + dependsOn(dokka) + archiveClassifier.set("javadoc") + from("$buildDir/javadoc") + } + + configure { + publications { + getByName("jvm") { + this as MavenPublication + artifact(kdocJar.get()) + } + } } } } } - pluginManager.withPlugin("org.jetbrains.dokka") { - val dokka by tasks.getting(DokkaTask::class) { - outputFormat = "html" - outputDirectory = "$buildDir/javadoc" - } - val kdocJar by tasks.registering(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - dependsOn(dokka) - archiveClassifier.set("javadoc") - from("$buildDir/javadoc") - } - - configure { - publications { - getByName("jvm") { - this as MavenPublication - artifact(kdocJar.get()) - } - } - } - } } diff --git a/src/main/kotlin/scientifik/ScientifikMPPlugin.kt b/src/main/kotlin/scientifik/ScientifikMPPlugin.kt index a5e4332..1362d44 100644 --- a/src/main/kotlin/scientifik/ScientifikMPPlugin.kt +++ b/src/main/kotlin/scientifik/ScientifikMPPlugin.kt @@ -82,7 +82,7 @@ open class ScientifikMPPlugin : Plugin { val dokka by tasks.getting(DokkaTask::class) { outputFormat = "html" outputDirectory = "$buildDir/javadoc" - multiplatform{ + multiplatform { } } @@ -94,13 +94,15 @@ open class ScientifikMPPlugin : Plugin { from("$buildDir/javadoc") } - configure { + pluginManager.withPlugin("maven-publish") { + configure { - targets.all { - val publication = publications.findByName(name) as MavenPublication + targets.all { + val publication = publications.findByName(name) as MavenPublication - // Patch publications with fake javadoc - publication.artifact(kdocJar.get()) + // Patch publications with fake javadoc + publication.artifact(kdocJar.get()) + } } } } diff --git a/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt b/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt index f8d635d..250280d 100644 --- a/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt +++ b/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt @@ -120,7 +120,7 @@ open class ScientifikPublishPlugin : Plugin { if (bintrayRepo == null) { project.logger.warn("[${project.name}] Bintray repository not defined") } else { - + project.logger.info("Adding bintray publishing to project [${project.name}]") project.configure { repositories { maven("https://bintray.com/mipt-npm/$bintrayRepo") @@ -143,14 +143,16 @@ open class ScientifikPublishPlugin : Plugin { setLicenses("Apache-2.0") vcsUrl = vcs version.apply { - name = project.version.toString() - vcsTag = project.version.toString() - released = java.util.Date().toString() + this.name = project.version.toString() + this.vcsTag = project.version.toString() + this.released = java.util.Date().toString() } } //workaround bintray bug - setPublications(*project.extensions.findByType()!!.publications.names.toTypedArray()) + afterEvaluate { + setPublications(*project.extensions.findByType()!!.publications.names.toTypedArray()) + } } } }