New deploy model

This commit is contained in:
Alexander Nozik 2020-03-09 13:06:40 +03:00
parent e00642bb34
commit 50020082a8
3 changed files with 44 additions and 74 deletions

View File

@ -7,7 +7,7 @@ plugins {
} }
group = "scientifik" group = "scientifik"
version = "0.3.2" version = "0.4.0"
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
@ -16,7 +16,7 @@ repositories {
maven("https://dl.bintray.com/kotlin/kotlin-eap") maven("https://dl.bintray.com/kotlin/kotlin-eap")
} }
val kotlinVersion = "1.3.61" val kotlinVersion = "1.3.70"
java { java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@ -26,11 +26,8 @@ java {
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.2")
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.1") implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1")
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.10.0")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.10.0")
} }
gradlePlugin { gradlePlugin {

View File

@ -2,9 +2,7 @@
* Build constants * Build constants
*/ */
object Scientifik { object Scientifik {
const val ioVersion = "0.1.15" const val coroutinesVersion = "1.3.4"
const val coroutinesVersion = "1.3.3" const val serializationVersion = "0.20.0"
const val atomicfuVersion = "0.14.1"
const val serializationVersion = "0.14.0"
const val JVM_VERSION = "11" const val JVM_VERSION = "11"
} }

View File

@ -1,14 +1,14 @@
package scientifik package scientifik
import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
open class ScientifikPublishPlugin : Plugin<Project> { open class ScientifikPublishPlugin : Plugin<Project> {
@ -18,12 +18,6 @@ open class ScientifikPublishPlugin : Plugin<Project> {
project.plugins.apply("maven-publish") project.plugins.apply("maven-publish")
project.run { project.run {
val bintrayRepo = if (project.version.toString().contains("dev")) {
"dev"
} else {
findProperty("bintrayRepo") as? String
}
val githubProject = findProperty("githubProject") as? String val githubProject = findProperty("githubProject") as? String
val vcs = findProperty("vcs") as? String val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/mipt-npm/$it" } ?: githubProject?.let { "https://github.com/mipt-npm/$it" }
@ -33,11 +27,9 @@ open class ScientifikPublishPlugin : Plugin<Project> {
return@apply return@apply
} }
project.plugins.apply("com.jfrog.bintray")
project.configure<PublishingExtension> { project.configure<PublishingExtension> {
// Process each publication we have in this project // Process each publication we have in this project
publications.filterIsInstance<MavenPublication>().forEach { publication -> publications.withType<MavenPublication>().forEach { publication ->
@Suppress("UnstableApiUsage") @Suppress("UnstableApiUsage")
publication.pom { publication.pom {
@ -71,8 +63,9 @@ open class ScientifikPublishPlugin : Plugin<Project> {
val githubToken: String? by project val githubToken: String? by project
if (githubProject != null && githubUser != null && githubToken != null) { if (githubProject != null && githubUser != null && githubToken != null) {
project.logger.info("Adding github publishing to project [${project.name}]")
repositories { repositories {
val repository = maven { val githubMavenRepository = maven {
name = "github" name = "github"
url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/") url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/")
credentials { credentials {
@ -86,7 +79,7 @@ open class ScientifikPublishPlugin : Plugin<Project> {
tasks.register<PublishToMavenRepository>("publish${publication.name.capitalize()}ToGithub") { tasks.register<PublishToMavenRepository>("publish${publication.name.capitalize()}ToGithub") {
group = "publishing" group = "publishing"
this.publication = publication this.publication = publication
this.repository = repository this.repository = githubMavenRepository
} }
} }
@ -98,60 +91,42 @@ open class ScientifikPublishPlugin : Plugin<Project> {
} }
} }
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform"){
tasks.filterIsInstance<BintrayUploadTask>().forEach { val bintrayRepo = if (project.version.toString().contains("dev")) {
it.doFirst { "dev"
publications.filterIsInstance<MavenPublication>() } else {
.forEach { publication -> findProperty("bintrayRepo") as? String
val moduleFile =
buildDir.resolve("publications/${publication.name}/module.json")
if (moduleFile.exists()) {
publication.artifact(object : FileBasedMavenArtifact(moduleFile) {
override fun getDefaultExtension() = "module"
})
}
}
}
}
} }
} val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
val bintrayUser = project.findProperty("bintrayUser") as? String
val bintrayKey = project.findProperty("bintrayApiKey") as? String
if (bintrayRepo != null && bintrayUser != null && bintrayKey != null) {
project.logger.info("Adding bintray publishing to project [${project.name}]")
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<PublishingExtension> {
repositories { repositories {
maven("https://bintray.com/mipt-npm/$bintrayRepo") val bintrayMavenRepository = maven {
} name = "bintray"
} uri("https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/${project.name}/;publish=0;override=1")
credentials {
project.configure<BintrayExtension> { this.username = bintrayUser
user = project.findProperty("bintrayUser") as? String? this.password = bintrayKey
key = project.findProperty("bintrayApiKey") as? String? }
publish = true
override = true
// 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 {
this.name = project.version.toString()
this.vcsTag = project.version.toString()
this.released = java.util.Date().toString()
} }
}
//workaround bintray bug val bintrayPublishTasks = publications.withType<MavenPublication>().map { publication ->
afterEvaluate { tasks.register<PublishToMavenRepository>("publish${publication.name.capitalize()}ToBintray") {
setPublications(*project.extensions.findByType<PublishingExtension>()!!.publications.names.toTypedArray()) group = "publishing"
this.publication = publication
this.repository = bintrayMavenRepository
}
}
tasks.register<PublishToMavenRepository>("publishToBintray") {
group = "publishing"
dependsOn(bintrayPublishTasks)
}
} }
} }
} }