From 1af0ed4b91755a377f3a3ca3f8dd3ea7377c26d7 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 22 Feb 2019 13:52:35 +0300 Subject: [PATCH] Deploy configuration --- .gitignore | 3 +- README.md | 53 ++++++++++-- build.gradle.kts | 83 ++++++++++++------ gradle/artifactory.gradle | 31 +++++++ gradle/bintray.gradle | 85 +++++++++++++++++++ kmath-commons/build.gradle.kts | 16 ++++ .../scientifik/kmath/linear/BufferMatrix.kt | 2 +- settings.gradle.kts | 2 +- 8 files changed, 238 insertions(+), 37 deletions(-) create mode 100644 gradle/artifactory.gradle create mode 100644 gradle/bintray.gradle diff --git a/.gitignore b/.gitignore index 6e66dc376..d07c3c850 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,4 @@ # Cache of project .gradletasknamecache -gradle/artifactory.gradle -gradle/bintray.gradle \ No newline at end of file +gradle.properties \ No newline at end of file diff --git a/README.md b/README.md index a13696d34..75b6e8345 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,48 @@ +Bintray: [ ![Download](https://api.bintray.com/packages/mipt-npm/scientifik/scientifik.kmath/images/download.svg) ](https://bintray.com/mipt-npm/scientifik/scientifik.kmath/_latestVersion) + # KMath The Kotlin MATHematics library is intended as a Kotlin-based analog to Python's `numpy` library. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. ## Features +Actual feature list is [here](doc/features.md) + * **Algebra** * Algebraic structures like rings, spaces and field (**TODO** add example to wiki) * Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. * Complex numbers backed by the `Field` API (meaning that they will be usable in any structure like vectors and N-dimensional arrays). - * [In progress] advanced linear algebra operations like matrix inversion and LU decomposition. -* **Array-like structures** Full support of [numpy-like ndarrays](https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.ndarray.html) including mixed arithmetic operations and function operations over arrays and numbers just like in Python (with the added benefit of static type checking). + * Advanced linear algebra operations like matrix inversion and LU decomposition. -* **Expressions** Expressions are one of the ultimate goals of KMath. By writing a single mathematical expression +* **Array-like structures** Full support of many-dimenstional array-like structures +including mixed arithmetic operations and function operations over arrays and numbers (with the added benefit of static type checking). + +* **Expressions** By writing a single mathematical expression once, users will be able to apply different types of objects to the expression by providing a context. Exceptions can be used for a wide variety of purposes from high performance calculations to code generation. +* **Histograms** Fast multi-dimensional histograms. + +* **Streaming** Streaming operations on mathematica objects and objects buffers. + +* **Commons-math wrapper** It is planned to gradually wrap most parts of [Apache commons-math](http://commons.apache.org/proper/commons-math/) + library in Kotlin code and maybe rewrite some parts to better suit the Kotlin programming paradigm, however there is no fixed roadmap for that. Feel free + to submit a feature request if you want something to be done first. + +* **Koma wrapper** [Koma](https://github.com/kyonifer/koma) is a well established numerics library in kotlin, specifically linear algebra. +The plan is to have wrappers for koma implementations for compatibility with kmath API. + ## Planned features -* **Common mathematics** It is planned to gradually wrap most parts of [Apache commons-math](http://commons.apache.org/proper/commons-math/) -library in Kotlin code and maybe rewrite some parts to better suit the Kotlin programming paradigm, however there is no fixed roadmap for that. Feel free -to submit a feature request if you want something to be done first. - * **Messaging** A mathematical notation to support multi-language and multi-node communication for mathematical tasks. +* **Array statistics** + +* **Integration** Univariate and multivariate integration framework. + +* **Probability and distributions** + +* **Fitting** Non-linear curve fitting facilities + ## Multi-platform support KMath is developed as a multi-platform library, which means that most of interfaces are declared in the [common module](kmath-core/src/commonMain). @@ -39,6 +60,10 @@ of optimized parts should be better than SciPy. ## Releases +Working builds can be obtained here: [![](https://jitpack.io/v/altavir/kmath.svg)](https://jitpack.io/#altavir/kmath). + +### Development + The project is currently in pre-release stage. Nightly builds can be used by adding an additional repository to the Gradle config like so: ```groovy @@ -69,7 +94,19 @@ or in the Gradle Kotlin DSL: api("scientifik:kmath-core-jvm:0.1.0-dev") ``` -Working builds can be obtained here: [![](https://jitpack.io/v/altavir/kmath.svg)](https://jitpack.io/#altavir/kmath). +### Release + +Release artifacts are accessible from bintray with following configuration: + +```kotlin +repositories{ + maven("https://dl.bintray.com/mipt-npm/scientifik") +} + +dependencies{ + api("scientifik:kmath-core-jvm:0.1.0") +} +``` ## Contributing diff --git a/build.gradle.kts b/build.gradle.kts index 350156420..58a5a5bf2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ buildscript { val ioVersion: String by rootProject.extra("0.1.5") val coroutinesVersion: String by rootProject.extra("1.1.1") val atomicfuVersion: String by rootProject.extra("0.12.1") + val dokkaVersion: String by rootProject.extra("0.9.17") repositories { //maven("https://dl.bintray.com/kotlin/kotlin-eap") @@ -15,6 +16,7 @@ buildscript { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath("org.jfrog.buildinfo:build-info-extractor-gradle:4+") classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4") + classpath("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion") } } @@ -22,20 +24,31 @@ plugins { id("com.jfrog.artifactory") version "4.9.1" apply false } -allprojects { - if (project.name.startsWith("kmath")) { - apply(plugin = "maven-publish") - apply(plugin = "com.jfrog.artifactory") - } +val kmathVersion by extra("0.1.0") +allprojects { group = "scientifik" - version = "0.1.0-dev" + version = kmathVersion repositories { //maven("https://dl.bintray.com/kotlin/kotlin-eap") jcenter() } + apply(plugin = "maven") + apply(plugin = "maven-publish") + + // apply bintray configuration + apply(from = "${rootProject.rootDir}/gradle/bintray.gradle") + + //apply artifactory configuration + apply(from = "${rootProject.rootDir}/gradle/artifactory.gradle") +} + +subprojects { + if (!name.startsWith("kmath")) return@subprojects + + extensions.findByType()?.apply { jvm { compilations.all { @@ -49,29 +62,49 @@ allprojects { languageSettings.progressiveMode = true } } - } - extensions.findByType()?.apply { - val javadocJar by tasks.creating(Jar::class) { - archiveClassifier.value("javadoc") - // TODO: instead of a single empty Javadoc JAR, generate real documentation for each module - } - val sourcesJar by tasks.creating(Jar::class) { - archiveClassifier.value("sources") - } + extensions.findByType()?.apply { + publications.filterIsInstance().forEach { publication -> + if (publication.name == "kotlinMultiplatform") { + // for our root metadata publication, set artifactId with a package and project name + publication.artifactId = project.name + } else { + // for targets, set artifactId with a package, project name and target name (e.g. iosX64) + publication.artifactId = "${project.name}-${publication.name}" + } + } - repositories { - maven(uri("$buildDir/repo")) + // Create empty jar for sources classifier to satisfy maven requirements + val stubSources by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + //from(sourceSets.main.get().allSource) + } + + // Create empty jar for javadoc classifier to satisfy maven requirements + val stubJavadoc by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") + } + + extensions.findByType()?.apply { + + targets.forEach { target -> + val publication = publications.findByName(target.name) as MavenPublication + + // Patch publications with fake javadoc + publication.artifact(stubJavadoc) + + // Remove gradle metadata publishing from all targets which are not native +// if (target.platformType.name != "native") { +// publication.gradleModuleMetadataFile = null +// tasks.matching { it.name == "generateMetadataFileFor${name.capitalize()}Publication" }.all { +// onlyIf { false } +// } +// } + } + } } - publications.withType().all { - artifact(javadocJar) - artifact(sourcesJar) - } - //apply(from = "${rootProject.rootDir}/gradle/bintray.gradle") } } -if (file("gradle/artifactory.gradle").exists()) { - apply(from = "gradle/artifactory.gradle") -} + diff --git a/gradle/artifactory.gradle b/gradle/artifactory.gradle new file mode 100644 index 000000000..12e59642b --- /dev/null +++ b/gradle/artifactory.gradle @@ -0,0 +1,31 @@ +apply plugin: "com.jfrog.artifactory" + +artifactory { + def artifactory_user = project.hasProperty('artifactoryUser') ? project.property('artifactoryUser') : "" + def artifactory_password = project.hasProperty('artifactoryPassword') ? project.property('artifactoryPassword') : "" + def artifactory_contextUrl = 'http://npm.mipt.ru:8081/artifactory' + + contextUrl = artifactory_contextUrl //The base Artifactory URL if not overridden by the publisher/resolver + publish { + repository { + repoKey = 'gradle-dev-local' + username = artifactory_user + password = artifactory_password + } + + defaults { + publications('jvm', 'js', 'kotlinMultiplatform', 'metadata') + publishBuildInfo = false + publishArtifacts = true + publishPom = true + publishIvy = false + } + } + resolve { + repository { + repoKey = 'gradle-dev' + username = artifactory_user + password = artifactory_password + } + } +} \ No newline at end of file diff --git a/gradle/bintray.gradle b/gradle/bintray.gradle new file mode 100644 index 000000000..8da83c860 --- /dev/null +++ b/gradle/bintray.gradle @@ -0,0 +1,85 @@ +apply plugin: 'com.jfrog.bintray' + +def vcs = "https://github.com/mipt-npm/kmath" + +def pomConfig = { + licenses { + license { + name "The Apache Software License, Version 2.0" + url "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution "repo" + } + } + developers { + developer { + id "MIPT-NPM" + name "MIPT nuclear physics methods laboratory" + organization "MIPT" + organizationUrl "http://npm.mipt.ru" + } + } + scm { + url vcs + } +} + +project.ext.configureMavenCentralMetadata = { pom -> + def root = asNode() + root.appendNode('name', project.name) + root.appendNode('description', project.description) + root.appendNode('url', vcs) + root.children().last() + pomConfig +} + +project.ext.configurePom = pomConfig + + +// Configure publishing +publishing { + repositories { + maven { + url = "https://bintray.com/mipt-npm/scientifik" + } + } + + // Process each publication we have in this project + publications.all { publication -> + // apply changes to pom.xml files, see pom.gradle + pom.withXml(configureMavenCentralMetadata) + + + } +} + +bintray { + user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') + key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') + publish = true + override = true // for multi-platform Kotlin/Native publishing + + pkg { + userOrg = "mipt-npm" + repo = "scientifik" + name = "scientifik.kmath" + issueTrackerUrl = "https://github.com/mipt-npm/kmath/issues" + licenses = ['Apache-2.0'] + vcsUrl = vcs + version { + name = project.version + vcsTag = project.version + released = new Date() + } + } +} + +bintrayUpload.dependsOn publishToMavenLocal + +// This is for easier debugging of bintray uploading problems +bintrayUpload.doFirst { + publications = project.publishing.publications.findAll { + !it.name.contains('-test') && it.name != 'kotlinMultiplatform' + }.collect { + println("Uploading artifact '$it.groupId:$it.artifactId:$it.version' from publication '$it.name'") + it.name//https://github.com/bintray/gradle-bintray-plugin/issues/256 + } +} \ No newline at end of file diff --git a/kmath-commons/build.gradle.kts b/kmath-commons/build.gradle.kts index 305761c01..0ea7b7eff 100644 --- a/kmath-commons/build.gradle.kts +++ b/kmath-commons/build.gradle.kts @@ -1,5 +1,6 @@ plugins { kotlin("jvm") + `maven-publish` } description = "Commons math binding for kmath" @@ -11,3 +12,18 @@ dependencies { testImplementation("org.jetbrains.kotlin:kotlin-test") testImplementation("org.jetbrains.kotlin:kotlin-test-junit") } + + +val sourcesJar by tasks.registering(Jar::class) { + classifier = "sources" + from(sourceSets.main.get().allSource) +} + +publishing { + publications { + register("jvm", MavenPublication::class) { + from(components["java"]) + artifact(sourcesJar.get()) + } + } +} \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/BufferMatrix.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/BufferMatrix.kt index 3752f6db5..dbffea8f3 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/BufferMatrix.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/BufferMatrix.kt @@ -2,6 +2,7 @@ package scientifik.kmath.linear import scientifik.kmath.operations.Ring import scientifik.kmath.structures.* +import kotlin.jvm.JvmSynthetic /** * Basic implementation of Matrix space based on [NDStructure] @@ -32,7 +33,6 @@ class BufferMatrix( } } - override val shape: IntArray get() = intArrayOf(rowNum, colNum) override fun suggestFeature(vararg features: MatrixFeature) = diff --git a/settings.gradle.kts b/settings.gradle.kts index 7e815354e..8684de3ee 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,7 +15,7 @@ pluginManagement { } } -//enableFeaturePreview("GRADLE_METADATA") +enableFeaturePreview("GRADLE_METADATA") rootProject.name = "kmath" include(