Merge pull request #13 from mipt-npm/dev

0.9.3
This commit is contained in:
Alexander Nozik 2021-03-24 16:21:33 +03:00 committed by GitHub
commit ac4b34c054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 94 additions and 76 deletions

View File

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
### Changed ### Changed
- `publication.platform` changed to `publishing.platform`
- Dokka version to `1.4.30`
- `useDateTime` in extension
### Deprecated ### Deprecated

View File

@ -3,12 +3,12 @@ plugins {
`kotlin-dsl` `kotlin-dsl`
`maven-publish` `maven-publish`
signing signing
id("org.jetbrains.changelog") version "1.0.0" id("org.jetbrains.changelog") version "1.1.2"
id("org.jetbrains.dokka") version "1.4.20" id("org.jetbrains.dokka") version "1.4.30"
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.9.0" version = "0.9.3"
description = "Build tools for DataForge and kscience projects" description = "Build tools for DataForge and kscience projects"
@ -17,12 +17,10 @@ repositories {
jcenter() jcenter()
maven("https://repo.kotlin.link") 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-dev") maven("https://dl.bintray.com/kotlin/kotlin-dev")
} }
val kotlinVersion = "1.4.31" val kotlinVersion = "1.4.32"
java { java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@ -32,10 +30,10 @@ java {
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.2")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.30")
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.0.0") implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.1.2")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.5.0")
} }
project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply { project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply {
@ -52,12 +50,6 @@ project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply {
implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin" implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin"
} }
create("publishing") {
id = "ru.mipt.npm.gradle.publish"
description = "The publication plugin for bintray and github"
implementationClass = "ru.mipt.npm.gradle.KSciencePublishingPlugin"
}
create("mpp") { create("mpp") {
id = "ru.mipt.npm.gradle.mpp" id = "ru.mipt.npm.gradle.mpp"
description = "Pre-configured multiplatform project" description = "Pre-configured multiplatform project"

View File

@ -42,6 +42,9 @@ enum class DependencySourceSet(val setName: String, val suffix: String) {
class KScienceExtension(val project: Project) { class KScienceExtension(val project: Project) {
/**
* Use coroutines-core with default version or [version]
*/
fun useCoroutines( fun useCoroutines(
version: String = KScienceVersions.coroutinesVersion, version: String = KScienceVersions.coroutinesVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN, sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
@ -52,13 +55,25 @@ class KScienceExtension(val project: Project) {
dependencyConfiguration = configuration dependencyConfiguration = configuration
) )
fun useAtomic(version: String = KScienceVersions.atomicVersion): Unit = project.run { /**
* Use kotlinx-atmicfu plugin and library
*/
fun useAtomic(
version: String = KScienceVersions.atomicVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
): Unit = project.run {
plugins.apply("kotlinx-atomicfu") plugins.apply("kotlinx-atomicfu")
useCommonDependency( useCommonDependency(
"org.jetbrains.kotlinx:atomicfu:$version" "org.jetbrains.kotlinx:atomicfu:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
) )
} }
/**
* Use core serialization library and configure targets
*/
fun useSerialization( fun useSerialization(
version: String = KScienceVersions.serializationVersion, version: String = KScienceVersions.serializationVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN, sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
@ -79,26 +94,20 @@ class KScienceExtension(val project: Project) {
SerializationTargets(sourceSet, configuration).apply(block) SerializationTargets(sourceSet, configuration).apply(block)
} }
fun useAtomic(
version: String = KScienceVersions.atomicVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
): Unit = project.run {
plugins.apply("kotlinx-atomicfu")
useCommonDependency(
"org.jetbrains.kotlinx:atomicfu-common:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
}
fun useFx( fun useFx(
vararg modules: FXModule, vararg modules: FXModule,
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
version: String = "14", version: String = "11",
platform: FXPlatform = defaultPlatform platform: FXPlatform = defaultPlatform
) = project.useFx(modules.toList(), configuration, version, platform) ) = project.useFx(modules.toList(), configuration, version, platform)
/**
* Use kotlinx-datetime library with default version or [version]
*/
fun useDateTime(version: String = KScienceVersions.dateTimeVersion){
project.useCommonDependency("org.jetbrains.kotlinx:kotlinx-datetime:$version")
}
/** /**
* Mark this module as an application module. JVM application should be enabled separately * Mark this module as an application module. JVM application should be enabled separately
*/ */

View File

@ -17,10 +17,12 @@ import ru.mipt.npm.gradle.internal.setupPublication
class KSciencePublishingExtension(val project: Project) { class KSciencePublishingExtension(val project: Project) {
private var initializedFlag = false private var initializedFlag = false
fun setup(vcsUrl: String){ fun configurePublications(vcsUrl: String){
if(!initializedFlag) {
project.setupPublication(vcsUrl) project.setupPublication(vcsUrl)
initializedFlag = true initializedFlag = true
} }
}
/** /**
* github publishing * github publishing
@ -28,7 +30,7 @@ class KSciencePublishingExtension(val project: Project) {
fun github(githubProject: String, githubOrg: String = "mipt-npm") { fun github(githubProject: String, githubOrg: String = "mipt-npm") {
//automatically initialize vcs using github //automatically initialize vcs using github
if(!initializedFlag){ if(!initializedFlag){
setup("https://github.com/$githubOrg/$githubProject") configurePublications("https://github.com/$githubOrg/$githubProject")
} }
project.addGithubPublishing(githubOrg, githubProject) project.addGithubPublishing(githubOrg, githubProject)
} }
@ -37,7 +39,7 @@ class KSciencePublishingExtension(val project: Project) {
* Space publishing * Space publishing
*/ */
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") { fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") {
require(initializedFlag){"The publishing is not set up use 'setup' method to do so"} require(initializedFlag){"The publishing is not set up use 'configurePublications' method to do so"}
project.addSpacePublishing(spaceRepo) project.addSpacePublishing(spaceRepo)
} }
@ -48,10 +50,10 @@ class KSciencePublishingExtension(val project: Project) {
// var bintrayRepo: String? by project.extra // var bintrayRepo: String? by project.extra
/** /**
* Sonatype publising * Sonatype publishing
*/ */
fun sonatype(){ fun sonatype(){
require(initializedFlag){"The publishing is not set up use 'setup' method to do so"} require(initializedFlag){"The publishing is not set up use 'configurePublications' method to do so"}
project.addSonatypePublishing() project.addSonatypePublishing()
} }
} }

View File

@ -6,13 +6,14 @@ import org.gradle.api.JavaVersion
* Build constants * Build constants
*/ */
object KScienceVersions { object KScienceVersions {
const val kotlinVersion = "1.4.31" const val kotlinVersion = "1.4.32"
const val kotlinxNodeVersion = "0.0.7" const val kotlinxNodeVersion = "0.0.7"
const val coroutinesVersion = "1.4.3" 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.2" const val ktorVersion = "1.5.2"
const val htmlVersion = "0.7.2" const val htmlVersion = "0.7.2"
const val dateTimeVersion = "0.1.1"
val JVM_TARGET = JavaVersion.VERSION_11 val JVM_TARGET = JavaVersion.VERSION_11

View File

@ -22,10 +22,7 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
internal fun RepositoryHandler.applyRepos(): Unit { internal fun RepositoryHandler.applyRepos(): Unit {
mavenCentral() mavenCentral()
maven("https://repo.kotlin.link") maven("https://repo.kotlin.link")
maven("https://dl.bintray.com/kotlin/kotlin-eap") maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://kotlin.bintray.com/kotlinx")
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
} }
internal fun Copy.fromJsDependencies(configurationName: String) = project.afterEvaluate { internal fun Copy.fromJsDependencies(configurationName: String) = project.afterEvaluate {

View File

@ -59,6 +59,7 @@ internal fun Project.setupPublication(vcs: String) = allprojects {
} }
// Process each publication we have in this project // Process each publication we have in this project
afterEvaluate {
publications.withType<MavenPublication>().forEach { publication -> publications.withType<MavenPublication>().forEach { publication ->
publication.artifact(dokkaJar) publication.artifact(dokkaJar)
publication.pom { publication.pom {
@ -93,12 +94,13 @@ internal fun Project.setupPublication(vcs: String) = allprojects {
} }
} }
} }
}
internal fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT") internal fun Project.isSnapshot() = version.toString().contains("dev") || version.toString().endsWith("SNAPSHOT")
internal val Project.publicationTarget: String internal val Project.publicationTarget: String
get() { get() {
val publicationPlatform = project.findProperty("publication.platform") as? String val publicationPlatform = project.findProperty("publishing.platform") as? String
return if (publicationPlatform == null) { return if (publicationPlatform == null) {
"AllPublications" "AllPublications"
} else { } else {
@ -110,8 +112,12 @@ internal fun Project.addGithubPublishing(
githubOrg: String, githubOrg: String,
githubProject: String githubProject: String
) { ) {
if (requestPropertyOrNull("publishing.enabled") != "true") {
logger.info("Skipping github publishing because publishing is disabled")
return
}
if (requestPropertyOrNull("publishing.github") == "false") { if (requestPropertyOrNull("publishing.github") == "false") {
logger.info("Skipping github publishing based on flag value") logger.info("Skipping github publishing because `publishing.github == false`")
return return
} }
@ -140,8 +146,12 @@ internal fun Project.addGithubPublishing(
} }
internal fun Project.addSpacePublishing(spaceRepo: String) { internal fun Project.addSpacePublishing(spaceRepo: String) {
if (requestPropertyOrNull("publishing.enabled") != "true") {
logger.info("Skipping github publishing because publishing is disabled")
return
}
if (requestPropertyOrNull("publishing.space") == "false") { if (requestPropertyOrNull("publishing.space") == "false") {
logger.info("Skipping space publishing based on flag value") logger.info("Skipping space publishing because `publishing.space == false`")
return return
} }
@ -171,12 +181,16 @@ internal fun Project.addSpacePublishing(spaceRepo: String) {
} }
internal fun Project.addSonatypePublishing() { internal fun Project.addSonatypePublishing() {
if(requestPropertyOrNull("publishing.enabled")!="true"){
logger.info("Skipping github publishing because publishing is disabled")
return
}
if (isSnapshot()) { if (isSnapshot()) {
logger.info("Sonatype publishing skipped for dev version") logger.info("Sonatype publishing skipped for dev version")
return return
} }
if (requestPropertyOrNull("publishing.sonatype") == "false") { if (requestPropertyOrNull("publishing.sonatype") == "false") {
logger.info("Skipping sonatype publishing based on flag value") logger.info("Skipping sonatype publishing because `publishing.sonatype == false`")
return return
} }