Sonatype publication
This commit is contained in:
parent
1fa05926af
commit
fdf88327b4
@ -8,6 +8,7 @@ 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
|
||||
|
@ -2,11 +2,14 @@ plugins {
|
||||
`java-gradle-plugin`
|
||||
`kotlin-dsl`
|
||||
`maven-publish`
|
||||
id("de.marcphilipp.nexus-publish") version "0.4.0"
|
||||
id("org.jetbrains.changelog") version "1.0.0"
|
||||
}
|
||||
|
||||
group = "ru.mipt.npm"
|
||||
version = "0.7.6"
|
||||
version = "0.7.7"
|
||||
|
||||
description = "Build tools for DataForge and kscience projects"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
@ -119,26 +122,20 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
val bintrayUser: String? by project
|
||||
val bintrayApiKey: String? by project
|
||||
val projectName = project.name
|
||||
val sonatypeUser: String? by project
|
||||
val sonatypePassword: String? by project
|
||||
|
||||
if (bintrayUser != null && bintrayApiKey != null) {
|
||||
if (sonatypeUser != null && sonatypePassword != null) {
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "bintray"
|
||||
url = uri(
|
||||
"https://api.bintray.com/maven/mipt-npm/dev/$projectName/;publish=1;override=1"
|
||||
)
|
||||
credentials {
|
||||
username = bintrayUser
|
||||
password = bintrayApiKey
|
||||
sonatype{
|
||||
username.set(sonatypeUser)
|
||||
password.set(sonatypePassword)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -2,12 +2,12 @@ package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ApplicationPlugin
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
import ru.mipt.npm.gradle.internal.configurePublishing
|
||||
import ru.mipt.npm.gradle.internal.defaultPlatform
|
||||
import ru.mipt.npm.gradle.internal.useCommonDependency
|
||||
import ru.mipt.npm.gradle.internal.useFx
|
||||
@ -128,7 +128,7 @@ class KScienceExtension(val project: Project) {
|
||||
}
|
||||
|
||||
fun publish() {
|
||||
project.configurePublishing()
|
||||
project.plugins.apply(KSciencePublishPlugin::class)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,15 +13,25 @@ import kotlin.collections.component2
|
||||
|
||||
class KSciencePublishingExtension(val project: Project) {
|
||||
var vcs: String? by project.extra
|
||||
|
||||
// github publishing
|
||||
var githubOrg: String? by project.extra
|
||||
var githubProject: String? by project.extra
|
||||
|
||||
// Space publishing
|
||||
var spaceRepo: String? by project.extra
|
||||
var spaceUser: String? by project.extra
|
||||
var spaceToken: String? by project.extra
|
||||
|
||||
// Bintray publishing
|
||||
var bintrayOrg: String? by project.extra
|
||||
var bintrayUser: String? by project.extra
|
||||
var bintrayApiKey: String? by project.extra
|
||||
var bintrayRepo: String? by project.extra
|
||||
|
||||
// Sonatype publising
|
||||
var sonatypeUser: String? by project.extra
|
||||
var sonatypePassword: String? by project.extra
|
||||
}
|
||||
|
||||
|
||||
@ -139,12 +149,17 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
val patchChangelog by tasks.getting
|
||||
|
||||
val release by tasks.creating{
|
||||
afterEvaluate {
|
||||
group = RELEASE_GROUP
|
||||
description = "Publish development or production release based on version suffix"
|
||||
dependsOn(generateReadme, patchChangelog)
|
||||
dependsOn(generateReadme)
|
||||
tasks.findByName("publishAllPublicationsToBintrayRepository")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
tasks.findByName("publishAllPublicationsToSpaceRepository")?.let {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
companion object{
|
||||
|
@ -2,12 +2,198 @@ package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import ru.mipt.npm.gradle.internal.configurePublishing
|
||||
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.configurePublishing()
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
package ru.mipt.npm.gradle.internal
|
||||
|
||||
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.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
|
||||
internal fun Project.configurePublishing() {
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user