Merge pull request #8 from mipt-npm/dev
0.8.0
This commit is contained in:
commit
3bae601c68
24
CHANGELOG.md
24
CHANGELOG.md
@ -7,12 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Ktor version to versions
|
|
||||||
- Add sonatype publishing
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Kotlin to 1.4.30 stable
|
|
||||||
- Added intermediate jsCommon main/test sourcesSet for node plugin
|
### Deprecated
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
### Security
|
||||||
|
## [0.8.0]
|
||||||
|
### Added
|
||||||
|
- Ktor version to versions
|
||||||
|
- Add sonatype publishing
|
||||||
|
- Per-platform release publishing
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Kotlin to 1.4.30 stable.
|
||||||
|
- Added intermediate jsCommon main/test sourcesSet for node plugin.
|
||||||
|
- Plugin names changed to `ru.mipt.npm` package.
|
||||||
|
- Common plugin id changed to `common`
|
||||||
|
- Plugins group changed to `ru.mipt.npm` with `gradle` prefix
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
28
README.md
28
README.md
@ -1,29 +1,29 @@
|
|||||||
# KScience build tools
|
# KScience build tools
|
||||||
|
|
||||||
A collection of gradle plugins for building and publishin *kscience* and *dataforge* projects.
|
A collection of gradle plugins for building and publish in *kscience* and *dataforge* projects.
|
||||||
|
|
||||||
## ru.mipt.npm.kscience
|
## ru.mipt.npm.gradle.common
|
||||||
A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target.
|
A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform configures the project for appropriate target.
|
||||||
|
|
||||||
## ru.mipt.npm.project
|
## ru.mipt.npm.gradle.project
|
||||||
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
|
Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool.
|
||||||
|
|
||||||
## ru.mipt.npm.publish
|
## ru.mipt.npm.gradle.publish
|
||||||
Enables publishing to maven-central, bintray, Space and github.
|
Enables publishing to maven-central, bintray, Space and github.
|
||||||
|
|
||||||
## ru.mipt.npm.mpp
|
## ru.mipt.npm.gradle.mpp
|
||||||
`= kotlin("multiplatform") + ru.mipt.npm.kscience`
|
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
|
||||||
|
|
||||||
Includes JVM-IR and JS-IR-Browser targets.
|
Includes JVM-IR and JS-IR-Browser targets.
|
||||||
|
|
||||||
## ru.mipt.npm.jvm
|
## ru.mipt.npm.gradle.jvm
|
||||||
`= kotlin("jvm") + ru.mipt.npm.kscience`
|
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
|
||||||
|
|
||||||
## ru.mipt.npm.js
|
## ru.mipt.npm.gradle.js
|
||||||
`= kotlin("js + ru.mipt.npm.kscience`
|
`= kotlin("js") + ru.mipt.npm.gradle.common`
|
||||||
|
|
||||||
## ru.mipt.npm.native
|
## ru.mipt.npm.gradle.native
|
||||||
add default native targets to `ru.mipt.npm.mpp`
|
add default native targets to `ru.mipt.npm.gradle.mpp`
|
||||||
|
|
||||||
## ru.mipt.npm.node
|
## ru.mipt.npm.gradle.node
|
||||||
add node target to `ru.mipt.npm.mpp`
|
add node target to `ru.mipt.npm.gradle.mpp`
|
165
build.gradle.kts
165
build.gradle.kts
@ -2,21 +2,24 @@ plugins {
|
|||||||
`java-gradle-plugin`
|
`java-gradle-plugin`
|
||||||
`kotlin-dsl`
|
`kotlin-dsl`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("de.marcphilipp.nexus-publish") version "0.4.0"
|
signing
|
||||||
id("org.jetbrains.changelog") version "1.0.0"
|
id("org.jetbrains.changelog") version "1.0.0"
|
||||||
|
id("org.jetbrains.dokka") version "1.4.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.mipt.npm"
|
group = "ru.mipt.npm"
|
||||||
version = "0.7.7"
|
version = "0.8.0"
|
||||||
|
|
||||||
description = "Build tools for DataForge and kscience projects"
|
description = "Build tools for DataForge and kscience projects"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven("https://repo.kotlin.link")
|
||||||
maven("https://kotlin.bintray.com/kotlinx")
|
maven("https://kotlin.bintray.com/kotlinx")
|
||||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||||
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinVersion = "1.4.30"
|
val kotlinVersion = "1.4.30"
|
||||||
@ -31,111 +34,161 @@ dependencies {
|
|||||||
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||||
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1")
|
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1")
|
||||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
|
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
|
||||||
implementation("org.jetbrains.dokka:dokka-base:1.4.20")
|
|
||||||
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.0.0")
|
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.0.0")
|
||||||
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
|
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
gradlePlugin {
|
project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply{
|
||||||
plugins {
|
plugins {
|
||||||
create("kscience.common"){
|
create("common") {
|
||||||
id = "ru.mipt.npm.kscience"
|
id = "ru.mipt.npm.gradle.common"
|
||||||
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
|
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.project"){
|
create("project") {
|
||||||
id = "ru.mipt.npm.project"
|
id = "ru.mipt.npm.gradle.project"
|
||||||
description = "The root plugin for multimodule project infrastructure"
|
description = "The root plugin for multimodule project infrastructure"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.publish") {
|
create("publishing") {
|
||||||
id = "ru.mipt.npm.publish"
|
id = "ru.mipt.npm.gradle.publish"
|
||||||
description = "The publication plugin for bintray and github"
|
description = "The publication plugin for bintray and github"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KSciencePublishPlugin"
|
implementationClass = "ru.mipt.npm.gradle.KSciencePublishingPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.mpp") {
|
create("mpp") {
|
||||||
id = "ru.mipt.npm.mpp"
|
id = "ru.mipt.npm.gradle.mpp"
|
||||||
description = "Pre-configured multiplatform project"
|
description = "Pre-configured multiplatform project"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.jvm") {
|
create("jvm") {
|
||||||
id = "ru.mipt.npm.jvm"
|
id = "ru.mipt.npm.gradle.jvm"
|
||||||
description = "Pre-configured JVM project"
|
description = "Pre-configured JVM project"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.js") {
|
create("js") {
|
||||||
id = "ru.mipt.npm.js"
|
id = "ru.mipt.npm.gradle.js"
|
||||||
description = "Pre-configured JS project"
|
description = "Pre-configured JS project"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.native") {
|
create("native") {
|
||||||
id = "ru.mipt.npm.native"
|
id = "ru.mipt.npm.gradle.native"
|
||||||
description = "Additional native targets to be use alongside mpp"
|
description = "Additional native targets to be use alongside mpp"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
create("kscience.node") {
|
create("node") {
|
||||||
id = "ru.mipt.npm.node"
|
id = "ru.mipt.npm.gradle.node"
|
||||||
description = "Additional nodejs target to be use alongside mpp"
|
description = "Additional nodejs target to be use alongside mpp"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
afterEvaluate {
|
||||||
val vcs = "https://github.com/mipt-npm/scientifik-gradle-tools"
|
publishing {
|
||||||
|
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||||
|
|
||||||
// Process each publication we have in this project
|
val sourcesJar: Jar by tasks.creating(Jar::class) {
|
||||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
archiveClassifier.set("sources")
|
||||||
|
from(sourceSets.named("main").get().allSource)
|
||||||
|
}
|
||||||
|
|
||||||
publication.pom {
|
val javadocsJar: Jar by tasks.creating(Jar::class) {
|
||||||
name.set(project.name)
|
group = "documentation"
|
||||||
description.set(project.description)
|
archiveClassifier.set("javadoc")
|
||||||
url.set(vcs)
|
from(tasks.dokkaHtml)
|
||||||
|
}
|
||||||
|
|
||||||
licenses {
|
// Process each publication we have in this project
|
||||||
license {
|
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||||
name.set("The Apache Software License, Version 2.0")
|
publication.apply {
|
||||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
artifact(sourcesJar)
|
||||||
distribution.set("repo")
|
artifact(javadocsJar)
|
||||||
|
|
||||||
|
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)
|
||||||
|
tag.set(project.version.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
|
||||||
tag.set(project.version.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val sonatypeUser: String? by project
|
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
||||||
val sonatypePassword: String? by project
|
val spaceUser: String? by project
|
||||||
|
val spaceToken: String? by project
|
||||||
|
|
||||||
if (sonatypeUser != null && sonatypePassword != null) {
|
if (spaceUser != null && spaceToken != null) {
|
||||||
nexusPublishing {
|
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||||
repositories {
|
repositories {
|
||||||
sonatype{
|
maven {
|
||||||
username.set(sonatypeUser)
|
name = "space"
|
||||||
password.set(sonatypePassword)
|
url = uri(spaceRepo)
|
||||||
|
credentials {
|
||||||
|
username = spaceUser
|
||||||
|
password = spaceToken
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val sonatypeUser: String? by project
|
||||||
|
val sonatypePassword: String? by project
|
||||||
|
|
||||||
|
if (sonatypeUser != null && sonatypePassword != null) {
|
||||||
|
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
||||||
|
"https://oss.sonatype.org/content/repositories/snapshots"
|
||||||
|
} else {
|
||||||
|
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugins.findPlugin("signing") == null) {
|
||||||
|
plugins.apply("signing")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri(sonatypeRepo)
|
||||||
|
credentials {
|
||||||
|
username = sonatypeUser
|
||||||
|
password = sonatypePassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
signing {
|
||||||
|
//useGpgCmd()
|
||||||
|
sign(publications)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class KScienceExtension(val project: Project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun publish() {
|
fun publish() {
|
||||||
project.plugins.apply(KSciencePublishPlugin::class)
|
project.plugins.apply(KSciencePublishingPlugin::class)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
import org.gradle.api.GradleException
|
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
@ -19,59 +18,45 @@ class KScienceNativePlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure<KotlinMultiplatformExtension> {
|
configure<KotlinMultiplatformExtension> {
|
||||||
val ideaActive = System.getProperty("idea.active") == "true"
|
//deploy mode
|
||||||
|
linuxX64()
|
||||||
|
mingwX64()
|
||||||
|
macosX64()
|
||||||
|
|
||||||
if (ideaActive) {
|
sourceSets {
|
||||||
//development mode
|
val commonMain by getting
|
||||||
val hostOs = System.getProperty("os.name")
|
val commonTest by getting
|
||||||
|
|
||||||
when {
|
val nativeMain by creating {
|
||||||
hostOs == "Mac OS X" -> macosX64("native")
|
dependsOn(commonMain)
|
||||||
hostOs == "Linux" -> linuxX64("native")
|
|
||||||
hostOs.startsWith("Windows") -> mingwX64("native")
|
|
||||||
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//deploy mode
|
|
||||||
linuxX64()
|
|
||||||
mingwX64()
|
|
||||||
macosX64()
|
|
||||||
|
|
||||||
sourceSets{
|
val nativeTest by creating {
|
||||||
val commonMain by getting
|
dependsOn(commonTest)
|
||||||
val commonTest by getting
|
}
|
||||||
|
|
||||||
val nativeMain by creating{
|
val linuxX64Main by getting {
|
||||||
dependsOn(commonMain)
|
dependsOn(nativeMain)
|
||||||
}
|
}
|
||||||
|
|
||||||
val nativeTest by creating{
|
val mingwX64Main by getting {
|
||||||
dependsOn(commonTest)
|
dependsOn(nativeMain)
|
||||||
}
|
}
|
||||||
|
|
||||||
val linuxX64Main by getting{
|
val macosX64Main by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
}
|
}
|
||||||
|
|
||||||
val mingwX64Main by getting{
|
val linuxX64Test by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeTest)
|
||||||
}
|
}
|
||||||
|
|
||||||
val macosX64Main by getting{
|
val mingwX64Test by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeTest)
|
||||||
}
|
}
|
||||||
|
|
||||||
val linuxX64Test by getting{
|
val macosX64Test by getting {
|
||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
}
|
|
||||||
|
|
||||||
val mingwX64Test by getting{
|
|
||||||
dependsOn(nativeTest)
|
|
||||||
}
|
|
||||||
|
|
||||||
val macosX64Test by getting{
|
|
||||||
dependsOn(nativeTest)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,11 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
group = "documentation"
|
group = "documentation"
|
||||||
description = "Generate a README file if stub is present"
|
description = "Generate a README file if stub is present"
|
||||||
|
|
||||||
if(readmeExtension.readmeTemplate.exists()) {
|
if (readmeExtension.readmeTemplate.exists()) {
|
||||||
inputs.file(readmeExtension.readmeTemplate)
|
inputs.file(readmeExtension.readmeTemplate)
|
||||||
}
|
}
|
||||||
readmeExtension.additionalFiles.forEach {
|
readmeExtension.additionalFiles.forEach {
|
||||||
if(it.exists()){
|
if (it.exists()) {
|
||||||
inputs.file(it)
|
inputs.file(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.withType<DokkaTask>{
|
tasks.withType<DokkaTask> {
|
||||||
dependsOn(generateReadme)
|
dependsOn(generateReadme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,11 +90,11 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rootReadmeExtension.readmeTemplate.exists()) {
|
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||||
inputs.file(rootReadmeExtension.readmeTemplate)
|
inputs.file(rootReadmeExtension.readmeTemplate)
|
||||||
}
|
}
|
||||||
rootReadmeExtension.additionalFiles.forEach {
|
rootReadmeExtension.additionalFiles.forEach {
|
||||||
if(it.exists()){
|
if (it.exists()) {
|
||||||
inputs.file(it)
|
inputs.file(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
appendln("> ${ext.description}")
|
appendln("> ${ext.description}")
|
||||||
appendln(">\n> **Maturity**: ${ext.maturity}")
|
appendln(">\n> **Maturity**: ${ext.maturity}")
|
||||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$name/")
|
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$name/")
|
||||||
if(featureString.isNotBlank()) {
|
if (featureString.isNotBlank()) {
|
||||||
appendln(">\n> **Features:**")
|
appendln(">\n> **Features:**")
|
||||||
appendln(featureString)
|
appendln(featureString)
|
||||||
}
|
}
|
||||||
@ -142,27 +142,38 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<DokkaTask>{
|
tasks.withType<DokkaTask> {
|
||||||
dependsOn(generateReadme)
|
dependsOn(generateReadme)
|
||||||
}
|
}
|
||||||
|
|
||||||
val patchChangelog by tasks.getting
|
val patchChangelog by tasks.getting
|
||||||
|
|
||||||
val release by tasks.creating{
|
afterEvaluate {
|
||||||
afterEvaluate {
|
val release by tasks.creating {
|
||||||
group = RELEASE_GROUP
|
group = RELEASE_GROUP
|
||||||
description = "Publish development or production release based on version suffix"
|
description = "Publish development or production release based on version suffix"
|
||||||
dependsOn(generateReadme)
|
dependsOn(generateReadme)
|
||||||
tasks.findByName("publishAllPublicationsToBintrayRepository")?.let {
|
|
||||||
|
val publicationPlatform = project.findProperty("ci.publication.platform") as? String
|
||||||
|
val publicationName = if(publicationPlatform == null){
|
||||||
|
"AllPublications"
|
||||||
|
} else {
|
||||||
|
publicationPlatform.capitalize() + "Publication"
|
||||||
|
}
|
||||||
|
tasks.findByName("publish${publicationName}ToSonatypeRepository")?.let {
|
||||||
dependsOn(it)
|
dependsOn(it)
|
||||||
}
|
}
|
||||||
tasks.findByName("publishAllPublicationsToSpaceRepository")?.let {
|
tasks.findByName("publish${publicationName}ToBintrayRepository")?.let {
|
||||||
|
dependsOn(it)
|
||||||
|
}
|
||||||
|
tasks.findByName("publish${publicationName}ToSpaceRepository")?.let {
|
||||||
dependsOn(it)
|
dependsOn(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
companion object{
|
|
||||||
|
companion object {
|
||||||
const val RELEASE_GROUP = "release"
|
const val RELEASE_GROUP = "release"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,199 +0,0 @@
|
|||||||
package ru.mipt.npm.gradle
|
|
||||||
|
|
||||||
import org.gradle.api.Plugin
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.publish.PublishingExtension
|
|
||||||
import org.gradle.api.publish.maven.MavenPublication
|
|
||||||
import org.gradle.jvm.tasks.Jar
|
|
||||||
import org.gradle.kotlin.dsl.*
|
|
||||||
import org.gradle.plugins.signing.SigningExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
|
||||||
|
|
||||||
|
|
||||||
open class KSciencePublishPlugin : Plugin<Project> {
|
|
||||||
|
|
||||||
override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.kscience") {
|
|
||||||
project.run {
|
|
||||||
if (plugins.findPlugin("maven-publish") == null) {
|
|
||||||
plugins.apply("maven-publish")
|
|
||||||
}
|
|
||||||
|
|
||||||
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
|
|
||||||
val githubProject: String? by project
|
|
||||||
val vcs = findProperty("vcs") as? String
|
|
||||||
?: githubProject?.let { "https://github.com/$githubOrg/$it" }
|
|
||||||
|
|
||||||
// if (vcs == null) {
|
|
||||||
// project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
project.configure<PublishingExtension> {
|
|
||||||
plugins.withId("org.jetbrains.kotlin.js") {
|
|
||||||
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
|
|
||||||
|
|
||||||
val sourcesJar: Jar by project.tasks.creating(Jar::class) {
|
|
||||||
archiveClassifier.set("sources")
|
|
||||||
from(kotlin.sourceSets["main"].kotlin)
|
|
||||||
}
|
|
||||||
|
|
||||||
publications {
|
|
||||||
create("js", MavenPublication::class) {
|
|
||||||
from(components["kotlin"])
|
|
||||||
artifact(sourcesJar)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
|
||||||
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
|
||||||
|
|
||||||
val sourcesJar: Jar by project.tasks.creating(Jar::class) {
|
|
||||||
archiveClassifier.set("sources")
|
|
||||||
from(kotlin.sourceSets["main"].kotlin)
|
|
||||||
}
|
|
||||||
|
|
||||||
publications {
|
|
||||||
create("jvm", MavenPublication::class) {
|
|
||||||
from(components["kotlin"])
|
|
||||||
artifact(sourcesJar)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Process each publication we have in this project
|
|
||||||
publications.withType<MavenPublication>().forEach { publication ->
|
|
||||||
publication.pom {
|
|
||||||
name.set(project.name)
|
|
||||||
description.set(project.description)
|
|
||||||
vcs?.let { 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")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
vcs?.let {
|
|
||||||
scm {
|
|
||||||
url.set(vcs)
|
|
||||||
tag.set(project.version.toString())
|
|
||||||
//developerConnection = "scm:git:[fetch=]/*ВАША ССЫЛКА НА .git файл*/[push=]/*Повторить предыдущую ссылку*/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val githubUser: String? by project
|
|
||||||
val githubToken: String? by project
|
|
||||||
|
|
||||||
if (githubProject != null && githubUser != null && githubToken != null) {
|
|
||||||
project.logger.info("Adding github publishing to project [${project.name}]")
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "github"
|
|
||||||
url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/")
|
|
||||||
credentials {
|
|
||||||
username = githubUser
|
|
||||||
password = githubToken
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val spaceRepo: String? by project
|
|
||||||
val spaceUser: String? by project
|
|
||||||
val spaceToken: String? by project
|
|
||||||
|
|
||||||
if (spaceRepo != null && spaceUser != null && spaceToken != null) {
|
|
||||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "space"
|
|
||||||
url = uri(spaceRepo!!)
|
|
||||||
credentials {
|
|
||||||
username = spaceUser
|
|
||||||
password = spaceToken
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
|
|
||||||
val bintrayUser: String? by project
|
|
||||||
val bintrayApiKey: String? by project
|
|
||||||
|
|
||||||
|
|
||||||
val bintrayRepo = if (project.version.toString().contains("dev")) {
|
|
||||||
"dev"
|
|
||||||
} else {
|
|
||||||
findProperty("bintrayRepo") as? String
|
|
||||||
}
|
|
||||||
|
|
||||||
val projectName = project.name
|
|
||||||
|
|
||||||
if (bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) {
|
|
||||||
project.logger.info("Adding bintray publishing to project [$projectName]")
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "bintray"
|
|
||||||
url = uri(
|
|
||||||
"https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/$projectName/;publish=1;override=1"
|
|
||||||
)
|
|
||||||
credentials {
|
|
||||||
username = bintrayUser
|
|
||||||
password = bintrayApiKey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val sonatypeUser: String? by project
|
|
||||||
val sonatypePassword: String? by project
|
|
||||||
|
|
||||||
if (sonatypeUser != null && sonatypePassword != null) {
|
|
||||||
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
|
||||||
"https://oss.sonatype.org/content/repositories/snapshots"
|
|
||||||
} else {
|
|
||||||
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugins.findPlugin("signing") == null) {
|
|
||||||
plugins.apply("signing")
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.findByType<SigningExtension>()?.apply {
|
|
||||||
useGpgCmd()
|
|
||||||
sign(publications)
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = uri(sonatypeRepo)
|
|
||||||
credentials {
|
|
||||||
username = sonatypeUser
|
|
||||||
password = sonatypePassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
208
src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishingPlugin.kt
Normal file
208
src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishingPlugin.kt
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.publish.PublishingExtension
|
||||||
|
import org.gradle.api.publish.maven.MavenPublication
|
||||||
|
import org.gradle.jvm.tasks.Jar
|
||||||
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.gradle.plugins.signing.SigningExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
|
|
||||||
|
|
||||||
|
private fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT")
|
||||||
|
|
||||||
|
open class KSciencePublishingPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project): Unit = project.afterEvaluate {
|
||||||
|
if (plugins.findPlugin("maven-publish") == null) {
|
||||||
|
plugins.apply("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
|
||||||
|
val githubProject: String? by project
|
||||||
|
val vcs = findProperty("vcs") as? String
|
||||||
|
?: githubProject?.let { "https://github.com/$githubOrg/$it" }
|
||||||
|
|
||||||
|
configure<PublishingExtension> {
|
||||||
|
plugins.withId("org.jetbrains.kotlin.js") {
|
||||||
|
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
|
||||||
|
|
||||||
|
val sourcesJar: Jar by project.tasks.creating(Jar::class) {
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
from(kotlin.sourceSets["main"].kotlin)
|
||||||
|
}
|
||||||
|
|
||||||
|
publications {
|
||||||
|
create("js", MavenPublication::class) {
|
||||||
|
from(components["kotlin"])
|
||||||
|
artifact(sourcesJar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||||
|
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||||
|
|
||||||
|
val sourcesJar: Jar by project.tasks.creating(Jar::class) {
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
from(kotlin.sourceSets["main"].kotlin)
|
||||||
|
}
|
||||||
|
|
||||||
|
publications {
|
||||||
|
create("jvm", MavenPublication::class) {
|
||||||
|
from(components["kotlin"])
|
||||||
|
artifact(sourcesJar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val dokkaJar: Jar by tasks.creating(Jar::class) {
|
||||||
|
group = "documentation"
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
from(tasks.findByName("dokkaHtml"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process each publication we have in this project
|
||||||
|
publications.withType<MavenPublication>().forEach { publication ->
|
||||||
|
publication.artifact(dokkaJar)
|
||||||
|
publication.pom {
|
||||||
|
name.set(project.name)
|
||||||
|
description.set(project.description ?: project.name)
|
||||||
|
vcs?.let { 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
vcs?.let {
|
||||||
|
scm {
|
||||||
|
url.set(vcs)
|
||||||
|
tag.set(project.version.toString())
|
||||||
|
//developerConnection = "scm:git:[fetch=]/*ВАША ССЫЛКА НА .git файл*/[push=]/*Повторить предыдущую ссылку*/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val githubUser: String? by project
|
||||||
|
val githubToken: String? by project
|
||||||
|
|
||||||
|
if (githubProject != null && githubUser != null && githubToken != null) {
|
||||||
|
project.logger.info("Adding github publishing to project [${project.name}]")
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "github"
|
||||||
|
url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/")
|
||||||
|
credentials {
|
||||||
|
username = githubUser
|
||||||
|
password = githubToken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val spaceRepo: String? by project
|
||||||
|
val spaceUser: String? by project
|
||||||
|
val spaceToken: String? by project
|
||||||
|
|
||||||
|
if (spaceRepo != null && spaceUser != null && spaceToken != null) {
|
||||||
|
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "space"
|
||||||
|
url = uri(spaceRepo!!)
|
||||||
|
credentials {
|
||||||
|
username = spaceUser
|
||||||
|
password = spaceToken
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
|
||||||
|
val bintrayUser: String? by project
|
||||||
|
val bintrayApiKey: String? by project
|
||||||
|
val bintrayPublish: String? by project
|
||||||
|
|
||||||
|
val bintrayRepo = if (isSnapshot()) {
|
||||||
|
"dev"
|
||||||
|
} else {
|
||||||
|
findProperty("bintrayRepo") as? String
|
||||||
|
}
|
||||||
|
|
||||||
|
val projectName = project.name
|
||||||
|
|
||||||
|
if (bintrayPublish == "true" && bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) {
|
||||||
|
project.logger.info("Adding bintray publishing to project [$projectName]")
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "bintray"
|
||||||
|
url = uri(
|
||||||
|
"https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/$projectName/;publish=1;override=1"
|
||||||
|
)
|
||||||
|
credentials {
|
||||||
|
username = bintrayUser
|
||||||
|
password = bintrayApiKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val sonatypePublish: String? by project
|
||||||
|
val sonatypeUser: String? by project
|
||||||
|
val sonatypePassword: String? by project
|
||||||
|
|
||||||
|
val keyId: String? by project
|
||||||
|
val signingKey: String? = project.findProperty("signingKey") as? String ?: System.getenv("signingKey")
|
||||||
|
val signingKeyPassphrase: String? by project
|
||||||
|
|
||||||
|
if (sonatypePublish == "true" && sonatypeUser != null && sonatypePassword != null) {
|
||||||
|
val sonatypeRepo: String = if (isSnapshot()) {
|
||||||
|
"https://oss.sonatype.org/content/repositories/snapshots"
|
||||||
|
} else {
|
||||||
|
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugins.findPlugin("signing") == null) {
|
||||||
|
plugins.apply("signing")
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.configure<SigningExtension>("signing") {
|
||||||
|
if (!signingKey.isNullOrBlank()) {
|
||||||
|
//if key is provided, use it
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase)
|
||||||
|
} // else use file signing
|
||||||
|
sign(publications)
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri(sonatypeRepo)
|
||||||
|
credentials {
|
||||||
|
username = sonatypeUser
|
||||||
|
password = sonatypePassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ object KScienceVersions {
|
|||||||
const val kotlinVersion = "1.4.30"
|
const val kotlinVersion = "1.4.30"
|
||||||
const val kotlinxNodeVersion = "0.0.7"
|
const val kotlinxNodeVersion = "0.0.7"
|
||||||
const val coroutinesVersion = "1.4.2"
|
const val coroutinesVersion = "1.4.2"
|
||||||
const val serializationVersion = "1.1.0-RC"
|
const val serializationVersion = "1.1.0"
|
||||||
const val atomicVersion = "0.15.1"
|
const val atomicVersion = "0.15.1"
|
||||||
const val ktorVersion = "1.5.1"
|
const val ktorVersion = "1.5.1"
|
||||||
const val htmlVersion = "0.7.2"
|
const val htmlVersion = "0.7.2"
|
||||||
@ -17,7 +17,7 @@ object KScienceVersions {
|
|||||||
val JVM_TARGET = JavaVersion.VERSION_11
|
val JVM_TARGET = JavaVersion.VERSION_11
|
||||||
|
|
||||||
object Serialization{
|
object Serialization{
|
||||||
const val xmlVersion = "0.80.1"
|
const val xmlVersion = "0.81.0"
|
||||||
const val bsonVersion = "0.4.4"
|
const val bsonVersion = "0.4.4"
|
||||||
const val yamlKtVersion = "0.9.0"
|
const val yamlKtVersion = "0.9.0"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user