Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/jsonschema-4.32.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Montagon authored Nov 3, 2023
2 parents e2adac5 + 0e42da2 commit fe3a288
Show file tree
Hide file tree
Showing 81 changed files with 1,029 additions and 1,184 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-development-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 20

- name: Assemble
uses: gradle/gradle-build-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 20

- name: Assemble
uses: gradle/gradle-build-action@v2
Expand Down
24 changes: 24 additions & 0 deletions .run/build.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="build" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/spotless.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spotless" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="spotlessApply" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="test" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/wrapper.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="wrapper" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="wrapper" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ Libraries are published in Maven Central, under the `com.xebia` group.
Libraries are published in Maven Central. You may need to add that repository explicitly
in your build, if you haven't done it before.

```kotlin
repositories {
mavenCentral()
}
```groovy
repositories { mavenCentral() }
```

Then add the library in the usual way.

```kotlin
```groovy
// In Gradle Kotlin
dependencies {
implementation("com.xebia:xef-kotlin:<version>")
Expand Down Expand Up @@ -110,7 +108,7 @@ in your build, if you haven't done it before.

## 📖 Quick Introduction

In this small introduction we look at the main features of xef, including the `ai` function.
In this small introduction we look at the main features of xef, including the `conversation` function.

- [<img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Kotlin_Icon_2021.svg" height="15px" alt="Kotlin logo"> Kotlin version](https://github.com/xebia-functional/xef/blob/main/docs/intro/kotlin.md)
- [<img src="https://www.scala-lang.org/resources/img/frontpage/scala-spiral.png" height="15px" alt="Scala logo"> Scala version](https://github.com/xebia-functional/xef/blob/main/docs/intro/scala.md)
Expand All @@ -121,5 +119,5 @@ In this small introduction we look at the main features of xef, including the `a
You can also have a look at the examples to have a feeling of how using the library looks like.

