diff --git a/build.gradle.kts b/build.gradle.kts index d43c267..cee3a27 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "scientifik" -version = "0.1.0" +version = "0.1.1" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt b/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt index 328f2e1..5e836d4 100644 --- a/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt +++ b/src/main/kotlin/scientifik/ScientifikPublishPlugin.kt @@ -38,54 +38,57 @@ open class ScientifikPublishPlugin : Plugin { project.plugins.apply("maven-publish") val extension = project.extensions.create("scientifik") - val bintrayRepo = project.bintrayRepo - val vcs = project.vcs + project.afterEvaluate { - if (bintrayRepo == null || vcs == null) { - project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") - } + val bintrayRepo = project.bintrayRepo + val vcs = project.vcs - project.configure { - repositories { - maven("https://bintray.com/mipt-npm/$bintrayRepo") + if (bintrayRepo == null || vcs == null) { + project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") + return@afterEvaluate } - // Process each publication we have in this project - publications.filterIsInstance().forEach { publication -> + project.configure { + repositories { + maven("https://bintray.com/mipt-npm/$bintrayRepo") + } - @Suppress("UnstableApiUsage") - publication.pom { - name.set(project.name) - description.set(project.description) - url.set(vcs) + // Process each publication we have in this project + publications.filterIsInstance().forEach { publication -> - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } - } - developers { - developer { - id.set("MIPT-NPM") - name.set("MIPT nuclear physics methods laboratory") - organization.set("MIPT") - organizationUrl.set("http://npm.mipt.ru") - } - - } - scm { + @Suppress("UnstableApiUsage") + publication.pom { + name.set(project.name) + description.set(project.description) url.set(vcs) + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + developers { + developer { + id.set("MIPT-NPM") + name.set("MIPT nuclear physics methods laboratory") + organization.set("MIPT") + organizationUrl.set("http://npm.mipt.ru") + } + + } + scm { + url.set(vcs) + } } } } - } - if (extension.kdoc) { - project.plugins.apply("org.jetbrains.dokka") + if (extension.kdoc) { + project.plugins.apply("org.jetbrains.dokka") + - project.afterEvaluate { extensions.findByType()?.apply { val dokka by tasks.getting(DokkaTask::class) { outputFormat = "html" @@ -165,69 +168,70 @@ open class ScientifikPublishPlugin : Plugin { } } } + } - } - project.plugins.apply("com.jfrog.bintray") + project.plugins.apply("com.jfrog.bintray") - project.configure { - user = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER") - key = project.findProperty("bintrayApiKey") as? String? ?: System.getenv("BINTRAY_API_KEY") - publish = true - override = true // for multi-platform Kotlin/Native publishing + project.configure { + user = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER") + key = project.findProperty("bintrayApiKey") as? String? ?: System.getenv("BINTRAY_API_KEY") + publish = true + override = true // for multi-platform Kotlin/Native publishing - // We have to use delegateClosureOf because bintray supports only dynamic groovy syntax - // this is a problem of this plugin - pkg.apply { - userOrg = "mipt-npm" - repo = bintrayRepo - name = project.name - issueTrackerUrl = "${vcs}/issues" - setLicenses("Apache-2.0") - vcsUrl = vcs - version.apply { - name = project.version.toString() - vcsTag = project.version.toString() - released = java.util.Date().toString() + // We have to use delegateClosureOf because bintray supports only dynamic groovy syntax + // this is a problem of this plugin + pkg.apply { + userOrg = "mipt-npm" + repo = bintrayRepo + name = project.name + issueTrackerUrl = "${vcs}/issues" + setLicenses("Apache-2.0") + vcsUrl = vcs + version.apply { + name = project.version.toString() + vcsTag = project.version.toString() + released = java.util.Date().toString() + } } - } - //workaround bintray bug - project.afterEvaluate { + //workaround bintray bug + setPublications(*project.extensions.findByType()!!.publications.names.toTypedArray()) - } + // project.tasks.figetByPath("bintrayUpload") { // dependsOn(publishToMavenLocal) // } - } + } - project.plugins.apply("com.jfrog.artifactory") + project.plugins.apply("com.jfrog.artifactory") - project.configure { - val artifactoryUser: String? by project - val artifactoryPassword: String? by project - val artifactoryContextUrl = "http://npm.mipt.ru:8081/artifactory" + project.configure { + val artifactoryUser: String? by project + val artifactoryPassword: String? by project + val artifactoryContextUrl = "http://npm.mipt.ru:8081/artifactory" - setContextUrl(artifactoryContextUrl)//The base Artifactory URL if not overridden by the publisher/resolver - publish(delegateClosureOf { - repository(delegateClosureOf { - setProperty("repoKey", "gradle-dev-local") - setProperty("username", artifactoryUser) - setProperty("password", artifactoryPassword) + setContextUrl(artifactoryContextUrl)//The base Artifactory URL if not overridden by the publisher/resolver + publish(delegateClosureOf { + repository(delegateClosureOf { + setProperty("repoKey", "gradle-dev-local") + setProperty("username", artifactoryUser) + setProperty("password", artifactoryPassword) + }) + + defaults(delegateClosureOf { + invokeMethod("publications", arrayOf("jvm", "js", "kotlinMultiplatform", "metadata")) + }) }) - - defaults(delegateClosureOf { - invokeMethod("publications", arrayOf("jvm", "js", "kotlinMultiplatform", "metadata")) + resolve(delegateClosureOf { + repository(delegateClosureOf { + setProperty("repoKey", "gradle-dev") + setProperty("username", artifactoryUser) + setProperty("password", artifactoryPassword) + }) }) - }) - resolve(delegateClosureOf { - repository(delegateClosureOf { - setProperty("repoKey", "gradle-dev") - setProperty("username", artifactoryUser) - setProperty("password", artifactoryPassword) - }) - }) + } } } } \ No newline at end of file