Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ensure correct line endings for Gradle wrapper files
*.bat text eol=crlf
gradlew text eol=lf
gradlew.bat text eol=crlf
*.sh text eol=lf
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle

- name: Print Java version
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down Expand Up @@ -237,7 +237,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down Expand Up @@ -284,7 +284,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
Expand Down Expand Up @@ -418,7 +418,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle

- name: Print Java version
Expand Down Expand Up @@ -497,7 +497,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21
cache: gradle

- name: Print Java version
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ android {
}

kotlinOptions {
jvmTarget = "17"
jvmTarget = "21"
}

buildFeatures {
Expand Down
44 changes: 32 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ fun properties(key: String) = project.findProperty(key).toString()
group = properties("libraryGroup")
version = properties("libraryVersion")

plugins {
kotlin("jvm") // Version is applied globally via settings.gradle.kts
id("com.github.ben-manes.versions") // Version is applied globally via settings.gradle.kts
jacoco
id("io.github.gradle-nexus.publish-plugin")
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(findProperty("ossrhUsername")?.toString() ?: System.getenv("OSSRH_USERNAME"))
password.set(findProperty("ossrhPassword")?.toString() ?: System.getenv("OSSRH_PASSWORD"))
}
}
}


subprojects {
apply(plugin = "jacoco")
repositories {
Expand All @@ -14,15 +33,22 @@ subprojects {
else -> {
apply(plugin = "java")
apply(plugin = "kotlin")
// Explicitly configure Java toolchain
extensions.configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
}
}
tasks.withType<JavaCompile> {
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.release.set(21)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
freeCompilerArgs.set(listOf("-Xjsr305=strict"))
javaParameters.set(true)
}
Expand Down Expand Up @@ -80,14 +106,14 @@ subprojects {

allprojects {
// Only apply Java plugin to non-Android projects
when (name) {
when (name) {
"android" -> { /* Skip Java plugin for Android project */ }
else -> {
apply(plugin = "java")
java {
toolchain { languageVersion.set(JavaLanguageVersion.of(17)) }
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain { languageVersion.set(JavaLanguageVersion.of(21)) }
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}
}
Expand Down Expand Up @@ -175,10 +201,4 @@ tasks {
repositories {
gradlePluginPortal()
mavenCentral()
}

plugins {
kotlin("jvm") // Version is applied globally via settings.gradle.kts
id("com.github.ben-manes.versions") // Version is applied globally via settings.gradle.kts
jacoco
}
85 changes: 77 additions & 8 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Keeping findProperty as it might be needed for immediate resolution by other plugins/tasks
// If not, switch to providers.gradleProperty(key).get()
// Use providers for consistency with other modules
group = providers.gradleProperty("libraryGroup").get()
version = providers.gradleProperty("libraryVersion").get()
group = providers.gradleProperty("cognotikGroup").get()
version = providers.gradleProperty("cognotikVersion").get()

plugins {
`java-library`
kotlin("jvm")
`maven-publish`
signing
}

repositories {
Expand Down Expand Up @@ -51,10 +51,10 @@ dependencies {


compileOnly(libs.asm)
compileOnly(kotlin("stdlib"))
compileOnly(libs.kotlinx.coroutines)
implementation(kotlin("stdlib"))
implementation(libs.kotlinx.coroutines)

testImplementation(kotlin("script-runtime"))
testImplementation(libs.kotlin.script.runtime)

testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter.api)
Expand Down Expand Up @@ -82,5 +82,74 @@ dependencies {
exclude(group = "org.slf4j", module = "slf4j-api")
}
testImplementation(libs.mockito)
// Ensure Kotlin compilation happens before Java compilation
tasks.named("compileJava") {
dependsOn(tasks.named("compileKotlin"))
}
tasks.named("compileTestJava") {
dependsOn(tasks.named("compileTestKotlin"))
}

}


java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])

groupId = "com.cognotik"
artifactId = "core"
version = project.version.toString()

pom {
name.set("Cognotik Core")
description.set("Core library for Cognotik AI framework")
url.set("https://github.com/SimiaCryptus/Cognotik")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
id.set("simiacryptus")
name.set("SimiaCryptus")
email.set("[email protected]")
}
}

scm {
connection.set("scm:git:git://github.com/SimiaCryptus/Cognotik.git")
developerConnection.set("scm:git:ssh://github.com/SimiaCryptus/Cognotik.git")
url.set("https://github.com/SimiaCryptus/Cognotik")
}
}
}
}
}

signing {
val signingKey = findProperty("signingInMemoryKey")?.toString() ?: System.getenv("SIGNING_KEY")
val signingPassword = findProperty("signingInMemoryKeyPassword")?.toString() ?: System.getenv("SIGNING_PASSWORD")

if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}

sign(publishing.publications["maven"])
}

tasks.javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ object OutputInterceptor {
private val isSetup = AtomicBoolean(false)
private val globalStreamLock = Any()

@JvmStatic

fun setupInterceptor() {
if (isSetup.getAndSet(true)) return
System.setOut(PrintStream(OutputStreamRouter(originalOut)))
Expand All @@ -29,6 +31,8 @@ object OutputInterceptor {
}
}

@JvmStatic

fun getThreadOutput(): String {
val outputStream = getThreadOutputStream()
try {
Expand All @@ -39,10 +43,14 @@ object OutputInterceptor {
return outputStream.toString()
}

@JvmStatic

fun clearThreadOutput() {
getThreadOutputStream().reset()
}

@JvmStatic

fun clearGlobalOutput() {
synchronized(globalStreamLock) {
globalStream.reset()
Expand Down
Loading
Loading