Dev #41
@ -1,11 +1,11 @@
|
||||
[versions]
|
||||
tools = "0.10.7"
|
||||
tools = "0.10.8-kotlin-1.6.0"
|
||||
kotlin = "1.6.0"
|
||||
atomicfu = "0.17.0"
|
||||
binary-compatibility-validator = "0.8.0"
|
||||
changelog = "1.3.1"
|
||||
dokka = "1.6.0"
|
||||
kotlin-jupyter = "0.11.0-6"
|
||||
kotlin-jupyter = "0.11.0-39"
|
||||
kotlinx-benchmark = "0.3.1"
|
||||
kotlinx-cli = "0.3.3"
|
||||
kotlinx-collections-immutable = "0.3.4"
|
||||
@ -15,10 +15,10 @@ kotlinx-html = "0.7.3"
|
||||
kotlinx-knit = "0.3.0"
|
||||
kotlinx-nodejs = "0.0.7"
|
||||
kotlinx-serialization = "1.3.1"
|
||||
ktor = "1.6.5"
|
||||
ktor = "1.6.6"
|
||||
xmlutil = "0.83.0"
|
||||
yamlkt = "0.10.2"
|
||||
jsBom = "0.0.1-pre.265-kotlin-1.5.31"
|
||||
jsBom = "0.0.1-pre.279-kotlin-1.6.0"
|
||||
junit = "5.8.1"
|
||||
|
||||
[libraries]
|
||||
|
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-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -2,169 +2,10 @@ package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import ru.mipt.npm.gradle.internal.applyRepos
|
||||
import ru.mipt.npm.gradle.internal.applySettings
|
||||
import ru.mipt.npm.gradle.internal.fromJsDependencies
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
public open class KScienceCommonPlugin : Plugin<Project> {
|
||||
public companion object {
|
||||
public val defaultJvmArgs: List<String> = listOf("-Xjvm-default=all", "-Xlambdas=indy")
|
||||
}
|
||||
|
||||
|
||||
override fun apply(project: Project): Unit = project.run {
|
||||
//Common configuration
|
||||
registerKScienceExtension()
|
||||
repositories.applyRepos()
|
||||
|
||||
//Configuration for K-JVM plugin
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
//logger.info("Applying KScience configuration for JVM project")
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<KotlinJvmCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
||||
}
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
//logger.info("Applying KScience configuration for JS project")
|
||||
configure<KotlinJsProjectExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(tasks.findByName("processResources") as? Copy)?.apply {
|
||||
fromJsDependencies("runtimeClasspath")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
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"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||
}
|
||||
}
|
||||
val jsMain by getting
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings()
|
||||
}
|
||||
|
||||
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
||||
fromJsDependencies("jsRuntimeClasspath")
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
||||
override fun apply(project: Project): Unit = project.configureKScience(
|
||||
KotlinVersion(1, 6, 0)
|
||||
)
|
||||
}
|
||||
|
@ -54,10 +54,18 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_VARIABLE") private val release by project.tasks.creating {
|
||||
group = KScienceProjectPlugin.RELEASE_GROUP
|
||||
description = "Publish development or production release based on version suffix"
|
||||
}
|
||||
|
||||
private fun linkPublicationsToReleaseTask(name: String) = project.afterEvaluate {
|
||||
allTasks()
|
||||
.filter { it.name == "publish${publicationTarget}To${name.capitalize()}Repository" }
|
||||
.forEach { releaseTask?.dependsOn(it) }
|
||||
.forEach {
|
||||
logger.info("Linking $it to release")
|
||||
release.dependsOn(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,40 +73,42 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
*
|
||||
* @param githubProject the GitHub project.
|
||||
* @param githubOrg the GitHub user or organization.
|
||||
* @param release whether publish packages in the `release` task to the GitHub repository.
|
||||
* @param publish add publish task for github.
|
||||
* @param addToRelease publish packages in the `release` task to the GitHub repository.
|
||||
*/
|
||||
public fun github(
|
||||
githubProject: String,
|
||||
githubOrg: String = "mipt-npm",
|
||||
release: Boolean = false,
|
||||
publish: Boolean = true
|
||||
addToRelease: Boolean = project.requestPropertyOrNull("publishing.github") == "true",
|
||||
) {
|
||||
// Automatically initialize VCS using GitHub
|
||||
if (!isVcsInitialized) {
|
||||
git("https://github.com/$githubOrg/${githubProject}", "https://github.com/$githubOrg/${githubProject}.git")
|
||||
}
|
||||
|
||||
if (publish) project.addGithubPublishing(githubOrg, githubProject)
|
||||
if (release) linkPublicationsToReleaseTask("github")
|
||||
}
|
||||
|
||||
private val releaseTask by lazy {
|
||||
project.tasks.findByName("release")
|
||||
if (addToRelease) {
|
||||
try {
|
||||
project.addGithubPublishing(githubOrg, githubProject)
|
||||
linkPublicationsToReleaseTask("github")
|
||||
} catch (t: Throwable){
|
||||
project.logger.error("Failed to set up github publication", t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Space Packages Maven repository to publishing.
|
||||
*
|
||||
* @param spaceRepo the repository URL.
|
||||
* @param release whether publish packages in the `release` task to the Space repository.
|
||||
* @param addToRelease publish packages in the `release` task to the Space repository.
|
||||
*/
|
||||
public fun space(
|
||||
spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven",
|
||||
release: Boolean = true
|
||||
addToRelease: Boolean = project.requestPropertyOrNull("publishing.space") != "false",
|
||||
) {
|
||||
project.addSpacePublishing(spaceRepo)
|
||||
|
||||
if (release) linkPublicationsToReleaseTask("space")
|
||||
if (addToRelease) linkPublicationsToReleaseTask("space")
|
||||
}
|
||||
|
||||
// // Bintray publishing
|
||||
@ -110,13 +120,15 @@ public class KSciencePublishingExtension(public val project: Project) {
|
||||
/**
|
||||
* Adds Sonatype Maven repository to publishing.
|
||||
*
|
||||
* @param release whether publish packages in the `release` task to the Sonatype repository.
|
||||
* @param addToRelease publish packages in the `release` task to the Sonatype repository.
|
||||
*/
|
||||
public fun sonatype(release: Boolean = true) {
|
||||
public fun sonatype(
|
||||
addToRelease: Boolean = (project.requestPropertyOrNull("publishing.sonatype") != "false"),
|
||||
) {
|
||||
require(isVcsInitialized) { "The project vcs is not set up use 'git' method to do so" }
|
||||
project.addSonatypePublishing()
|
||||
|
||||
if (release) linkPublicationsToReleaseTask("sonatype")
|
||||
if (addToRelease) linkPublicationsToReleaseTask("sonatype")
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,14 +258,6 @@ public open class KScienceProjectPlugin : Plugin<Project> {
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
//val patchChangelog by tasks.getting
|
||||
|
||||
@Suppress("UNUSED_VARIABLE") val release by tasks.creating {
|
||||
group = RELEASE_GROUP
|
||||
description = "Publish development or production release based on version suffix"
|
||||
dependsOn(generateReadme)
|
||||
}
|
||||
|
||||
// Disable API validation for snapshots
|
||||
if (isSnapshot()) {
|
||||
extensions.findByType<ApiValidationExtension>()?.apply {
|
||||
|
166
src/main/kotlin/ru/mipt/npm/gradle/commonConfigurations.kt
Normal file
166
src/main/kotlin/ru/mipt/npm/gradle/commonConfigurations.kt
Normal file
@ -0,0 +1,166 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.dokka.gradle.DokkaPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import ru.mipt.npm.gradle.internal.applyRepos
|
||||
import ru.mipt.npm.gradle.internal.applySettings
|
||||
import ru.mipt.npm.gradle.internal.fromJsDependencies
|
||||
|
||||
|
||||
private val defaultJvmArgs: List<String> = listOf("-Xjvm-default=all", "-Xlambdas=indy")
|
||||
|
||||
public fun Project.configureKScience(
|
||||
kotlinVersion: KotlinVersion
|
||||
){
|
||||
//Common configuration
|
||||
registerKScienceExtension()
|
||||
repositories.applyRepos()
|
||||
|
||||
//Configuration for K-JVM plugin
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
//logger.info("Applying KScience configuration for JVM project")
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings(kotlinVersion)
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<KotlinJvmCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
||||
}
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
//logger.info("Applying KScience configuration for JS project")
|
||||
configure<KotlinJsProjectExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings(kotlinVersion)
|
||||
}
|
||||
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["test"].apply {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(tasks.findByName("processResources") as? Copy)?.apply {
|
||||
fromJsDependencies("runtimeClasspath")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
explicitApiWarning()
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + defaultJvmArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
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"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit5"))
|
||||
implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}")
|
||||
}
|
||||
}
|
||||
val jsMain by getting
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
languageSettings.applySettings(kotlinVersion)
|
||||
}
|
||||
|
||||
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
|
||||
fromJsDependencies("jsRuntimeClasspath")
|
||||
}
|
||||
|
||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// apply dokka for all projects
|
||||
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
|
||||
apply<DokkaPlugin>()
|
||||
}
|
||||
}
|
@ -11,9 +11,12 @@ import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
|
||||
internal fun LanguageSettingsBuilder.applySettings() {
|
||||
languageVersion = "1.6"
|
||||
apiVersion = "1.6"
|
||||
internal fun LanguageSettingsBuilder.applySettings(
|
||||
kotlinVersion: KotlinVersion
|
||||
) {
|
||||
val versionString = "${kotlinVersion.major}.${kotlinVersion.minor}"
|
||||
languageVersion = versionString
|
||||
apiVersion = versionString
|
||||
progressiveMode = true
|
||||
|
||||
optIn("kotlin.RequiresOptIn")
|
||||
|
@ -11,10 +11,10 @@ import org.gradle.plugins.signing.SigningPlugin
|
||||
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
|
||||
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
|
||||
?: System.getenv(propertyName)
|
||||
|
||||
private fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||
internal fun Project.requestProperty(propertyName: String): String = requestPropertyOrNull(propertyName)
|
||||
?: error("Property $propertyName not defined")
|
||||
|
||||
|
||||
@ -126,8 +126,8 @@ internal fun Project.addGithubPublishing(
|
||||
logger.info("Skipping github publishing because publishing is disabled")
|
||||
return
|
||||
}
|
||||
if (requestPropertyOrNull("publishing.github") == "false") {
|
||||
logger.info("Skipping github publishing because `publishing.github == false`")
|
||||
if (requestPropertyOrNull("publishing.github") != "false") {
|
||||
logger.info("Skipping github publishing because `publishing.github != true`")
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user