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]
|
||||
### Added
|
||||
- Ktor version to versions
|
||||
- Add sonatype publishing
|
||||
|
||||
### 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
|
||||
|
||||
|
28
README.md
28
README.md
@ -1,29 +1,29 @@
|
||||
# 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.
|
||||
|
||||
## ru.mipt.npm.project
|
||||
## ru.mipt.npm.gradle.project
|
||||
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.
|
||||
|
||||
## ru.mipt.npm.mpp
|
||||
`= kotlin("multiplatform") + ru.mipt.npm.kscience`
|
||||
## ru.mipt.npm.gradle.mpp
|
||||
`= kotlin("multiplatform") + ru.mipt.npm.gradle.common`
|
||||
|
||||
Includes JVM-IR and JS-IR-Browser targets.
|
||||
|
||||
## ru.mipt.npm.jvm
|
||||
`= kotlin("jvm") + ru.mipt.npm.kscience`
|
||||
## ru.mipt.npm.gradle.jvm
|
||||
`= kotlin("jvm") + ru.mipt.npm.gradle.common`
|
||||
|
||||
## ru.mipt.npm.js
|
||||
`= kotlin("js + ru.mipt.npm.kscience`
|
||||
## ru.mipt.npm.gradle.js
|
||||
`= kotlin("js") + ru.mipt.npm.gradle.common`
|
||||
|
||||
## ru.mipt.npm.native
|
||||
add default native targets to `ru.mipt.npm.mpp`
|
||||
## ru.mipt.npm.gradle.native
|
||||
add default native targets to `ru.mipt.npm.gradle.mpp`
|
||||
|
||||
## ru.mipt.npm.node
|
||||
add node target to `ru.mipt.npm.mpp`
|
||||
## ru.mipt.npm.gradle.node
|
||||
add node target to `ru.mipt.npm.gradle.mpp`
|
113
build.gradle.kts
113
build.gradle.kts
@ -2,21 +2,24 @@ plugins {
|
||||
`java-gradle-plugin`
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
id("de.marcphilipp.nexus-publish") version "0.4.0"
|
||||
signing
|
||||
id("org.jetbrains.changelog") version "1.0.0"
|
||||
id("org.jetbrains.dokka") version "1.4.20"
|
||||
}
|
||||
|
||||
group = "ru.mipt.npm"
|
||||
version = "0.7.7"
|
||||
version = "0.8.0"
|
||||
|
||||
description = "Build tools for DataForge and kscience projects"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
jcenter()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://kotlin.bintray.com/kotlinx")
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||
|
||||
}
|
||||
|
||||
val kotlinVersion = "1.4.30"
|
||||
@ -31,70 +34,84 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||
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-base:1.4.20")
|
||||
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.0.0")
|
||||
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply{
|
||||
plugins {
|
||||
create("kscience.common"){
|
||||
id = "ru.mipt.npm.kscience"
|
||||
create("common") {
|
||||
id = "ru.mipt.npm.gradle.common"
|
||||
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
|
||||
}
|
||||
|
||||
create("kscience.project"){
|
||||
id = "ru.mipt.npm.project"
|
||||
create("project") {
|
||||
id = "ru.mipt.npm.gradle.project"
|
||||
description = "The root plugin for multimodule project infrastructure"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
|
||||
}
|
||||
|
||||
create("kscience.publish") {
|
||||
id = "ru.mipt.npm.publish"
|
||||
create("publishing") {
|
||||
id = "ru.mipt.npm.gradle.publish"
|
||||
description = "The publication plugin for bintray and github"
|
||||
implementationClass = "ru.mipt.npm.gradle.KSciencePublishPlugin"
|
||||
implementationClass = "ru.mipt.npm.gradle.KSciencePublishingPlugin"
|
||||
}
|
||||
|
||||
create("kscience.mpp") {
|
||||
id = "ru.mipt.npm.mpp"
|
||||
create("mpp") {
|
||||
id = "ru.mipt.npm.gradle.mpp"
|
||||
description = "Pre-configured multiplatform project"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceMPPlugin"
|
||||
}
|
||||
|
||||
create("kscience.jvm") {
|
||||
id = "ru.mipt.npm.jvm"
|
||||
create("jvm") {
|
||||
id = "ru.mipt.npm.gradle.jvm"
|
||||
description = "Pre-configured JVM project"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJVMPlugin"
|
||||
}
|
||||
|
||||
create("kscience.js") {
|
||||
id = "ru.mipt.npm.js"
|
||||
create("js") {
|
||||
id = "ru.mipt.npm.gradle.js"
|
||||
description = "Pre-configured JS project"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceJSPlugin"
|
||||
}
|
||||
|
||||
create("kscience.native") {
|
||||
id = "ru.mipt.npm.native"
|
||||
create("native") {
|
||||
id = "ru.mipt.npm.gradle.native"
|
||||
description = "Additional native targets to be use alongside mpp"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
||||
}
|
||||
|
||||
create("kscience.node") {
|
||||
id = "ru.mipt.npm.node"
|
||||
create("node") {
|
||||
id = "ru.mipt.npm.gradle.node"
|
||||
description = "Additional nodejs target to be use alongside mpp"
|
||||
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
val vcs = "https://github.com/mipt-npm/scientifik-gradle-tools"
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
val vcs = "https://github.com/mipt-npm/gradle-tools"
|
||||
|
||||
val sourcesJar: Jar by tasks.creating(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(sourceSets.named("main").get().allSource)
|
||||
}
|
||||
|
||||
val javadocsJar: Jar by tasks.creating(Jar::class) {
|
||||
group = "documentation"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.dokkaHtml)
|
||||
}
|
||||
|
||||
// Process each publication we have in this project
|
||||
publications.filterIsInstance<MavenPublication>().forEach { publication ->
|
||||
publication.apply {
|
||||
artifact(sourcesJar)
|
||||
artifact(javadocsJar)
|
||||
|
||||
publication.pom {
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set(vcs)
|
||||
@ -121,21 +138,57 @@ publishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
||||
val spaceUser: String? by project
|
||||
val spaceToken: String? by project
|
||||
|
||||
if (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 sonatypeUser: String? by project
|
||||
val sonatypePassword: String? by project
|
||||
|
||||
if (sonatypeUser != null && sonatypePassword != null) {
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
sonatype{
|
||||
username.set(sonatypeUser)
|
||||
password.set(sonatypePassword)
|
||||
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() {
|
||||
project.plugins.apply(KSciencePublishPlugin::class)
|
||||
project.plugins.apply(KSciencePublishingPlugin::class)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
@ -19,61 +18,47 @@ class KScienceNativePlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
val ideaActive = System.getProperty("idea.active") == "true"
|
||||
|
||||
if (ideaActive) {
|
||||
//development mode
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
when {
|
||||
hostOs == "Mac OS X" -> macosX64("native")
|
||||
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{
|
||||
sourceSets {
|
||||
val commonMain by getting
|
||||
val commonTest by getting
|
||||
|
||||
val nativeMain by creating{
|
||||
val nativeMain by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val nativeTest by creating{
|
||||
val nativeTest by creating {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
val linuxX64Main by getting{
|
||||
val linuxX64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
|
||||
val mingwX64Main by getting{
|
||||
val mingwX64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
|
||||
val macosX64Main by getting{
|
||||
val macosX64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
|
||||
val linuxX64Test by getting{
|
||||
val linuxX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
|
||||
val mingwX64Test by getting{
|
||||
val mingwX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
|
||||
val macosX64Test by getting{
|
||||
val macosX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -56,11 +56,11 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
group = "documentation"
|
||||
description = "Generate a README file if stub is present"
|
||||
|
||||
if(readmeExtension.readmeTemplate.exists()) {
|
||||
if (readmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(readmeExtension.readmeTemplate)
|
||||
}
|
||||
readmeExtension.additionalFiles.forEach {
|
||||
if(it.exists()){
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<DokkaTask>{
|
||||
tasks.withType<DokkaTask> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
}
|
||||
@ -90,11 +90,11 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
if(rootReadmeExtension.readmeTemplate.exists()) {
|
||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||
inputs.file(rootReadmeExtension.readmeTemplate)
|
||||
}
|
||||
rootReadmeExtension.additionalFiles.forEach {
|
||||
if(it.exists()){
|
||||
if (it.exists()) {
|
||||
inputs.file(it)
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
appendln("> ${ext.description}")
|
||||
appendln(">\n> **Maturity**: ${ext.maturity}")
|
||||
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$name/")
|
||||
if(featureString.isNotBlank()) {
|
||||
if (featureString.isNotBlank()) {
|
||||
appendln(">\n> **Features:**")
|
||||
appendln(featureString)
|
||||
}
|
||||
@ -142,27 +142,38 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<DokkaTask>{
|
||||
tasks.withType<DokkaTask> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
val patchChangelog by tasks.getting
|
||||
|
||||
val release by tasks.creating{
|
||||
afterEvaluate {
|
||||
val release by tasks.creating {
|
||||
group = RELEASE_GROUP
|
||||
description = "Publish development or production release based on version suffix"
|
||||
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)
|
||||
}
|
||||
tasks.findByName("publishAllPublicationsToSpaceRepository")?.let {
|
||||
tasks.findByName("publish${publicationName}ToBintrayRepository")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
tasks.findByName("publish${publicationName}ToSpaceRepository")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
companion object{
|
||||
|
||||
companion object {
|
||||
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 kotlinxNodeVersion = "0.0.7"
|
||||
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 ktorVersion = "1.5.1"
|
||||
const val htmlVersion = "0.7.2"
|
||||
@ -17,7 +17,7 @@ object KScienceVersions {
|
||||
val JVM_TARGET = JavaVersion.VERSION_11
|
||||
|
||||
object Serialization{
|
||||
const val xmlVersion = "0.80.1"
|
||||
const val xmlVersion = "0.81.0"
|
||||
const val bsonVersion = "0.4.4"
|
||||
const val yamlKtVersion = "0.9.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user