- [<img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Kotlin_Icon_2021.svg" height="15px" alt="Kotlin logo"> Examples in Kotlin](https://github.com/xebia-functional/xef/tree/main/examples/kotlin/src/main/kotlin/com/xebia/functional/xef/conversation)
- [<img src="https://www.scala-lang.org/resources/img/frontpage/scala-spiral.png" height="15px" alt="Scala logo"> Examples in Scala](https://github.com/xebia-functional/xef/tree/main/examples/scala/src/main/scala/com/xebia/functional/xef/scala/conversation)
- [<img src="https://www.scala-lang.org/resources/img/frontpage/scala-spiral.png" height="15px" alt="Scala logo"> Examples in Scala](https://github.com/xebia-functional/xef/tree/main/examples/scala/src/main/scala/com/xebia/functional/xef/examples/scala)
- [<img src="https://upload.wikimedia.org/wikipedia/en/thumb/3/30/Java_programming_language_logo.svg/234px-Java_programming_language_logo.svg.png" height="15px" alt="Java logo"> Examples in Java](https://github.com/xebia-functional/xef/tree/main/examples/java/src/main/java/com/xebia/functional/xef/java/auto)
38 changes: 15 additions & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@file:Suppress("DSL_SCOPE_VIOLATION")

plugins {
base
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.spotless)
alias(libs.plugins.dokka)
alias(libs.plugins.arrow.gradle.nexus)
alias(libs.plugins.arrow.gradle.publish) apply false
alias(libs.plugins.semver.gradle)
base
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.spotless)
alias(libs.plugins.dokka)
alias(libs.plugins.arrow.gradle.nexus)
alias(libs.plugins.arrow.gradle.publish) apply false
alias(libs.plugins.semver.gradle)
}

allprojects {
group = property("project.group").toString()
group = property("project.group").toString()
}

fun isMultiplatformModule(project: Project): Boolean {
Expand All @@ -22,18 +22,14 @@ fun isMultiplatformModule(project: Project): Boolean {

val multiPlatformModules = project.subprojects.filter { isMultiplatformModule(it) }.map { it.name }

enum class ModuleType {
MULTIPLATFORM,
SINGLEPLATFORM
}
enum class ModuleType { SINGLEPLATFORM, MULTIPLATFORM }

fun Project.configureBuildAndTestTask(
taskName: String,
moduleType: ModuleType,
multiPlatformModules: List<String>
) {
val platform: String by extra

tasks.register(taskName) {
doLast {
val gradleCommand = getGradleCommand(platform)
Expand All @@ -42,30 +38,26 @@ fun Project.configureBuildAndTestTask(
}
project.exec {
when (moduleType) {
ModuleType.SINGLEPLATFORM -> {
commandLine(gradleCommand, "build", *buildExcludeOptions(multiPlatformModules))
}
ModuleType.MULTIPLATFORM -> {
multiPlatformModules.forEach { module ->
commandLine(gradleCommand, ":$module:${platform}Test")
}
}
ModuleType.SINGLEPLATFORM -> {
commandLine(gradleCommand, "build", *buildExcludeOptions(multiPlatformModules))
}
}
}
}
}
}

fun Project.buildExcludeOptions(modules: List<String>): Array<String> {
fun buildExcludeOptions(modules: List<String>): Array<String> {
return modules.flatMap { listOf("-x", ":$it:build") }.toTypedArray()
}

fun getGradleCommand(platform: String): String {
return if (platform == "mingwX64") {
"gradlew.bat"
} else {
"./gradlew"
}
return if (platform == "mingwX64") "gradlew.bat" else "./gradlew"
}

configureBuildAndTestTask(
Expand Down
6 changes: 1 addition & 5 deletions buildSrc/src/main/kotlin/JavaPublishingConventionsPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.BasePluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.register
import org.gradle.plugins.signing.SigningExtension

class JavaPublishingConventionsPlugin : Plugin<Project> {

override fun apply(project: Project): Unit = project.run {
val publishingExtension: PublishingExtension =
extensions.findByType<PublishingExtension>()
Expand All @@ -35,7 +32,6 @@ class JavaPublishingConventionsPlugin : Plugin<Project> {
val signingKeyId: String? = configValue("signing.keyId", "SIGNING_KEY_ID")
val signingKey: String? = configValue("signing.key", "SIGNING_KEY")
val signingPassphrase: String? = configValue("signing.passphrase", "SIGNING_KEY_PASSPHRASE")

isRequired = !isLocal
useGpgCmd()
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassphrase)
Expand Down
16 changes: 4 additions & 12 deletions buildSrc/src/main/kotlin/Predef.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication

internal fun Project.configValue(propertyName: String, environmentVariableName: String): String? {
internal fun Project.configValue(propertyName: String, envVarName: String): String? {
val property: String? = project.properties[propertyName]?.toString()
val environmentVariable: String? = System.getenv(environmentVariableName)

val configValue = property ?: environmentVariable

val envVar: String? = System.getenv(envVarName)
val configValue = property ?: envVar
return configValue.also {
if (configValue.isNullOrBlank()) {
errorMessage(
"$propertyName Gradle property and " +
"$environmentVariableName environment variable are missing",
)
errorMessage("$propertyName Gradle property and $envVarName environment variable are missing")
}
}
}
Expand All @@ -22,21 +17,18 @@ internal fun MavenPublication.pomConfiguration(project: Project) {
name.set(project.properties["pom.name"]?.toString())
description.set(project.properties["pom.description"]?.toString())
url.set(project.properties["pom.url"]?.toString())

licenses {
license {
name.set(project.properties["pom.license.name"]?.toString())
url.set(project.properties["pom.license.url"]?.toString())
}
}

developers {
developer {
id.set(project.properties["pom.developer.id"].toString())
name.set(project.properties["pom.developer.name"].toString())
}
}

scm {
url.set(project.properties["pom.smc.url"].toString())
connection.set(project.properties["pom.smc.connection"].toString())
Expand Down
4 changes: 1 addition & 3 deletions buildSrc/src/main/kotlin/ScalaPublishingConventionsPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.gradle.kotlin.dsl.register
import org.gradle.plugins.signing.SigningExtension

class ScalaPublishingConventionsPlugin : Plugin<Project> {

override fun apply(project: Project): Unit = project.run {
val scaladocJarTask: TaskProvider<Jar> = tasks.register<Jar>("scaladocJar") {
group = BasePlugin.BUILD_GROUP
Expand All @@ -37,11 +38,9 @@ class ScalaPublishingConventionsPlugin : Plugin<Project> {
publications {
register<MavenPublication>("maven") {
val scala3Suffix = "_3"

artifactId = basePluginExtension.archivesName.get() + scala3Suffix
from(components["java"])
artifact(scaladocJarTask)

pomConfiguration(project)
}
}
Expand All @@ -52,7 +51,6 @@ class ScalaPublishingConventionsPlugin : Plugin<Project> {
val signingKeyId: String? = configValue("signing.keyId", "SIGNING_KEY_ID")
val signingKey: String? = configValue("signing.key", "SIGNING_KEY")
val signingPassphrase: String? = configValue("signing.passphrase", "SIGNING_KEY_PASSPHRASE")

isRequired = !isLocal
useGpgCmd()
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassphrase)
Expand Down
2 changes: 1 addition & 1 deletion config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ console-reports:

output-reports:
active: false
exclude:
# exclude:
# - 'TxtOutputReport'
# - 'XmlOutputReport'
# - 'HtmlOutputReport'
Expand Down
Loading

0 comments on commit fe3a288

Please sign in to comment.