Skip to content

Commit 1bb06cd

Browse files
build
- Simplified exposing sourceSets using a for loop - Exposes "generate" (fix's IntelliJ issue) - You can now run a single generator instead of needing to run every generator via autogenerate
1 parent d248e9d commit 1bb06cd

2 files changed

Lines changed: 33 additions & 18 deletions

File tree

build.gradle.kts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,26 @@ tasks.register<Jar>("oneJarBin") {
107107
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
108108
}
109109
}
110+
111+
// Classpath for running any single code generator that lives in each module's `generate` directory.
112+
//
113+
// ./gradlew runGenerator -Pgenerator=org.ejml.dense.block.GeneratorTileMultiplication_F64
114+
//
115+
tasks.register<JavaExec>("runGenerator") {
116+
group = "ejml"
117+
description = "Runs a code generator by fully qualified class name. Use -Pgenerator=<fqcn>."
118+
workingDir = rootDir
119+
mainClass.set(providers.gradleProperty("generator"))
120+
121+
val parts = project.subprojects
122+
.filter { it.plugins.hasPlugin("ejml.java-conventions") }
123+
.map { dependencies.project(mapOf("path" to it.path, "configuration" to "generateOutput")) }
124+
.plus(dependencies.project(mapOf("path" to ":main:autocode", "configuration" to "runtimeElements")))
125+
classpath = configurations.detachedConfiguration(*parts.toTypedArray())
126+
127+
doFirst {
128+
if (!mainClass.isPresent)
129+
throw GradleException("Specify the generator's fully qualified class name, e.g.\n" +
130+
" ./gradlew runGenerator -Pgenerator=org.ejml.dense.block.GeneratorTileMultiplication_F64")
131+
}
132+
}

buildSrc/src/main/kotlin/ejml.java-conventions.gradle.kts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,17 @@ sourceSets {
6161
}
6262
}
6363

64-
// Expose benchmarks source set output for sibling modules (mainly :regression)
65-
val benchmarksOutput by configurations.creating {
66-
isCanBeConsumed = true
67-
isCanBeResolved = false
68-
}
69-
sourceSets["benchmarks"].output.classesDirs.forEach { dir ->
70-
artifacts.add("benchmarksOutput", dir) {
71-
builtBy(tasks.named("benchmarksClasses"))
64+
// Expose these sourceSets so that sibling modules have access to them. Without this
65+
// regression, and testing both fail. IntelliJ can't run generators
66+
listOf("generate", "benchmarks", "test").forEach { sourceSet ->
67+
val output = configurations.create("${sourceSet}Output") {
68+
isCanBeConsumed = true
69+
isCanBeResolved = false
7270
}
73-
}
74-
75-
// Expose test source set output for sibling modules that need test fixtures
76-
val testOutput by configurations.creating {
77-
isCanBeConsumed = true
78-
isCanBeResolved = false
79-
}
80-
sourceSets["test"].output.classesDirs.forEach { dir ->
81-
artifacts.add("testOutput", dir) {
82-
builtBy(tasks.named("testClasses"))
71+
sourceSets[sourceSet].output.classesDirs.forEach { dir ->
72+
artifacts.add(output.name, dir) {
73+
builtBy(tasks.named("${sourceSet}Classes"))
74+
}
8375
}
8476
}
8577

0 commit comments

Comments
 (0)