New publishing mechanics. Kotlin to 1.3.70
This commit is contained in:
parent
50020082a8
commit
9e8b21d327
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "scientifik"
|
||||
version = "0.4.0"
|
||||
version = "0.4.0-dev"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
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-6.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
3
gradlew.bat
vendored
3
gradlew.bat
vendored
@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
|
@ -5,4 +5,10 @@ object Scientifik {
|
||||
const val coroutinesVersion = "1.3.4"
|
||||
const val serializationVersion = "0.20.0"
|
||||
const val JVM_VERSION = "11"
|
||||
|
||||
object Serialization{
|
||||
const val xmlVersion = "0.20.0.0"
|
||||
const val yamlVersion = "0.16.1"
|
||||
const val bsonVersion = "0.2.1"
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ package scientifik
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.getValue
|
||||
import org.gradle.kotlin.dsl.getting
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
|
||||
import java.io.File
|
||||
|
||||
open class ScientifikJSPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
@ -18,7 +18,14 @@ open class ScientifikJSPlugin : Plugin<Project> {
|
||||
|
||||
configure<KotlinJsProjectExtension> {
|
||||
target {
|
||||
browser()
|
||||
browser {
|
||||
webpackTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
}
|
||||
distribution {
|
||||
directory = project.jsDistDirectory
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSets["main"].apply {
|
||||
languageSettings.applySettings()
|
||||
@ -37,31 +44,18 @@ open class ScientifikJSPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
tasks.apply {
|
||||
val browserWebpack by getting(KotlinWebpack::class) {
|
||||
afterEvaluate {
|
||||
val destination = listOf(name, version.toString()).joinToString("-")
|
||||
destinationDirectory = destinationDirectory?.resolve(destination)
|
||||
}
|
||||
outputFileName = "main.bundle.js"
|
||||
}
|
||||
|
||||
|
||||
val installJsDist by creating(Copy::class) {
|
||||
group = "distribution"
|
||||
dependsOn(browserWebpack)
|
||||
from(fileTree("src/main/web"))
|
||||
afterEvaluate {
|
||||
into(browserWebpack.destinationDirectory!!)
|
||||
val browserDistribution by getting {
|
||||
doLast {
|
||||
val indexFile = File(browserWebpack.destinationDirectory!!, "index.html")
|
||||
val indexFile = project.jsDistDirectory.resolve("index.html")
|
||||
if (indexFile.exists()) {
|
||||
println("Run JS distribution at: ${indexFile.canonicalPath}")
|
||||
}
|
||||
}
|
||||
}
|
||||
group = "distribution"
|
||||
}
|
||||
|
||||
findByName("assemble")?.dependsOn(installJsDist)
|
||||
// findByName("assemble")?.dependsOn(installJsDist)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,10 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
|
||||
import java.io.File
|
||||
|
||||
open class ScientifikMPPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
@ -23,6 +20,7 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
repositories.applyRepos()
|
||||
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
@ -32,9 +30,15 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
js {
|
||||
browser {}
|
||||
browser {
|
||||
webpackTask {
|
||||
outputFileName = "main.bundle.js"
|
||||
}
|
||||
distribution {
|
||||
directory = project.jsDistDirectory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sourceSets.invoke {
|
||||
val commonMain by getting {
|
||||
@ -108,42 +112,31 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
tasks.apply {
|
||||
val jsBrowserWebpack by getting(KotlinWebpack::class) {
|
||||
afterEvaluate {
|
||||
val destination = listOf(name, "js", version.toString()).joinToString("-")
|
||||
destinationDirectory = destinationDirectory?.resolve(destination)
|
||||
}
|
||||
outputFileName = "main.bundle.js"
|
||||
}
|
||||
|
||||
|
||||
val installJsDist by creating(Copy::class) {
|
||||
group = "distribution"
|
||||
dependsOn(jsBrowserWebpack)
|
||||
from(project.fileTree("src/jsMain/web"))
|
||||
afterEvaluate {
|
||||
into(jsBrowserWebpack.destinationDirectory!!)
|
||||
val jsBrowserDistribution by getting {
|
||||
doLast {
|
||||
val indexFile = File(jsBrowserWebpack.destinationDirectory!!, "index.html")
|
||||
val indexFile = project.jsDistDirectory.resolve("index.html")
|
||||
if (indexFile.exists()) {
|
||||
println("Run JS distribution at: ${indexFile.canonicalPath}")
|
||||
}
|
||||
}
|
||||
}
|
||||
group = "distribution"
|
||||
}
|
||||
|
||||
findByName("assemble")?.dependsOn(installJsDist)
|
||||
// findByName("assemble")?.dependsOn(installJsDist)
|
||||
|
||||
// withType<Test>(){
|
||||
// useJUnitPlatform()
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,10 +4,8 @@ import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import org.gradle.kotlin.dsl.register
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
|
||||
|
||||
@ -30,7 +28,6 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
project.configure<PublishingExtension> {
|
||||
// Process each publication we have in this project
|
||||
publications.withType<MavenPublication>().forEach { publication ->
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
publication.pom {
|
||||
name.set(project.name)
|
||||
@ -55,6 +52,7 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
}
|
||||
scm {
|
||||
url.set(vcs)
|
||||
tag.set(project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,7 +63,7 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
if (githubProject != null && githubUser != null && githubToken != null) {
|
||||
project.logger.info("Adding github publishing to project [${project.name}]")
|
||||
repositories {
|
||||
val githubMavenRepository = maven {
|
||||
maven {
|
||||
name = "github"
|
||||
url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/")
|
||||
credentials {
|
||||
@ -74,22 +72,13 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val githubPublishTasks = publications.filterIsInstance<MavenPublication>().map { publication ->
|
||||
tasks.register<PublishToMavenRepository>("publish${publication.name.capitalize()}ToGithub") {
|
||||
group = "publishing"
|
||||
this.publication = publication
|
||||
this.repository = githubMavenRepository
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<PublishToMavenRepository>("publishToGithub") {
|
||||
group = "publishing"
|
||||
dependsOn(githubPublishTasks)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
|
||||
val bintrayUser = project.findProperty("bintrayUser") as? String
|
||||
val bintrayKey = project.findProperty("bintrayApiKey") as? String
|
||||
|
||||
|
||||
val bintrayRepo = if (project.version.toString().contains("dev")) {
|
||||
@ -98,36 +87,24 @@ open class ScientifikPublishPlugin : Plugin<Project> {
|
||||
findProperty("bintrayRepo") as? String
|
||||
}
|
||||
|
||||
val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm"
|
||||
val bintrayUser = project.findProperty("bintrayUser") as? String
|
||||
val bintrayKey = project.findProperty("bintrayApiKey") as? String
|
||||
val projectName = project.name
|
||||
|
||||
if (bintrayRepo != null && bintrayUser != null && bintrayKey != null) {
|
||||
project.logger.info("Adding bintray publishing to project [${project.name}]")
|
||||
project.logger.info("Adding bintray publishing to project [$projectName]")
|
||||
|
||||
repositories {
|
||||
val bintrayMavenRepository = maven {
|
||||
maven {
|
||||
name = "bintray"
|
||||
uri("https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/${project.name}/;publish=0;override=1")
|
||||
url = uri(
|
||||
"https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/$projectName/;publish=0;override=1"
|
||||
)
|
||||
credentials {
|
||||
this.username = bintrayUser
|
||||
this.password = bintrayKey
|
||||
username = bintrayUser
|
||||
password = bintrayKey
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val bintrayPublishTasks = publications.withType<MavenPublication>().map { publication ->
|
||||
tasks.register<PublishToMavenRepository>("publish${publication.name.capitalize()}ToBintray") {
|
||||
group = "publishing"
|
||||
this.publication = publication
|
||||
this.repository = bintrayMavenRepository
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<PublishToMavenRepository>("publishToBintray") {
|
||||
group = "publishing"
|
||||
dependsOn(bintrayPublishTasks)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package scientifik
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
import java.io.File
|
||||
|
||||
internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
||||
progressiveMode = true
|
||||
@ -23,3 +25,16 @@ internal fun RepositoryHandler.applyRepos(): Unit{
|
||||
maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
|
||||
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
||||
}
|
||||
|
||||
val Project.jsDistDirectory: File
|
||||
get() {
|
||||
val distributionName = listOf(
|
||||
name,
|
||||
"js",
|
||||
version.toString()
|
||||
).joinToString("-")
|
||||
|
||||
return buildDir.resolve(
|
||||
"distributions/$distributionName}"
|
||||
)
|
||||
}
|
@ -7,62 +7,162 @@ import org.gradle.kotlin.dsl.findByType
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
internal fun Project.useDependency(vararg pairs: Pair<String, String>) {
|
||||
enum class DependencyConfiguration {
|
||||
API,
|
||||
IMPLEMENTATION
|
||||
}
|
||||
|
||||
enum class DependencySourceSet(val setName: String, val suffix: String) {
|
||||
MAIN("main", "Main"),
|
||||
TEST("test", "Test")
|
||||
}
|
||||
|
||||
internal fun Project.useDependency(
|
||||
vararg pairs: Pair<String, String>,
|
||||
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.API
|
||||
) {
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
sourceSets {
|
||||
pairs.forEach { (name, dep)->
|
||||
pairs.forEach { (target, dep) ->
|
||||
val name = target + dependencySourceSet.suffix
|
||||
findByName(name)?.apply {
|
||||
dependencies {
|
||||
implementation(dep)
|
||||
when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> api(dep)
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementation(dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pairs.find { it.first == "jvmMain" }?.let { dep ->
|
||||
}
|
||||
|
||||
pairs.find { it.first == "jvm" }?.let { dep ->
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||
dependencies.apply {
|
||||
add(implementationConfigurationName, dep.second)
|
||||
val configurationName = when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> apiConfigurationName
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||
}
|
||||
add(configurationName, dep.second)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pairs.find { it.first == "jsMain" }?.let { dep ->
|
||||
pairs.find { it.first == "js" }?.let { dep ->
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
sourceSets.findByName("main")?.apply {
|
||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||
dependencies.apply {
|
||||
add(implementationConfigurationName, dep.second)
|
||||
val configurationName = when (dependencyConfiguration) {
|
||||
DependencyConfiguration.API -> apiConfigurationName
|
||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||
}
|
||||
add(configurationName, dep.second)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SerializationTargets(
|
||||
val sourceSet: DependencySourceSet,
|
||||
val configuration: DependencyConfiguration
|
||||
) {
|
||||
fun Project.cbor(
|
||||
version: String = Scientifik.serializationVersion
|
||||
) {
|
||||
useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-serialization-cbor-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.useSerialization(version: String = Scientifik.serializationVersion) {
|
||||
fun Project.protobuf(
|
||||
version: String = Scientifik.serializationVersion
|
||||
) {
|
||||
useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-serialization-protobuf-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.xml(
|
||||
version: String = Scientifik.Serialization.xmlVersion
|
||||
) {
|
||||
useDependency(
|
||||
"common" to "net.devrieze:xmlutil:$version",
|
||||
"jvm" to "net.devrieze:xmlutil:$version",
|
||||
"js" to "net.devrieze:xmlutil:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.yaml(
|
||||
version: String = Scientifik.Serialization.yamlVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.charleskorn.kaml:kaml:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
|
||||
fun Project.bson(
|
||||
version: String = Scientifik.Serialization.bsonVersion
|
||||
) {
|
||||
useDependency(
|
||||
"jvm" to "com.github.jershell:kbson:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.serialization(
|
||||
version: String = Scientifik.serializationVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||
block: SerializationTargets.() -> Unit = {}
|
||||
) {
|
||||
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
|
||||
useDependency(
|
||||
"commonMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$version",
|
||||
"jvmMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$version",
|
||||
"jsMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$version",
|
||||
"nativeMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$version"
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$version",
|
||||
"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
|
||||
)
|
||||
SerializationTargets(sourceSet, configuration).apply(block)
|
||||
}
|
||||
|
||||
fun Project.useCoroutines(version: String = Scientifik.coroutinesVersion) = useDependency(
|
||||
"commonMain" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$version",
|
||||
"jvmMain" to "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
|
||||
"jsMain" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$version",
|
||||
"nativeMain" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$version"
|
||||
fun Project.coroutines(
|
||||
version: String = Scientifik.coroutinesVersion,
|
||||
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||
configuration: DependencyConfiguration = DependencyConfiguration.API
|
||||
) = useDependency(
|
||||
"common" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$version",
|
||||
"jvm" to "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version",
|
||||
"js" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$version",
|
||||
"native" to "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$version",
|
||||
dependencySourceSet = sourceSet,
|
||||
dependencyConfiguration = configuration
|
||||
)
|
||||
|
||||
//fun Project.useAtomic(version: String = Scientifik.atomicfuVersion) {
|
||||
//fun Project.atomic(version: String = Scientifik.atomicfuVersion) {
|
||||
// plugins.apply("kotlinx-atomicfu")
|
||||
// useDependency(
|
||||
// "commonMain" to "org.jetbrains.kotlinx:atomicfu-common:$version",
|
||||
|
Loading…
Reference in New Issue
Block a user