Space publishing

This commit is contained in:
Alexander Nozik 2020-07-05 14:39:35 +03:00
parent 7a282fa207
commit 615b06eb8c
13 changed files with 270 additions and 260 deletions

View File

@ -4,10 +4,11 @@ plugins {
`kotlin-dsl` `kotlin-dsl`
`maven-publish` `maven-publish`
id("com.jfrog.bintray") version "1.8.5" id("com.jfrog.bintray") version "1.8.5"
id("org.jetbrains.changelog") version "0.3.2"
} }
group = "scientifik" group = "scientifik"
version = "0.5.0" version = "0.5.1"
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
@ -55,12 +56,6 @@ gradlePlugin {
description = "Pre-configured JS project" description = "Pre-configured JS project"
implementationClass = "scientifik.ScientifikJSPlugin" implementationClass = "scientifik.ScientifikJSPlugin"
} }
// create("scientifik-atomic") {
// id = "scientifik.atomic"
// description = "Add kotlin atomic plugin to any flafor"
// implementationClass = "scientifik.ScientifikAtomicPlugin"
// }
} }
} }

Binary file not shown.

View File

@ -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.2.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath

1
gradlew.bat vendored
View File

@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

View File

@ -4,14 +4,14 @@ import org.gradle.api.JavaVersion
* Build constants * Build constants
*/ */
object Scientifik { object Scientifik {
const val coroutinesVersion = "1.3.4" const val coroutinesVersion = "1.3.7"
const val serializationVersion = "0.20.0" const val serializationVersion = "0.20.0"
const val atomicVersion = "0.14.3"
val JVM_TARGET = JavaVersion.VERSION_11 val JVM_TARGET = JavaVersion.VERSION_1_8
// val JVM_VERSION = JVM_TARGET.toString()
object Serialization{ object Serialization{
const val xmlVersion = "0.20.0.0" const val xmlVersion = "0.20.0.1"
const val yamlVersion = "0.16.1" const val yamlVersion = "0.16.1"
const val bsonVersion = "0.2.1" const val bsonVersion = "0.2.1"
} }

View File

@ -10,59 +10,56 @@ import org.gradle.kotlin.dsl.getting
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
open class ScientifikJSPlugin : Plugin<Project> { open class ScientifikJSPlugin : Plugin<Project> {
override fun apply(project: Project) { override fun apply(project: Project): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.js")
with(project) { repositories.applyRepos()
plugins.apply("org.jetbrains.kotlin.js")
repositories.applyRepos() configure<KotlinJsProjectExtension> {
target {
configure<KotlinJsProjectExtension> { browser {
target { webpackTask {
browser { outputFileName = "main.bundle.js"
webpackTask {
outputFileName = "main.bundle.js"
}
distribution {
directory = project.jsDistDirectory
}
} }
} distribution {
sourceSets["main"].apply { directory = project.jsDistDirectory
languageSettings.applySettings()
dependencies {
api(kotlin("stdlib-js"))
}
}
sourceSets["test"].apply {
languageSettings.applySettings()
dependencies {
implementation(kotlin("test-js"))
} }
} }
} }
sourceSets["main"].apply {
languageSettings.applySettings()
tasks.apply { dependencies {
api(kotlin("stdlib-js"))
val processResources by getting(Copy::class)
processResources.copyJSResources(configurations["runtimeClasspath"])
val browserDistribution by getting {
doLast {
val indexFile = project.jsDistDirectory.resolve("index.html")
if (indexFile.exists()) {
println("Run JS distribution at: ${indexFile.canonicalPath}")
}
}
group = "distribution"
} }
}
// findByName("assemble")?.dependsOn(installJsDist) sourceSets["test"].apply {
languageSettings.applySettings()
dependencies {
implementation(kotlin("test-js"))
}
} }
} }
tasks.apply {
val processResources by getting(Copy::class)
processResources.copyJSResources(configurations["runtimeClasspath"])
val browserDistribution by getting {
doLast {
val indexFile = project.jsDistDirectory.resolve("index.html")
if (indexFile.exists()) {
println("Run JS distribution at: ${indexFile.canonicalPath}")
}
}
group = "distribution"
}
// findByName("assemble")?.dependsOn(installJsDist)
}
} }
} }

View File

