Skip to content

Commit

Permalink
feature/marge-mcsm (#25)
Browse files Browse the repository at this point in the history
* Release/3.0.0 (#24)

* fix

* Feature/migrate gradle (#23)

* change to gradle

* change: action

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* .java を .kt に名前変更

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* release: 3.0.0

* .java を .kt に名前変更

* logger

* .java を .kt に名前変更

* fix: compile err

* fix: compile err

* fix: compile warn

* add test

* add test

* add test

* add test
  • Loading branch information
kigawa01 authored Mar 23, 2024
1 parent d4c3443 commit d7a00a5
Show file tree
Hide file tree
Showing 164 changed files with 4,233 additions and 1,681 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/deploy_maven_central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
uses: gradle/wrapper-validation-action@v1
- name: Restore gradle.properties
env:
GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: |
echo "$GPG_PRIVATE_KEY" | base64 -d > kutil/sec.pem
echo "signing.keyId=ED76201E" >> ./gradle.properties
echo "signing.password=${GPG_PASSPHRASE}" >> ./gradle.properties
echo "signing.secretKeyRingFile=sec.pem" >> ./gradle.properties
- name: Publish package
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
# gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
# MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
####
29 changes: 29 additions & 0 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: run test

on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: run test
uses: gradle/gradle-build-action@v2
with:
arguments: allTests
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
####
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ out/
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
Expand Down Expand Up @@ -127,4 +126,4 @@ run/
/.idea/
/log1/
/log/
/api/build/
/*/build/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## About

* javaのutility
* kotlinのutility

## Use

Expand All @@ -11,20 +11,20 @@
<dependency>
<groupId>net.kigawa.kutil</groupId>
<artifactId>kutil</artifactId>
<version>2.2.1</version>
<version>3.0.0</version>
</dependency>
......
</dependencies>
```

## Requirement

* java
* kotlin

## Author

* kigawa
* kigawa.[email protected]
* contact@kigawa.net

# Making

Expand Down
3 changes: 2 additions & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ plugins {
}

dependencies {
}
commonMainImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
}
10 changes: 10 additions & 0 deletions api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Func.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.kigawa.kutil.kutil.api

import kotlinx.coroutines.channels.Channel


suspend inline fun <T> Channel<T>.forEach(func: (T) -> Unit) {
for (item in this) {
func(item)
}
}

This file was deleted.

56 changes: 56 additions & 0 deletions api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Kutil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@file:Suppress("unused")

package net.kigawa.kutil.kutil.api

import net.kigawa.kutil.kutil.api.io.KuCloseable
import net.kigawa.kutil.kutil.api.io.SuspendCloseable
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract

@Suppress("unused")
object Kutil {
fun fillStr(src: String, size: Int, fillChar: Char = ' '): String {
val sb = StringBuilder(size)
for (i in 0 until size) {
sb.append(src.getOrNull(i) ?: fillChar)
}
return sb.toString()
}

}

@OptIn(ExperimentalContracts::class)
inline fun <T : KuCloseable, R> T.tryCatch(
block: (self: T) -> R,
): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
try {
return block(this)
} catch (e: Throwable) {
throw e
} finally {
close()
}
}

@OptIn(ExperimentalContracts::class)
suspend inline fun <T : KuCloseable, R> T.tryCatchSuspend(
block: (self: T) -> R,
): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
try {
return block(this)
} catch (e: Throwable) {
throw e
} finally {
when (this) {
is SuspendCloseable -> suspendClose()
else -> close()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.kigawa.kutil.kutil.api

/**
* utilities about array
*/
@Suppress("unused", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect object KutilArray

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.kigawa.kutil.kutil.api

/**
* utilities about file
*/
@Suppress("unused", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect object KutilFile {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.kigawa.kutil.kutil.api

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect object KutilPlatform {
fun getSystemProperty(name: String): String
fun getEnv(name: String): String?
}
10 changes: 10 additions & 0 deletions api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Option.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.kigawa.kutil.kutil.api

@Suppress("unused")
interface Option {
val name: String
val optName: String
val shortName: String?
val description: String
val defaultValue: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.kigawa.kutil.kutil.api

@Suppress("unused")
class OptionStore {
private val options = mutableMapOf<Option, String>()

fun add(option: Option, value: String) {
options[option] = value
}


fun get(option: Option): String = options[option]
?: KutilPlatform.getEnv(option.name)
?: option.defaultValue

}
11 changes: 11 additions & 0 deletions api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Paths.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.kigawa.kutil.kutil.api

import net.kigawa.kutil.kutil.api.io.fs.KuPath

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect enum class Paths {
JAVA
;

val path: KuPath
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.kigawa.kutil.kutil.api

@Suppress("unused")
data class PlatFormInstance(
val exitProcess: (Int) -> Nothing,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.kigawa.kutil.kutil.api

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect object SignalHandler {
fun shutdownHook(hook: () -> Unit)
}
Loading

0 comments on commit d7a00a5

Please sign in to comment.