Merge pull request #16 from mipt-npm/dev

0.10.0
This commit is contained in:
Alexander Nozik 2021-06-19 14:12:34 +03:00 committed by GitHub
commit 8fe085c4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 149 additions and 87 deletions

View File

@ -16,6 +16,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security
## [0.10.0]
### Added
- Lazy readme properties
- BOM for kotlin-wrappers on JS
- Jupyter loader
### Changed
- API validation disabled for dev versions
- Kotlin plugins are propagated downstream
### Deprecated
### Removed
- bson support
### Fixed
### Security
## [0.9.5]

View File

@ -8,7 +8,7 @@ plugins {
}
group = "ru.mipt.npm"
version = "0.9.5"
version = "0.10.0"
description = "Build tools for DataForge and kscience projects"
@ -22,20 +22,20 @@ repositories {
maven("https://repo.kotlin.link")
}
val kotlinVersion = "1.5.0"
val kotlinVersion = "1.5.10"
java {
targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_11
}
// Add plugins used in buildSrc as dependencies, also we should specify version only here
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin:0.10.0-53")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.16.1")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32")
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.1.2")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.5.0")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.6.0")
}
project.extensions.findByType<GradlePluginDevelopmentExtension>()?.apply {

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0
gradlew vendored Normal file → Executable file
View File

View File

@ -1,2 +0,0 @@
rootProject.name = 'gradle-tools'

1
settings.gradle.kts Normal file
View File

@ -0,0 +1 @@
rootProject.name = "gradle-tools"

View File

@ -14,6 +14,7 @@ import ru.mipt.npm.gradle.internal.applyRepos
import ru.mipt.npm.gradle.internal.applySettings
import ru.mipt.npm.gradle.internal.fromJsDependencies
@Suppress("UNUSED_VARIABLE")
open class KScienceCommonPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
//Common configuration
@ -40,7 +41,6 @@ open class KScienceCommonPlugin : Plugin<Project> {
}
tasks.withType<KotlinJvmCompile> {
kotlinOptions {
useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
}
@ -63,7 +63,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
explicitApiWarning()
js(IR) {
browser{
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
@ -72,6 +72,9 @@ open class KScienceCommonPlugin : Plugin<Project> {
sourceSets["main"].apply {
languageSettings.applySettings()
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
sourceSets["test"].apply {
@ -95,7 +98,6 @@ open class KScienceCommonPlugin : Plugin<Project> {
jvm {
compilations.all {
kotlinOptions {
useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
}
@ -103,7 +105,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
}
js(IR) {
browser{
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
@ -111,7 +113,11 @@ open class KScienceCommonPlugin : Plugin<Project> {
}
sourceSets.invoke {
val commonMain by getting
val commonMain by getting {
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))

View File

@ -2,8 +2,6 @@ package ru.mipt.npm.gradle
import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
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
@ -49,7 +47,7 @@ class KScienceExtension(val project: Project) {
fun useCoroutines(
version: String = KScienceVersions.coroutinesVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API
configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
dependencySourceSet = sourceSet,
@ -62,7 +60,7 @@ class KScienceExtension(val project: Project) {
fun useAtomic(
version: String = KScienceVersions.atomicVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION,
): Unit = project.run {
plugins.apply("kotlinx-atomicfu")
useCommonDependency(
@ -79,7 +77,7 @@ class KScienceExtension(val project: Project) {
version: String = KScienceVersions.serializationVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
block: SerializationTargets.() -> Unit = {}
block: SerializationTargets.() -> Unit = {},
): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
val artifactName = if (version.startsWith("0")) {
@ -95,17 +93,23 @@ class KScienceExtension(val project: Project) {
SerializationTargets(sourceSet, configuration).apply(block)
}
/**
* Add platform-specific JavaFX dependencies with given list of [FXModule]s
*/
fun useFx(
vararg modules: FXModule,
configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY,
version: String = "11",
platform: FXPlatform = defaultPlatform
platform: FXPlatform = defaultPlatform,
) = project.useFx(modules.toList(), configuration, version, platform)
/**
* Add dependency on kotlinx-html library
*/
fun useHtml(
version: String = KScienceVersions.atomicVersion,
version: String = KScienceVersions.htmlVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
configuration: DependencyConfiguration = DependencyConfiguration.API,
): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-html:$version",
dependencySourceSet = sourceSet,
@ -115,8 +119,23 @@ class KScienceExtension(val project: Project) {
/**
* Use kotlinx-datetime library with default version or [version]
*/
fun useDateTime(version: String = KScienceVersions.dateTimeVersion){
project.useCommonDependency("org.jetbrains.kotlinx:kotlinx-datetime:$version")
fun useDateTime(
version: String = KScienceVersions.dateTimeVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.API,
) {
project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-datetime:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
}
/**
* Apply jupyter plugin
*/
fun useJupyter() {
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
}
/**
@ -146,10 +165,6 @@ class KScienceExtension(val project: Project) {
}
}
}
fun publish() {
project.plugins.apply(MavenPublishPlugin::class)
}
}
internal fun Project.registerKScienceExtension() {

View File

@ -7,6 +7,8 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.changelog.ChangelogPluginExtension
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.dokka.gradle.DokkaTask
import ru.mipt.npm.gradle.internal.*
@ -15,7 +17,7 @@ import ru.mipt.npm.gradle.internal.*
class KSciencePublishingExtension(val project: Project) {
private var initializedFlag = false
fun configurePublications(vcsUrl: String) {
fun vcs(vcsUrl: String) {
if (!initializedFlag) {
project.setupPublication(vcsUrl)
initializedFlag = true
@ -24,21 +26,37 @@ class KSciencePublishingExtension(val project: Project) {
/**
* github publishing
* @param publish include github packages in release publishing. By default - false
*/
fun github(githubProject: String, githubOrg: String = "mipt-npm") {
fun github(githubProject: String, githubOrg: String = "mipt-npm", publish: Boolean = false) {
//automatically initialize vcs using github
if (!initializedFlag) {
configurePublications("https://github.com/$githubOrg/$githubProject")
vcs("https://github.com/$githubOrg/$githubProject")
}
project.addGithubPublishing(githubOrg, githubProject)
if (publish) {
project.tasks.findByName("publish${project.publicationTarget}ToGithubRepository")?.let {publicationTask->
releaseTask?.dependsOn(publicationTask)
}
}
}
private val releaseTask by lazy {
project.tasks.findByName("release")
}
/**
* Space publishing
*/
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") {
require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" }
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven", publish: Boolean = false) {
require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" }
project.addSpacePublishing(spaceRepo)
if (publish) {
project.tasks.findByName("publish${project.publicationTarget}ToSpaceRepository")?.let { publicationTask ->
releaseTask?.dependsOn(publicationTask)
}
}
}
// // Bintray publishing
@ -50,9 +68,15 @@ class KSciencePublishingExtension(val project: Project) {
/**
* Sonatype publishing
*/
fun sonatype() {
require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" }
fun sonatype(publish: Boolean = true) {
require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" }
project.addSonatypePublishing()
if (publish) {
project.tasks.findByName("publish${project.publicationTarget}ToSonatypeRepository")
?.let { publicationTask ->
releaseTask?.dependsOn(publicationTask)
}
}
}
}
@ -63,9 +87,22 @@ class KSciencePublishingExtension(val project: Project) {
open class KScienceProjectPlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run {
apply<ChangelogPlugin>()
apply<DokkaPlugin>()
apply<BinaryCompatibilityValidatorPlugin>()
afterEvaluate {
if (isSnapshot()) {
configure<ApiValidationExtension> {
validationDisabled = true
}
} else {
configure<ChangelogPluginExtension> {
version = project.version.toString()
}
}
}
val rootReadmeExtension = KScienceReadmeExtension(this)
extensions.add("ksciencePublish", KSciencePublishingExtension(this))
extensions.add("readme", rootReadmeExtension)
@ -164,7 +201,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
}
}
tasks.withType<DokkaTask> {
tasks.withType<AbstractDokkaTask> {
dependsOn(generateReadme)
}

View File

@ -36,15 +36,15 @@ class KScienceReadmeExtension(val project: Project) {
data class Feature(val id: String, val description: String, val ref: String?, val name: String = id)
val features = ArrayList<Feature>()
val features: MutableList<Feature> = ArrayList()
@Deprecated("Use lambda builder instead")
fun feature(id: String, description: String, ref: String? = null, name: String = id) {
features.add(Feature(id, description, ref, name))
features += Feature(id, description, ref, name)
}
fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) {
features.add(Feature(id, description(), ref, name))
features += Feature(id, description(), ref, name)
}
private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
@ -55,14 +55,16 @@ class KScienceReadmeExtension(val project: Project) {
)
val actualizedProperties
get() = properties.mapValues { (_, value) ->
value.invoke()
}
get() = properties.mapValues { (_, value) -> value() }
fun property(key: String, value: Any?) {
properties[key] = { value }
}
fun property(key: String, value: () -> Any?) {
properties[key] = value
}
fun propertyByTemplate(key: String, template: String) {
val actual = actualizedProperties
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
@ -73,7 +75,7 @@ class KScienceReadmeExtension(val project: Project) {
fun propertyByTemplate(key: String, template: File) {
val actual = actualizedProperties
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
additionalFiles.add(template)
additionalFiles += template
}
/**

View File

@ -6,20 +6,20 @@ import org.gradle.api.JavaVersion
* Build constants
*/
object KScienceVersions {
const val kotlinVersion = "1.5.0"
const val kotlinVersion = "1.5.10"
const val kotlinxNodeVersion = "0.0.7"
const val coroutinesVersion = "1.4.3"
const val serializationVersion = "1.1.0"
const val coroutinesVersion = "1.5.0"
const val serializationVersion = "1.2.1"
const val atomicVersion = "0.16.1"
const val ktorVersion = "1.5.3"
const val ktorVersion = "1.6.0"
const val htmlVersion = "0.7.3"
const val dateTimeVersion = "0.1.1"
const val dateTimeVersion = "0.2.1"
const val jsBom = "0.0.1-pre.213-kotlin-1.5.10"
val JVM_TARGET = JavaVersion.VERSION_11
object Serialization{
const val xmlVersion = "0.81.2"
const val bsonVersion = "0.4.4"
const val xmlVersion = "0.82.0"
const val yamlKtVersion = "0.9.0"
}
}

View File

@ -1,10 +1,7 @@
package ru.mipt.npm.gradle
import org.gradle.api.Project
import org.gradle.kotlin.dsl.maven
import org.gradle.kotlin.dsl.repositories
import ru.mipt.npm.gradle.internal.useCommonDependency
import ru.mipt.npm.gradle.internal.useDependency
class SerializationTargets(
val sourceSet: DependencySourceSet,
@ -44,11 +41,8 @@ class SerializationTargets(
fun Project.xml(
version: String = KScienceVersions.Serialization.xmlVersion
) {
repositories {
maven("https://dl.bintray.com/pdvrieze/maven")
}
useCommonDependency(
"net.devrieze:xmlutil-serialization:$version",
"io.github.pdvrieze.xmlutil:serialization:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
@ -63,14 +57,4 @@ class SerializationTargets(
dependencyConfiguration = configuration
)
}
fun Project.bson(
version: String = KScienceVersions.Serialization.bsonVersion
) {
useDependency(
"jvm" to "com.github.jershell:kbson:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
}
}

View File

@ -22,8 +22,6 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
internal fun RepositoryHandler.applyRepos(): Unit {
mavenCentral()
maven("https://repo.kotlin.link")
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
}
internal fun Copy.fromJsDependencies(configurationName: String) = project.run {

View File

@ -20,33 +20,42 @@ 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>()!!
plugins.withId("org.jetbrains.kotlin.js") {
val kotlin: KotlinJsProjectExtension = extensions.findByType()!!
val sourcesJar: Jar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets["main"].kotlin)
kotlin.sourceSets.forEach{
from(it.kotlin)
}
}
afterEvaluate {
publications {
create("js", MavenPublication::class) {
from(components["kotlin"])
kotlin.js().components.forEach {
from(it)
}
artifact(sourcesJar)
}
}
}
}
plugins.withId("ru.mipt.npm.gradle.jvm") {
plugins.withId("org.jetbrains.kotlin.jvm") {
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
val sourcesJar: Jar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets["main"].kotlin)
kotlin.sourceSets.forEach{
from(it.kotlin)
}
}
publications {
create("jvm", MavenPublication::class) {
from(components["kotlin"])
kotlin.target.components.forEach {
from(it)
}
artifact(sourcesJar)
}
}
@ -110,7 +119,7 @@ internal val Project.publicationTarget: String
internal fun Project.addGithubPublishing(
githubOrg: String,
githubProject: String
githubProject: String,
) {
if (requestPropertyOrNull("publishing.enabled") != "true") {
logger.info("Skipping github publishing because publishing is disabled")
@ -139,8 +148,6 @@ internal fun Project.addGithubPublishing(
}
}
}
val publicationTask = tasks.getByName("publish${publicationTarget}ToGithubRepository")
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
}
}
}
@ -174,8 +181,6 @@ internal fun Project.addSpacePublishing(spaceRepo: String) {
}
}
}
val publicationTask = tasks.getByName("publish${publicationTarget}ToSpaceRepository")
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
}
}
}
@ -229,8 +234,6 @@ internal fun Project.addSonatypePublishing() {
}
}
}
val publicationTask = tasks.getByName("publish${publicationTarget}ToSonatypeRepository")
rootProject.tasks.findByName("release")?.dependsOn(publicationTask)
}
}
}