Skip to content

Commit

Permalink
impl with repsy maven
Browse files Browse the repository at this point in the history
  • Loading branch information
elect86 committed Mar 6, 2021
1 parent 80907cc commit 75e7201
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 31 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions 11/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

plugins {
java
`kotlin-dsl`
}

dependencies {

implementation(platform("kx.platform:plugin:0.0.7"))
implementation(platform("kx.platform:plugin:0.1.4"))

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")

Expand Down
2 changes: 1 addition & 1 deletion 11/src/main/kotlin/kx/kotlin.11.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIB
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
`java-library`
id("kx.kotlin")
}

Expand Down
3 changes: 1 addition & 2 deletions 8/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

plugins {
java
`kotlin-dsl`
}

dependencies {

implementation(platform("kx.platform:plugin:0.0.7"))
implementation(platform("kx.platform:plugin:0.1.4"))

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")

Expand Down
2 changes: 1 addition & 1 deletion 8/src/main/kotlin/kx/kotlin.8.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIB
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
`java-library`
id("kx.kotlin")
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ subprojects {
}

group = "kx.build-logic"
version = "0.4.6"
version = "0.5.9"

// limited dsl support inside here
fun publishing(configure: Action<PublishingExtension>) = extensions.configure("publishing", configure)
Expand Down
17 changes: 5 additions & 12 deletions commons/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@

plugins {
java
`kotlin-dsl`
}

dependencies {

// implementation(platform("kx.platform:plugin:0.0.7"))
implementation(platform("kx.platform:plugin:0.1.4"))

// implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.4.31")
// implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin")
}
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin")
implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin")

//gradlePlugin {
// // Define the plugin
// plugins.create("11") {
// id = "kx.kotlin"
// implementationClass = "kx.kotlin.11"
// }
//}
implementation(project(":impl"))
}
6 changes: 3 additions & 3 deletions commons/src/main/kotlin/kx/kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package kx
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
`java-library`
// kotlin("jvm")
id("org.jetbrains.kotlin.jvm")
// id("com.example.jacoco")
Expand All @@ -18,9 +18,9 @@ repositories {

dependencies {

implementation(platform("kx.platform:source:0.0.7"))
implementation(platform("kx.platform:source:0.1.4"))

testImplementation(platform("kx.platform:test:0.0.7"))
testImplementation(platform("kx.platform:test:0.1.4"))

implementation(kotlin("stdlib-jdk8"))

Expand Down
3 changes: 1 addition & 2 deletions docs/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

plugins {
java
`kotlin-dsl`
}

dependencies {

implementation(platform("kx.platform:plugin:0.0.7"))
implementation(platform("kx.platform:plugin:0.1.4"))

implementation("org.jetbrains.dokka:dokka-gradle-plugin")
implementation("org.jetbrains.dokka:dokka-core")
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/kotlin/kx/dokka.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URL

plugins {
java
`java-library`
id("org.jetbrains.dokka")
}

Expand Down
4 changes: 4 additions & 0 deletions impl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

plugins {
`kotlin-dsl`
}
83 changes: 83 additions & 0 deletions impl/src/main/kotlin/kx/kxUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package kx

import org.gradle.api.Action
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo

enum class KxProject {
kool, unsigned, glm, gli, vkk, uno, imgui, assimp, openvr;

val projectName
get() = when (this) {
unsigned -> "kotlin-unsigned"
uno -> "uno-sdk"
else -> name
}
}

//object KxBundle {
// val none = emptyArray<LwjglModules>()
// val everything = LwjglModules.values()
// val gettingStarted = arrayOf(assimp, bgfx, glfw, nanovg, nuklear, openal, opengl, par, stb, vulkan)
// val minimalOpenGL = arrayOf(assimp, glfw, openal, opengl, stb)
// val minimalOpenGLES = arrayOf(assimp, egl, glfw, openal, opengles, stb)
// val minimalVulkan = arrayOf(assimp, glfw, openal, stb, vulkan)
//}

//@JvmName("KxImplementation2")
//fun DependencyHandler.kxImplementation(modules: Array<KxProject>) = impl(false, modules)
//
//@JvmName("KxTestImplementation2")
//fun DependencyHandler.kxTestImplementation(modules: Array<KxProject>) = impl(true, modules)

fun DependencyHandler.kxImplementation(vararg projects: KxProject) = add(false, projects as Array<KxProject>)
fun DependencyHandler.kxTestImplementation(vararg projects: KxProject) = add(true, projects as Array<KxProject>)

private fun DependencyHandler.add(test: Boolean, projects: Array<KxProject>) {
for (p in projects) {
val group = "com.github.kotlin-graphics"
val art = p.projectName
if (test)
testImpl("$group:$art") { exclude("kx.platform") }
else
impl("$group:$art") { exclude("kx.platform") }
}
}

private fun DependencyHandler.impl(
dependencyNotation: String,
dependencyConfiguration: Action<ExternalModuleDependency>
): ExternalModuleDependency = addDependencyTo(
this, "implementation", dependencyNotation, dependencyConfiguration
) as ExternalModuleDependency

private fun DependencyHandler.testImpl(
dependencyNotation: String,
dependencyConfiguration: Action<ExternalModuleDependency>
): ExternalModuleDependency = addDependencyTo(
this, "testImplementation", dependencyNotation, dependencyConfiguration
) as ExternalModuleDependency

private fun <T : ModuleDependency> T.exclude(group: String? = null, module: String? = null): T =
uncheckedCast(exclude(excludeMapFor(group, module)))

@Suppress("unchecked_cast", "nothing_to_inline")
private inline fun <T> uncheckedCast(obj: Any?): T =
obj as T

private fun excludeMapFor(group: String?, module: String?): Map<String, String> =
mapOfNonNullValuesOf(
"group" to group,
"module" to module
)

private fun mapOfNonNullValuesOf(vararg entries: Pair<String, String?>): Map<String, String> =
mutableMapOf<String, String>().apply {
for ((k, v) in entries) {
if (v != null) {
put(k, v)
}
}
}
9 changes: 9 additions & 0 deletions impl/src/main/kotlin/kx/util.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kx.kx

plugins {
`java-library`
}

repositories {
maven("https://repo.repsy.io/mvn/elect/kx")
}
3 changes: 1 addition & 2 deletions lwjgl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

plugins {
java
`kotlin-dsl`
}

dependencies {

implementation(platform("kx.platform:plugin:0.0.7"))
implementation(platform("kx.platform:plugin:0.1.4"))
}
4 changes: 2 additions & 2 deletions lwjgl/src/main/kotlin/kx/lwjgl.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package kx

plugins {
java
`java-library`
}

dependencies {

implementation(platform("kx.platform:source:0.0.7"))
implementation(platform("kx.platform:source:0.1.4"))
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fun DependencyHandler.lwjglTestImplementation(modules: Array<LwjglModules>) = im
fun DependencyHandler.lwjglImplementation(vararg modules: LwjglModules) = impl(false, modules as Array<LwjglModules>)
fun DependencyHandler.lwjglTestImplementation(vararg modules: LwjglModules) = impl(true, modules as Array<LwjglModules>)

fun DependencyHandler.impl(test: Boolean, modules: Array<LwjglModules>) {
private fun DependencyHandler.impl(test: Boolean, modules: Array<LwjglModules>) {
// core
add(test, "", true)
for (m in modules)
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ include("8")
include("11")
include("docs")
include("lwjgl")
//include("jitpack")
//include("jitpack")
include("impl")

0 comments on commit 75e7201

Please sign in to comment.