Merge pull request #11 from mipt-npm/dev
0.9.0
This commit is contained in:
commit
b2ede48c3e
43
CHANGELOG.md
43
CHANGELOG.md
@ -17,7 +17,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
## [0.8.0]
|
|
||||||
|
## [0.9.0]
|
||||||
|
### Added
|
||||||
|
- Skip sonatype publishing for dev versions
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Publishing repositories are explicit and defined in the top level project
|
||||||
|
- Paths to publishing properties now use dot notation like `publishing.github.user`
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
- Publishing plugin
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Bintray publishing
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
## [0.8.4]
|
||||||
|
### Added
|
||||||
|
- Adaptive support for host OS in native
|
||||||
|
- CSS support for JS targets
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Kotlin 1.4.31
|
||||||
|
- Coroutines 1.4.3
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Plugin loading order for publishing
|
||||||
|
- Release task
|
||||||
|
- Readme generation for multi-module project
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
## [0.8.1]
|
||||||
### Added
|
### Added
|
||||||
- Ktor version to versions
|
- Ktor version to versions
|
||||||
- Add sonatype publishing
|
- Add sonatype publishing
|
||||||
@ -36,6 +75,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- kaml
|
- kaml
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fix publishing load order for sonatype
|
||||||
|
- Fix root project readme
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.mipt.npm"
|
group = "ru.mipt.npm"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
|
|
||||||
description = "Build tools for DataForge and kscience projects"
|
description = "Build tools for DataForge and kscience projects"
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ repositories {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinVersion = "1.4.30"
|
val kotlinVersion = "1.4.31"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@ -141,8 +141,8 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
val spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/mipt-npm/maven"
|
||||||
val spaceUser: String? by project
|
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
|
||||||
val spaceToken: String? by project
|
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
|
||||||
|
|
||||||
if (spaceUser != null && spaceToken != null) {
|
if (spaceUser != null && spaceToken != null) {
|
||||||
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
|
||||||
@ -159,8 +159,8 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val sonatypeUser: String? by project
|
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String
|
||||||
val sonatypePassword: String? by project
|
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String
|
||||||
|
|
||||||
if (sonatypeUser != null && sonatypePassword != null) {
|
if (sonatypeUser != null && sonatypePassword != null) {
|
||||||
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
val sonatypeRepo: String = if (project.version.toString().contains("dev")) {
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -20,11 +20,6 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
registerKScienceExtension()
|
registerKScienceExtension()
|
||||||
repositories.applyRepos()
|
repositories.applyRepos()
|
||||||
|
|
||||||
// apply dokka for all projects
|
|
||||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
|
||||||
plugins.apply("org.jetbrains.dokka")
|
|
||||||
}
|
|
||||||
|
|
||||||
//Configuration for K-JVM plugin
|
//Configuration for K-JVM plugin
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
//logger.info("Applying KScience configuration for JVM project")
|
//logger.info("Applying KScience configuration for JVM project")
|
||||||
@ -43,6 +38,22 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tasks.withType<KotlinJvmCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
useIR = true
|
||||||
|
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||||
|
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.apply {
|
||||||
|
withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
@ -51,7 +62,11 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
explicitApiWarning()
|
explicitApiWarning()
|
||||||
|
|
||||||
js(IR) {
|
js(IR) {
|
||||||
browser()
|
browser{
|
||||||
|
commonWebpackConfig {
|
||||||
|
cssSupport.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets["main"].apply {
|
sourceSets["main"].apply {
|
||||||
@ -86,7 +101,11 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
js(IR) {
|
js(IR) {
|
||||||
browser()
|
browser{
|
||||||
|
commonWebpackConfig {
|
||||||
|
cssSupport.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.invoke {
|
sourceSets.invoke {
|
||||||
@ -123,25 +142,23 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
||||||
fromJsDependencies("jsRuntimeClasspath")
|
fromJsDependencies("jsRuntimeClasspath")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.apply {
|
tasks.apply {
|
||||||
withType<KotlinJvmCompile> {
|
|
||||||
kotlinOptions {
|
|
||||||
useIR = true
|
|
||||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
withType<Test> {
|
withType<Test> {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply dokka for all projects
|
||||||
|
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||||
|
plugins.apply("org.jetbrains.dokka")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
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.apply
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.findPlugin
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
|
|
||||||
|
private fun KotlinMultiplatformExtension.sourceSets(configure: Action<NamedDomainObjectContainer<KotlinSourceSet>>): Unit =
|
||||||
|
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure)
|
||||||
|
|
||||||
class KScienceNativePlugin : Plugin<Project> {
|
class KScienceNativePlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) = target.run {
|
override fun apply(project: Project) = project.run {
|
||||||
//Apply multiplatform plugin is not applied, apply it
|
//Apply multiplatform plugin is not applied, apply it
|
||||||
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||||
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||||
@ -18,46 +26,42 @@ class KScienceNativePlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure<KotlinMultiplatformExtension> {
|
configure<KotlinMultiplatformExtension> {
|
||||||
//deploy mode
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val isLinux = hostOs == "Linux"
|
||||||
|
val isMinGw = hostOs.startsWith("Windows")
|
||||||
|
val isMacOs = hostOs == "Mac OS X"
|
||||||
|
|
||||||
|
if (isLinux || isMinGw) {
|
||||||
linuxX64()
|
linuxX64()
|
||||||
|
}
|
||||||
|
if (isMinGw) {
|
||||||
mingwX64()
|
mingwX64()
|
||||||
|
}
|
||||||
|
if (isMacOs) {
|
||||||
macosX64()
|
macosX64()
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting
|
val commonMain = findByName("commonMain")!!
|
||||||
val commonTest by getting
|
val commonTest = findByName("commonTest")!!
|
||||||
|
|
||||||
val nativeMain by creating {
|
val nativeMain = create("nativeMain").apply {
|
||||||
dependsOn(commonMain)
|
dependsOn(commonMain)
|
||||||
}
|
}
|
||||||
|
|
||||||
val nativeTest by creating {
|
val nativeTest = create("nativeTest").apply {
|
||||||
dependsOn(commonTest)
|
dependsOn(commonTest)
|
||||||
}
|
}
|
||||||
|
|
||||||
val linuxX64Main by getting {
|
findByName("linuxX64Main")?.dependsOn(nativeMain)
|
||||||
dependsOn(nativeMain)
|
findByName("linuxX64Test")?.dependsOn(nativeTest)
|
||||||
}
|
|
||||||
|
|
||||||
val mingwX64Main by getting {
|
findByName("mingwX64Main")?.dependsOn(nativeMain)
|
||||||
dependsOn(nativeMain)
|
findByName("mingwX64Test")?.dependsOn(nativeTest)
|
||||||
}
|
|
||||||
|
|
||||||
val macosX64Main by getting {
|
findByName("macosX64Main")?.dependsOn(nativeMain)
|
||||||
dependsOn(nativeMain)
|
findByName("macosX64Test")?.dependsOn(nativeTest)
|
||||||
}
|
|
||||||
|
|
||||||
val linuxX64Test by getting {
|
|
||||||
dependsOn(nativeTest)
|
|
||||||
}
|
|
||||||
|
|
||||||
val mingwX64Test by getting {
|
|
||||||
dependsOn(nativeTest)
|
|
||||||
}
|
|
||||||
|
|
||||||
val macosX64Test by getting {
|
|
||||||
dependsOn(nativeTest)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
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.apply
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.findPlugin
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
|
|
||||||
|
private fun KotlinMultiplatformExtension.sourceSets(configure: Action<NamedDomainObjectContainer<KotlinSourceSet>>): Unit =
|
||||||
|
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a separate target for node
|
* Create a separate target for node
|
||||||
@ -24,38 +32,30 @@ class KScienceNodePlugin : Plugin<Project> {
|
|||||||
js(name = "node", compiler = IR) {
|
js(name = "node", compiler = IR) {
|
||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
sourceSets {
|
|
||||||
val commonMain by getting
|
|
||||||
val commonTest by getting
|
|
||||||
|
|
||||||
val jsCommonMain by creating{
|
sourceSets {
|
||||||
|
val commonMain = findByName("commonMain")!!
|
||||||
|
val commonTest = findByName("commonTest")!!
|
||||||
|
|
||||||
|
val jsCommonMain = create("jsCommonMain").apply {
|
||||||
dependsOn(commonMain)
|
dependsOn(commonMain)
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsCommonTest by creating{
|
val jsCommonTest = create("jsCommonTest").apply {
|
||||||
dependsOn(commonTest)
|
dependsOn(commonTest)
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsMain by getting{
|
findByName("jsMain")?.dependsOn(jsCommonMain)
|
||||||
dependsOn(jsCommonMain)
|
findByName("jsTest")?.dependsOn(jsCommonTest)
|
||||||
}
|
|
||||||
|
|
||||||
val jsTest by getting{
|
findByName("nodeMain")?.apply {
|
||||||
dependsOn(jsCommonTest)
|
|
||||||
}
|
|
||||||
|
|
||||||
val nodeMain by creating {
|
|
||||||
dependsOn(jsCommonMain)
|
dependsOn(jsCommonMain)
|
||||||
dependencies {
|
dependencies {
|
||||||
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
|
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
findByName("nodeTest")?.dependsOn(jsCommonMain)
|
||||||
val nodeTest by creating {
|
|
||||||
dependsOn(jsCommonTest)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,30 +8,52 @@ import org.gradle.kotlin.dsl.*
|
|||||||
import org.jetbrains.changelog.ChangelogPlugin
|
import org.jetbrains.changelog.ChangelogPlugin
|
||||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||||
import org.jetbrains.dokka.gradle.DokkaTask
|
import org.jetbrains.dokka.gradle.DokkaTask
|
||||||
import kotlin.collections.component1
|
import ru.mipt.npm.gradle.internal.addGithubPublishing
|
||||||
import kotlin.collections.component2
|
import ru.mipt.npm.gradle.internal.addSonatypePublishing
|
||||||
|
import ru.mipt.npm.gradle.internal.addSpacePublishing
|
||||||
|
import ru.mipt.npm.gradle.internal.setupPublication
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
class KSciencePublishingExtension(val project: Project) {
|
class KSciencePublishingExtension(val project: Project) {
|
||||||
var vcs: String? by project.extra
|
private var initializedFlag = false
|
||||||
|
|
||||||
// github publishing
|
fun setup(vcsUrl: String){
|
||||||
var githubOrg: String? by project.extra
|
project.setupPublication(vcsUrl)
|
||||||
var githubProject: String? by project.extra
|
initializedFlag = true
|
||||||
|
}
|
||||||
|
|
||||||
// Space publishing
|
/**
|
||||||
var spaceRepo: String? by project.extra
|
* github publishing
|
||||||
var spaceUser: String? by project.extra
|
*/
|
||||||
var spaceToken: String? by project.extra
|
fun github(githubProject: String, githubOrg: String = "mipt-npm") {
|
||||||
|
//automatically initialize vcs using github
|
||||||
|
if(!initializedFlag){
|
||||||
|
setup("https://github.com/$githubOrg/$githubProject")
|
||||||
|
}
|
||||||
|
project.addGithubPublishing(githubOrg, githubProject)
|
||||||
|
}
|
||||||
|
|
||||||
// Bintray publishing
|
/**
|
||||||
var bintrayOrg: String? by project.extra
|
* Space publishing
|
||||||
var bintrayUser: String? by project.extra
|
*/
|
||||||
var bintrayApiKey: String? by project.extra
|
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") {
|
||||||
var bintrayRepo: String? by project.extra
|
require(initializedFlag){"The publishing is not set up use 'setup' method to do so"}
|
||||||
|
project.addSpacePublishing(spaceRepo)
|
||||||
|
}
|
||||||
|
|
||||||
// Sonatype publising
|
// // Bintray publishing
|
||||||
var sonatypeUser: String? by project.extra
|
// var bintrayOrg: String? by project.extra
|
||||||
var sonatypePassword: String? by project.extra
|
// var bintrayUser: String? by project.extra
|
||||||
|
// var bintrayApiKey: String? by project.extra
|
||||||
|
// var bintrayRepo: String? by project.extra
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sonatype publising
|
||||||
|
*/
|
||||||
|
fun sonatype(){
|
||||||
|
require(initializedFlag){"The publishing is not set up use 'setup' method to do so"}
|
||||||
|
project.addSonatypePublishing()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,20 +125,24 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
outputs.file(readmeFile)
|
outputs.file(readmeFile)
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
val projects = subprojects.associate {
|
// val projects = subprojects.associate {
|
||||||
it.name to it.extensions.findByType<KScienceReadmeExtension>()
|
// val normalizedPath = it.path.replaceFirst(":","").replace(":","/")
|
||||||
}
|
// it.path.replace(":","/") to it.extensions.findByType<KScienceReadmeExtension>()
|
||||||
|
// }
|
||||||
|
|
||||||
if (rootReadmeExtension.readmeTemplate.exists()) {
|
if (rootReadmeExtension.readmeTemplate.exists()) {
|
||||||
|
|
||||||
val modulesString = buildString {
|
val modulesString = buildString {
|
||||||
projects.entries.forEach { (name, ext) ->
|
subprojects.forEach { subproject ->
|
||||||
|
val name = subproject.name
|
||||||
|
val path = subproject.path.replaceFirst(":", "").replace(":", "/")
|
||||||
|
val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
|
||||||
appendln("<hr/>")
|
appendln("<hr/>")
|
||||||
appendln("\n* ### [$name]($name)")
|
appendln("\n* ### [$name]($path)")
|
||||||
if (ext != null) {
|
if (ext != null) {
|
||||||
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 = "$path/")
|
||||||
if (featureString.isNotBlank()) {
|
if (featureString.isNotBlank()) {
|
||||||
appendln(">\n> **Features:**")
|
appendln(">\n> **Features:**")
|
||||||
appendln(featureString)
|
appendln(featureString)
|
||||||
@ -126,12 +152,8 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
appendln("<hr/>")
|
appendln("<hr/>")
|
||||||
}
|
}
|
||||||
|
|
||||||
val rootReadmeProperties: Map<String, Any?> = mapOf(
|
val rootReadmeProperties: Map<String, Any?> =
|
||||||
"name" to project.name,
|
rootReadmeExtension.actualizedProperties + ("modules" to modulesString)
|
||||||
"group" to project.group,
|
|
||||||
"version" to project.version,
|
|
||||||
"modules" to modulesString
|
|
||||||
)
|
|
||||||
|
|
||||||
readmeFile.writeText(
|
readmeFile.writeText(
|
||||||
SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate)
|
SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate)
|
||||||
@ -148,28 +170,10 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
|
|
||||||
val patchChangelog by tasks.getting
|
val patchChangelog by tasks.getting
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
val release by tasks.creating {
|
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)
|
||||||
|
|
||||||
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("publish${publicationName}ToBintrayRepository")?.let {
|
|
||||||
dependsOn(it)
|
|
||||||
}
|
|
||||||
tasks.findByName("publish${publicationName}ToSpaceRepository")?.let {
|
|
||||||
dependsOn(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,207 +2,16 @@ package ru.mipt.npm.gradle
|
|||||||
|
|
||||||
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.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")
|
|
||||||
|
|
||||||
|
@Deprecated("To be replaced by maven-publish")
|
||||||
open class KSciencePublishingPlugin : Plugin<Project> {
|
open class KSciencePublishingPlugin : Plugin<Project> {
|
||||||
|
|
||||||
override fun apply(project: Project): Unit = project.afterEvaluate {
|
override fun apply(project: Project): Unit = project.run {
|
||||||
if (plugins.findPlugin("maven-publish") == null) {
|
if (plugins.findPlugin("maven-publish") == null) {
|
||||||
plugins.apply("maven-publish")
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -46,14 +46,15 @@ class KScienceReadmeExtension(val project: Project) {
|
|||||||
features.add(Feature(id, description(), ref, name))
|
features.add(Feature(id, description(), ref, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
val properties: MutableMap<String, () -> Any?> = mutableMapOf(
|
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
|
||||||
"name" to { project.name },
|
"name" to { project.name },
|
||||||
"group" to { project.group },
|
"group" to { project.group },
|
||||||
"version" to { project.version },
|
"version" to { project.version },
|
||||||
"features" to { featuresString() }
|
"features" to { featuresString() }
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun getActualizedProperties() = properties.mapValues { (_, value) ->
|
val actualizedProperties
|
||||||
|
get() = properties.mapValues { (_, value) ->
|
||||||
value.invoke()
|
value.invoke()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,14 +63,14 @@ class KScienceReadmeExtension(val project: Project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun propertyByTemplate(key: String, template: String) {
|
fun propertyByTemplate(key: String, template: String) {
|
||||||
val actual = getActualizedProperties()
|
val actual = actualizedProperties
|
||||||
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val additionalFiles = ArrayList<File>()
|
internal val additionalFiles = ArrayList<File>()
|
||||||
|
|
||||||
fun propertyByTemplate(key: String, template: File) {
|
fun propertyByTemplate(key: String, template: File) {
|
||||||
val actual = getActualizedProperties()
|
val actual = actualizedProperties
|
||||||
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
|
||||||
additionalFiles.add(template)
|
additionalFiles.add(template)
|
||||||
}
|
}
|
||||||
@ -88,7 +89,7 @@ class KScienceReadmeExtension(val project: Project) {
|
|||||||
*/
|
*/
|
||||||
fun readmeString(): String? {
|
fun readmeString(): String? {
|
||||||
return if (readmeTemplate.exists()) {
|
return if (readmeTemplate.exists()) {
|
||||||
val actual = getActualizedProperties()
|
val actual = actualizedProperties
|
||||||
SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString()
|
SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString()
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
@ -6,18 +6,18 @@ import org.gradle.api.JavaVersion
|
|||||||
* Build constants
|
* Build constants
|
||||||
*/
|
*/
|
||||||
object KScienceVersions {
|
object KScienceVersions {
|
||||||
const val kotlinVersion = "1.4.30"
|
const val kotlinVersion = "1.4.31"
|
||||||
const val kotlinxNodeVersion = "0.0.7"
|
const val kotlinxNodeVersion = "0.0.7"
|
||||||
const val coroutinesVersion = "1.4.2"
|
const val coroutinesVersion = "1.4.3"
|
||||||
const val serializationVersion = "1.1.0"
|
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.2"
|
||||||
const val htmlVersion = "0.7.2"
|
const val htmlVersion = "0.7.2"
|
||||||
|
|
||||||
val JVM_TARGET = JavaVersion.VERSION_11
|
val JVM_TARGET = JavaVersion.VERSION_11
|
||||||
|
|
||||||
object Serialization{
|
object Serialization{
|
||||||
const val xmlVersion = "0.81.0"
|
const val xmlVersion = "0.81.1"
|
||||||
const val bsonVersion = "0.4.4"
|
const val bsonVersion = "0.4.4"
|
||||||
const val yamlKtVersion = "0.9.0"
|
const val yamlKtVersion = "0.9.0"
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,11 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
|||||||
|
|
||||||
internal fun RepositoryHandler.applyRepos(): Unit {
|
internal fun RepositoryHandler.applyRepos(): Unit {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven("https://repo.kotlin.link")
|
||||||
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")
|
||||||
maven("https://kotlin.bintray.com/kotlinx")
|
maven("https://kotlin.bintray.com/kotlinx")
|
||||||
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
|
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
|
||||||
maven("https://dl.bintray.com/mipt-npm/kscience")
|
|
||||||
maven("https://dl.bintray.com/mipt-npm/dev")
|
|
||||||
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
|
||||||
maven("https://repo.kotlin.link")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Copy.fromJsDependencies(configurationName: String) = project.afterEvaluate {
|
internal fun Copy.fromJsDependencies(configurationName: String) = project.afterEvaluate {
|
||||||
|
228
src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt
Normal file
228
src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
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.api.tasks.bundling.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.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||||
|
?: System.getenv(propertyName)
|
||||||
|
|
||||||
|
private fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||||
|
?: error("Property $propertyName not defined")
|
||||||
|
|
||||||
|
|
||||||
|
internal fun Project.setupPublication(vcs: String) = allprojects {
|
||||||
|
plugins.withId("maven-publish") {
|
||||||
|
configure<PublishingExtension> {
|
||||||
|
|
||||||
|
plugins.withId("ru.mipt.npm.gradle.js") {
|
||||||
|
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
|
||||||
|
|
||||||
|
val sourcesJar: Jar by tasks.creating(Jar::class) {
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
from(kotlin.sourceSets["main"].kotlin)
|
||||||
|
}
|
||||||
|
|
||||||
|
publications {
|
||||||
|
create("js", MavenPublication::class) {
|
||||||
|
from(components["kotlin"])
|
||||||
|
artifact(sourcesJar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.withId("ru.mipt.npm.gradle.jvm") {
|
||||||
|
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
|
||||||
|
|
||||||
|
val sourcesJar: Jar by 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)
|
||||||
|
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())
|
||||||
|
//developerConnection = "scm:git:[fetch=]/*ВАША ССЫЛКА НА .git файл*/[push=]/*Повторить предыдущую ссылку*/"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT")
|
||||||
|
|
||||||
|
internal val Project.publicationTarget: String
|
||||||
|
get() {
|
||||||
|
val publicationPlatform = project.findProperty("publication.platform") as? String
|
||||||
|
return if (publicationPlatform == null) {
|
||||||
|
"AllPublications"
|
||||||
|
} else {
|
||||||
|
publicationPlatform.capitalize() + "Publication"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Project.addGithubPublishing(
|
||||||
|
githubOrg: String,
|
||||||
|
githubProject: String
|
||||||
|
) {
|
||||||
|
if (requestPropertyOrNull("publishing.github") == "false") {
|
||||||
|
logger.info("Skipping github publishing based on flag value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val githubUser: String = requestProperty("publishing.github.user")
|
||||||
|
val githubToken: String = requestProperty("publishing.github.token")
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
plugins.withId("maven-publish") {
|
||||||
|
configure<PublishingExtension> {
|
||||||
|
logger.info("Adding github publishing to project [${project.name}]")
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "github"
|
||||||
|
url = uri("https://maven.pkg.github.com/$githubOrg/$githubProject/")
|
||||||
|
credentials {
|
||||||
|
username = githubUser
|
||||||
|
password = githubToken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val publicationTask = tasks.getByName("publish${publicationTarget}ToGithubRepository")
|
||||||
|
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Project.addSpacePublishing(spaceRepo: String) {
|
||||||
|
if (requestPropertyOrNull("publishing.space") == "false") {
|
||||||
|
logger.info("Skipping space publishing based on flag value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val spaceUser: String = requestProperty("publishing.space.user")
|
||||||
|
val spaceToken: String = requestProperty("publishing.space.token")
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
plugins.withId("maven-publish") {
|
||||||
|
configure<PublishingExtension> {
|
||||||
|
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 publicationTask = tasks.getByName("publish${publicationTarget}ToSpaceRepository")
|
||||||
|
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Project.addSonatypePublishing() {
|
||||||
|
if(isSnapshot()){
|
||||||
|
logger.info("Sonatype publishing skipped for dev version")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (requestPropertyOrNull("publishing.sonatype") == "false") {
|
||||||
|
logger.info("Skipping sonatype publishing based on flag value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val sonatypeUser: String = requestProperty("publishing.sonatype.user")
|
||||||
|
val sonatypePassword: String = requestProperty("publishing.sonatype.password")
|
||||||
|
val signingId: String? = requestPropertyOrNull("publishing.signing.id")
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
plugins.withId("maven-publish") {
|
||||||
|
configure<PublishingExtension> {
|
||||||
|
val sonatypeRepo: String = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
||||||
|
|
||||||
|
if (plugins.findPlugin("signing") == null) {
|
||||||
|
plugins.apply("signing")
|
||||||
|
}
|
||||||
|
extensions.configure<SigningExtension>("signing") {
|
||||||
|
if (!signingId.isNullOrBlank()) {
|
||||||
|
val signingKey: String = requestProperty("publishing.signing.key")
|
||||||
|
val signingPassphrase: String = requestProperty("publishing.signing.passPhrase")
|
||||||
|
|
||||||
|
//if key is provided, use it
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
useInMemoryPgpKeys(signingId, signingKey, signingPassphrase)
|
||||||
|
} // else use file signing
|
||||||
|
sign(publications)
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri(sonatypeRepo)
|
||||||
|
credentials {
|
||||||
|
username = sonatypeUser
|
||||||
|
password = sonatypePassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val publicationTask = tasks.getByName("publish${publicationTarget}ToSonatypeRepository")
|
||||||
|
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//internal val Project.bintrayPublish: Boolean
|
||||||
|
// get() = (findProperty("publishing.bintray.publish") as? String)?.toBoolean() ?: false
|
||||||
|
//internal val Project.bintrayOrg: String? get() = findProperty("publishing.bintray.org") as? String
|
||||||
|
//internal val Project.bintrayUser: String? get() = findProperty("publishing.bintray.user") as? String
|
||||||
|
//internal val Project.bintrayApiKey: String? get() = findProperty("publishing.bintray.apiKey") as? String
|
Loading…
Reference in New Issue
Block a user