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`
`maven-publish`
id("com.jfrog.bintray") version "1.8.5"
id("org.jetbrains.changelog") version "0.3.2"
}
group = "scientifik"
version = "0.5.0"
version = "0.5.1"
repositories {
gradlePluginPortal()
@ -55,12 +56,6 @@ gradlePlugin {
description = "Pre-configured JS project"
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
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
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# 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
@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%

View File

@ -4,14 +4,14 @@ import org.gradle.api.JavaVersion
* Build constants
*/
object Scientifik {
const val coroutinesVersion = "1.3.4"
const val coroutinesVersion = "1.3.7"
const val serializationVersion = "0.20.0"
const val atomicVersion = "0.14.3"
val JVM_TARGET = JavaVersion.VERSION_11
// val JVM_VERSION = JVM_TARGET.toString()
val JVM_TARGET = JavaVersion.VERSION_1_8
object Serialization{
const val xmlVersion = "0.20.0.0"
const val xmlVersion = "0.20.0.1"
const val yamlVersion = "0.16.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
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) {
plugins.apply("org.jetbrains.kotlin.js")
repositories.applyRepos()
repositories.applyRepos()
configure<KotlinJsProjectExtension> {
target {
browser {
webpackTask {
outputFileName = "main.bundle.js"
}
distribution {
directory = project.jsDistDirectory
}
configure<KotlinJsProjectExtension> {
target {
browser {
webpackTask {
outputFileName = "main.bundle.js"
}
}
sourceSets["main"].apply {
languageSettings.applySettings()
dependencies {
api(kotlin("stdlib-js"))
}
}
sourceSets["test"].apply {
languageSettings.applySettings()
dependencies {
implementation(kotlin("test-js"))
distribution {
directory = project.jsDistDirectory
}
}
}
sourceSets["main"].apply {
languageSettings.applySettings()
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"
dependencies {
api(kotlin("stdlib-js"))
}
}
// 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
open class ScientifikJVMPlugin : Plugin<Project> {
override fun apply(project: Project) {
with(project) {
plugins.apply("org.jetbrains.kotlin.jvm")
override fun apply(project: Project): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.jvm")
repositories.applyRepos()
repositories.applyRepos()
extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = Scientifik.JVM_TARGET
}
extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = Scientifik.JVM_TARGET
}
tasks.withType<KotlinCompile> {
kotlinOptions {
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()
tasks.withType<KotlinCompile> {
kotlinOptions {
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 ${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
open class ScientifikMPPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.run {
override fun apply(project: Project): Unit = project.run {
plugins.apply("org.jetbrains.kotlin.multiplatform")
plugins.apply("org.jetbrains.kotlin.multiplatform")
repositories.applyRepos()
repositories.applyRepos()
configure<KotlinMultiplatformExtension> {
configure<KotlinMultiplatformExtension> {
jvm {
compilations.all {
kotlinOptions {
jvmTarget = Scientifik.JVM_TARGET.toString()
}
jvm {
compilations.all {
kotlinOptions {
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.run {
project.afterEvaluate {
val githubProject = findProperty("githubProject") as? String
val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/mipt-npm/$it" }
if (vcs == null) {
project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
return@apply
return@afterEvaluate
}
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 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(
vararg pairs: Pair<String, String>,
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.API
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
) {
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
@ -86,12 +86,12 @@ fun Project.useCoroutines(
dependencyConfiguration = configuration
)
//fun Project.atomic(version: String = Scientifik.atomicfuVersion) {
// plugins.apply("kotlinx-atomicfu")
// useDependency(
// "commonMain" to "org.jetbrains.kotlinx:atomicfu-common:$version",
// "jvmMain" to "org.jetbrains.kotlinx:atomicfu:$version",
// "jsMain" to "org.jetbrains.kotlinx:atomicfu-js:$version",
// "nativeMain" to "org.jetbrains.kotlinx:atomicfu-native:$version"
// )
//}
fun Project.useAtomic(version: String = Scientifik.atomicVersion) {
plugins.apply("kotlinx-atomicfu")
useDependency(
"commonMain" to "org.jetbrains.kotlinx:atomicfu-common:$version",
"jvmMain" to "org.jetbrains.kotlinx:atomicfu:$version",
"jsMain" to "org.jetbrains.kotlinx:atomicfu-js:$version",
"nativeMain" to "org.jetbrains.kotlinx:atomicfu-native:$version"
)
}

View File

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

View File

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