@ -15,87 +15,85 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
open class ScientifikJVMPlugin : Plugin<Project> { open class ScientifikJVMPlugin : Plugin<Project> {
override fun apply(project: Project) { override fun apply(project: Project): Unit = project.run {
with(project) { plugins.apply("org.jetbrains.kotlin.jvm")
plugins.apply("org.jetbrains.kotlin.jvm")
repositories.applyRepos() repositories.applyRepos()
extensions.findByType<JavaPluginExtension>()?.apply { extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = Scientifik.JVM_TARGET targetCompatibility = Scientifik.JVM_TARGET
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions { kotlinOptions {
jvmTarget = Scientifik.JVM_TARGET.toString() jvmTarget = Scientifik.JVM_TARGET.toString()
}
}
configure<KotlinJvmProjectExtension> {
val sourceSet = sourceSets["main"].apply {
languageSettings.applySettings()
dependencies {
api(kotlin("stdlib-jdk8"))
}
}
sourceSets["test"].apply {
languageSettings.applySettings()
dependencies {
implementation(kotlin("test"))
// implementation(kotlin("test-junit"))
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
}
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSet.kotlin.srcDirs.first())
}
pluginManager.withPlugin("maven-publish") {
configure<PublishingExtension> {
publications {
register("jvm", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
}
}
}
pluginManager.withPlugin("org.jetbrains.dokka") {
logger.info("Adding dokka functionality to project ${this@with.name}")
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
}
val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}
configure<PublishingExtension> {
publications {
getByName("jvm") {
this as MavenPublication
artifact(kdocJar.get())
}
}
}
}
}
}
tasks.withType<Test>(){
useJUnitPlatform()
} }
} }
configure<KotlinJvmProjectExtension> {
val sourceSet = sourceSets["main"].apply {
languageSettings.applySettings()
dependencies {
api(kotlin("stdlib-jdk8"))
}
}
sourceSets["test"].apply {
languageSettings.applySettings()
dependencies {
implementation(kotlin("test"))
// implementation(kotlin("test-junit"))
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
}
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSet.kotlin.srcDirs.first())
}
pluginManager.withPlugin("maven-publish") {
configure<PublishingExtension> {
publications {
register("jvm", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
}
}
}
pluginManager.withPlugin("org.jetbrains.dokka") {
logger.info("Adding dokka functionality to project ${project.name}")
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
}
val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}
configure<PublishingExtension> {
publications {
getByName("jvm") {
this as MavenPublication
artifact(kdocJar.get())
}
}
}
}
}
}
tasks.withType<Test>() {
useJUnitPlatform()
}
} }
}
}

View File

