Skip to content

Commit

Permalink
Moving to vorpal; distribution; ci&cd; up the versions of everything
Browse files Browse the repository at this point in the history
  • Loading branch information
belyaev-mikhail committed Apr 9, 2020
1 parent d1e0c94 commit 7e97ba5
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 30 deletions.
12 changes: 12 additions & 0 deletions .github/bintray-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>bintray-vorpal-research-kotlin-maven</id>
<username>${env.BINTRAY_USERNAME}</username>
<password>${env.BINTRAY_PASSWORD}</password>
</server>
</servers>
</settings>
53 changes: 53 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Java CD

on:
release:
types: published

jobs:
publish:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Deploy to Bintray
id: deploy-to-bintray
run: |
mvn versions:set -DnewVersion=${{ github.event.release.tag_name }}
mvn deploy -s .github/bintray-settings.xml || echo "deploy failed" >&2
env:
BINTRAY_USERNAME: ${{ secrets.bintray_username }}
BINTRAY_PASSWORD: ${{ secrets.bintray_password }}

- name: Move sources jar file
run: mv target/*-sources.jar sources.jar

- name: Move target jar file
run: mv target/*.jar target.jar

- name: Attach source jar to release
id: upload-source-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: sources.jar
asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-sources.jar
asset_content_type: application/zip

- name: Attach target jar to release
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: target.jar
asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.jar
asset_content_type: application/zip
17 changes: 17 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Java CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B package
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
target/
*.iml
47 changes: 39 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@

<groupId>ru.spbstu</groupId>
<artifactId>SymKt</artifactId>
<version>0.0.0.1-SNAPSHOT</version>
<version>0.0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>ru.spbstu.SymKt</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.3.70</kotlin.version>
<kotlin.version>1.3.71</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<junit.version>4.12</junit.version>
<wheels.version>0.0.0.7</wheels.version>
</properties>

<dependencies>
Expand All @@ -23,22 +24,30 @@
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<groupId>ru.spbstu</groupId>
<artifactId>kotlinx-warnings</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ru.spbstu</groupId>
<artifactId>kotlin-wheels</artifactId>
<version>${wheels.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.spbstu</groupId>
<artifactId>kotlin-wheels</artifactId>
<version>0.0.0.6</version>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -68,6 +77,20 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -78,4 +101,12 @@
</repository>
</repositories>

<distributionManagement>
<repository>
<id>bintray-vorpal-research-kotlin-maven</id>
<name>vorpal-research-kotlin-maven</name>
<url>https://api.bintray.com/maven/vorpal-research/kotlin-maven/${project.artifactId}/;publish=1</url>
</repository>
</distributionManagement>

</project>
2 changes: 2 additions & 0 deletions src/main/kotlin/ru/spbstu/Auxiliary.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ru.spbstu

import ru.spbstu.wheels.mapToArray

private val bernoulliCache = mutableMapOf(
0L to Rational.ONE,
2L to Rational(1, 6),
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/ru/spbstu/RowSum.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.spbstu

import kotlin.math.abs
import ru.spbstu.wheels.mapToArray

data class RowSum(
val index: Var,
Expand Down Expand Up @@ -46,7 +47,7 @@ data class RowSum(
if(body is Sum) {
return Sum.of(
Const(body.constant) * range,
*body.parts.mapToArray { s, c ->
*body.parts.mapToArray { (s, c) ->
val rs = symbolicRowSum(index, lowerBound, upperBound, range, s)
?: RowSum(index, lowerBound, upperBound, body)
Const(c) * rs
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/ru/spbstu/Symbolics.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.spbstu

import ru.spbstu.wheels.joinTo
import ru.spbstu.wheels.mapToArray
import kotlin.math.abs
import kotlin.reflect.KProperty

Expand Down Expand Up @@ -101,7 +102,7 @@ data class Sum(val constant: Rational = Rational.ZERO,
override fun simplify(): Symbolic = simplifyData(constant, parts)

override fun subst(substitution: Map<Var, Symbolic>): Symbolic =
of(Const(constant), *parts.mapToArray { c, r -> c.subst(substitution) * r })
of(Const(constant), *parts.mapToArray { (c, r) -> c.subst(substitution) * r })

override fun <C : MutableCollection<Var>> vars(mutableCollection: C): C =
mutableCollection.apply {
Expand All @@ -115,7 +116,7 @@ data class Sum(val constant: Rational = Rational.ZERO,
constant = constant * factor.value,
parts = parts.mapValues { (_, v) -> v * factor.value }
)
else -> of(factor * constant, *parts.mapToArray { ek, ev -> ek * factor * ev })
else -> of(factor * constant, *parts.mapToArray { (ek, ev) -> ek * factor * ev })
}

companion object {
Expand Down Expand Up @@ -170,7 +171,7 @@ data class Product(val constant: Rational = Rational.ONE,
override fun asProduct(): Product = this

override fun subst(substitution: Map<Var, Symbolic>): Symbolic =
of(Const(constant), *parts.mapToArray { c, r -> c.subst(substitution) pow r })
of(Const(constant), *parts.mapToArray { (c, r) -> c.subst(substitution) pow r })
override fun <C : MutableCollection<Var>> vars(mutableCollection: C): C =
mutableCollection.apply {
parts.forEach { (k, _) -> k.vars(mutableCollection) }
Expand Down
18 changes: 0 additions & 18 deletions src/main/kotlin/ru/spbstu/Util.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
package ru.spbstu

import kotlinx.warnings.Warnings

inline fun <A, reified B> Collection<A>.mapToArray(body: (A) -> B): Array<B> {
val res = arrayOfNulls<B>(size)
var i = 0
for(e in this) res[i++] = body(e)
@Suppress(Warnings.UNCHECKED_CAST)
return res as Array<B>
}

inline fun <K, V, reified B> Map<K, V>.mapToArray(body: (K, V) -> B): Array<B> {
val res = arrayOfNulls<B>(size)
var i = 0
for((k, v) in this) res[i++] = body(k, v)
@Suppress(Warnings.UNCHECKED_CAST)
return res as Array<B>
}

inline fun <T> T.sealed() = this

inline fun <T, C1: MutableCollection<in T>, C2: MutableCollection<in T>>
Expand Down

0 comments on commit 7e97ba5

Please sign in to comment.