@ -14,127 +14,125 @@ import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
open class ScientifikMPPlugin : Plugin<Project> { open class ScientifikMPPlugin : Plugin<Project> {
override fun apply(project: Project) { override fun apply(project: Project): Unit = project.run {
project.run {
plugins.apply("org.jetbrains.kotlin.multiplatform") plugins.apply("org.jetbrains.kotlin.multiplatform")
repositories.applyRepos() repositories.applyRepos()
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {
jvm { jvm {
compilations.all { compilations.all {
kotlinOptions { kotlinOptions {
jvmTarget = Scientifik.JVM_TARGET.toString() jvmTarget = Scientifik.JVM_TARGET.toString()
}
} }
} }
val js = js {
browser {
webpackTask {
outputFileName = "main.bundle.js"
}
distribution {
directory = project.jsDistDirectory
}
}
}
sourceSets.invoke {
val commonMain by getting {
dependencies {
api(kotlin("stdlib"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
api(kotlin("stdlib-jdk8"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
// implementation(kotlin("test-junit"))
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
}
}
val jsMain by getting {
dependencies {
api(kotlin("stdlib-js"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
targets.all {
sourceSets.all {
languageSettings.applySettings()
}
}
pluginManager.withPlugin("org.jetbrains.dokka") {
logger.info("Adding dokka functionality to project ${this@run.name}")
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
multiplatform {
}
}
val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}
pluginManager.withPlugin("maven-publish") {
configure<PublishingExtension> {
targets.all {
val publication = publications.findByName(name) as MavenPublication
// Patch publications with fake javadoc
publication.artifact(kdocJar.get())
}
}
}
}
tasks.apply {
val jsProcessResources by getting(Copy::class)
jsProcessResources.copyJSResources(configurations["jsRuntimeClasspath"])
val jsBrowserDistribution by getting {
doLast {
val indexFile = project.jsDistDirectory.resolve("index.html")
if (indexFile.exists()) {
println("Run JS distribution at: ${indexFile.canonicalPath}")
}
}
group = "distribution"
}
withType<Test>() {
useJUnitPlatform()
}
}
} }
val js = js {
browser {
webpackTask {
outputFileName = "main.bundle.js"
}
distribution {
directory = project.jsDistDirectory
}
}
}
sourceSets.invoke {
val commonMain by getting {
dependencies {
api(kotlin("stdlib"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
api(kotlin("stdlib-jdk8"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
// implementation(kotlin("test-junit"))
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
}
}
val jsMain by getting {
dependencies {
api(kotlin("stdlib-js"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
targets.all {
sourceSets.all {
languageSettings.applySettings()
}
}
pluginManager.withPlugin("org.jetbrains.dokka") {
logger.info("Adding dokka functionality to project ${this@run.name}")
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
multiplatform {
}
}
val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}
pluginManager.withPlugin("maven-publish") {
configure<PublishingExtension> {
targets.all {
val publication = publications.findByName(name) as MavenPublication
// Patch publications with fake javadoc
publication.artifact(kdocJar.get())
}
}
}
}
tasks.apply {
val jsProcessResources by getting(Copy::class)
jsProcessResources.copyJSResources(configurations["jsRuntimeClasspath"])
val jsBrowserDistribution by getting {
doLast {
val indexFile = project.jsDistDirectory.resolve("index.html")
if (indexFile.exists()) {
println("Run JS distribution at: ${indexFile.canonicalPath}")
}
}
group = "distribution"
}
withType<Test>() {
useJUnitPlatform()
}
}
} }
} }
} }

View File

@ -15,14 +15,14 @@ open class ScientifikPublishPlugin : Plugin<Project> {
project.plugins.apply("maven-publish") project.plugins.apply("maven-publish")
project.run { project.afterEvaluate {
val githubProject = findProperty("githubProject") as? String val githubProject = findProperty("githubProject") as? String
val vcs = findProperty("vcs") as? String val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/mipt-npm/$it" } ?: githubProject?.let { "https://github.com/mipt-npm/$it" }
if (vcs == null) { if (vcs == null) {
project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
return@apply return@afterEvaluate
} }
project.configure<PublishingExtension> { project.configure<PublishingExtension> {
@ -75,6 +75,24 @@ open class ScientifikPublishPlugin : Plugin<Project> {
} }
} }
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 bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
val bintrayUser = project.findProperty("bintrayUser") as? String val bintrayUser = project.findProperty("bintrayUser") as? String

View File

@ -21,7 +21,7 @@ enum class DependencySourceSet(val setName: String, val suffix: String) {
internal fun Project.useDependency( internal fun Project.useDependency(
vararg pairs: Pair<String, String>, vararg pairs: Pair<String, String>,
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN, dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.API dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
) { ) {
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.findByType<KotlinMultiplatformExtension>()?.apply { extensions.findByType<KotlinMultiplatformExtension>()?.apply {
@ -86,12 +86,12 @@ fun Project.useCoroutines(
dependencyConfiguration = configuration dependencyConfiguration = configuration
) )
//fun Project.atomic(version: String = Scientifik.atomicfuVersion) { fun Project.useAtomic(version: String = Scientifik.atomicVersion) {
// plugins.apply("kotlinx-atomicfu") plugins.apply("kotlinx-atomicfu")
// useDependency( useDependency(
// "commonMain" to "org.jetbrains.kotlinx:atomicfu-common:$version", "commonMain" to "org.jetbrains.kotlinx:atomicfu-common:$version",
// "jvmMain" to "org.jetbrains.kotlinx:atomicfu:$version", "jvmMain" to "org.jetbrains.kotlinx:atomicfu:$version",
// "jsMain" to "org.jetbrains.kotlinx:atomicfu-js:$version", "jsMain" to "org.jetbrains.kotlinx:atomicfu-js:$version",
// "nativeMain" to "org.jetbrains.kotlinx:atomicfu-native:$version" "nativeMain" to "org.jetbrains.kotlinx:atomicfu-native:$version"
// ) )
//} }

View File

@ -30,7 +30,7 @@ val defaultPlatform: FXPlatform = when {
else -> error("Platform not recognized") else -> error("Platform not recognized")
} }
fun KotlinDependencyHandler.addFXDependencies( private fun KotlinDependencyHandler.addFXDependencies(
vararg modules: FXModule, vararg modules: FXModule,
configuration: DependencyConfiguration, configuration: DependencyConfiguration,
version: String = "14", version: String = "14",

View File

@ -83,7 +83,8 @@ fun Project.useSerialization(
"jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$version", "jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$version",
"js" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$version", "js" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$version",
"native" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$version", "native" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$version",
dependencySourceSet = sourceSet dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
) )
SerializationTargets(sourceSet, configuration).apply(block) SerializationTargets(sourceSet, configuration).apply(block)
} }