Skip to content

Commit 2764934

Browse files
renovate[bot]JavierSegoviaCordoba
authored andcommitted
Update dependency com.javiersc.hubdle to v0.5.0-alpha.10
| datasource | package | from | to | | ---------- | ----------------------------------------------------- | ------------- | ------------- | | maven | com.javiersc.hubdle:com.javiersc.hubdle.gradle.plugin | 0.5.0-alpha.8 | 0.5.0-alpha.10 |
1 parent 14dc21c commit 2764934

File tree

1,149 files changed

+612
-5076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,149 files changed

+612
-5076
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
### Changed
1818

19+
- `@Ignore*` annotation use CamelCase in the target name
1920
- `@IgnoreDARWIN` to `@IgnoreAPPLE`
2021

2122
### Deprecated

buildSrc/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
implementation(hubdle.javiersc.kotlin.kotlinStdlib)
11+
implementation(hubdle.jetbrains.kotlin.kotlinGradlePluginApi)
12+
}

buildSrc/gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
####################################################################################################
2+
### CONFIGURATION ###
3+
####################################################################################################
4+
root.project.name=build-src
5+
main.project.name=build-src
6+
project.group=com.javiersc.kotlin.build.src

buildSrc/settings.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pluginManagement {
2+
val hubdleVersion: String =
3+
rootDir.parentFile
4+
.resolve("gradle/libs.versions.toml")
5+
.readLines()
6+
.first { it.contains("hubdle") }
7+
.split("\"")[1]
8+
9+
repositories {
10+
gradlePluginPortal()
11+
mavenCentral()
12+
google()
13+
mavenLocal()
14+
}
15+
16+
plugins { id("com.javiersc.hubdle") version hubdleVersion }
17+
}
18+
19+
plugins { id("com.javiersc.hubdle") }
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import com.javiersc.kotlin.stdlib.capitalize
2+
import java.io.File
3+
import javax.inject.Inject
4+
import org.gradle.api.DefaultTask
5+
import org.gradle.api.NamedDomainObjectContainer
6+
import org.gradle.api.Project
7+
import org.gradle.api.model.ObjectFactory
8+
import org.gradle.api.plugins.BasePlugin.ASSEMBLE_TASK_NAME
9+
import org.gradle.api.provider.ListProperty
10+
import org.gradle.api.provider.MapProperty
11+
import org.gradle.api.provider.Provider
12+
import org.gradle.api.provider.ProviderFactory
13+
import org.gradle.api.tasks.Input
14+
import org.gradle.api.tasks.OutputFiles
15+
import org.gradle.api.tasks.TaskAction
16+
import org.gradle.api.tasks.TaskProvider
17+
import org.gradle.jvm.tasks.Jar
18+
import org.gradle.kotlin.dsl.listProperty
19+
import org.gradle.kotlin.dsl.register
20+
import org.gradle.kotlin.dsl.withType
21+
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
22+
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
23+
import org.jetbrains.kotlin.gradle.tasks.BaseKotlinCompile
24+
25+
abstract class GenerateIgnoreClassesTask
26+
@Inject
27+
constructor(
28+
objects: ObjectFactory,
29+
providers: ProviderFactory,
30+
) : DefaultTask() {
31+
32+
private val testDir: String =
33+
when (project.name) {
34+
"kotlin-test-junit" -> "junit"
35+
"kotlin-test-junit5" -> "junit5"
36+
"kotlin-test-testng" -> "testng"
37+
else -> throw IllegalStateException("Unknown project name: ${project.name}")
38+
}
39+
40+
private val importPackage: String =
41+
when (project.name) {
42+
"kotlin-test-junit" -> "org.junit.Ignore"
43+
"kotlin-test-junit5" -> "org.junit.jupiter.api.Disabled"
44+
"kotlin-test-testng" -> "org.testng.annotations.Ignore"
45+
else -> throw IllegalStateException("Unknown project name: ${project.name}")
46+
}
47+
48+
private val importClass: String =
49+
when (project.name) {
50+
"kotlin-test-junit" -> "Ignore"
51+
"kotlin-test-junit5" -> "Disabled"
52+
"kotlin-test-testng" -> "Ignore"
53+
else -> throw IllegalStateException("Unknown project name: ${project.name}")
54+
}
55+
56+
private val mainKotlin = "main${File.separatorChar}kotlin"
57+
private val testDirWithSeparator = "$testDir${File.separatorChar}"
58+
private val mainWithSeparator = "${File.separatorChar}main"
59+
private val buildGeneratedWithSeparator =
60+
"build${File.separatorChar}generated${File.separatorChar}"
61+
62+
@get:Input abstract val sourceSets: MapProperty<String, List<String>>
63+
64+
@Input
65+
val names: ListProperty<String> =
66+
objects
67+
.listProperty<String>()
68+
.convention(
69+
sourceSets.map { sourceSets ->
70+
sourceSets
71+
.filter { (name, _) -> name.contains("Main") }
72+
.filterNot { (name, _) ->
73+
listOf(
74+
"androidNativeMain",
75+
"appleMain",
76+
"iosMain",
77+
"linuxMain",
78+
"macosMain",
79+
"mingwMain",
80+
"nativeMain",
81+
"tvosMain",
82+
"watchosMain",
83+
)
84+
.any { name == it }
85+
}
86+
.flatMap { (_, dirs) -> dirs }
87+
.filter { dir -> dir.endsWith(mainKotlin) }
88+
.map { dir ->
89+
dir.substringAfterLast(testDirWithSeparator)
90+
.substringAfterLast(buildGeneratedWithSeparator)
91+
.substringBeforeLast(mainWithSeparator)
92+
}
93+
.distinct()
94+
}
95+
)
96+
97+
@OutputFiles
98+
val outputFiles: Provider<List<File>> =
99+
providers.provider {
100+
names
101+
.get()
102+
.map { name ->
103+
project.buildDir.resolve(
104+
"generated/$name/main/kotlin/com/javiersc/kotlin/test/"
105+
)
106+
}
107+
.flatMap { directory ->
108+
names.get().map { name ->
109+
val className = "Ignore${name.capitalize()}"
110+
val ignoreClass =
111+
directory.resolve("$className.kt").apply {
112+
parentFile.mkdirs()
113+
createNewFile()
114+
}
115+
116+
if (directory.path.contains("common")) {
117+
val fileContent = buildString {
118+
appendLine("package com.javiersc.kotlin.test")
119+
appendLine()
120+
appendLine("public expect annotation class $className")
121+
}
122+
ignoreClass.writeText(fileContent)
123+
}
124+
if (!directory.path.contains("common")) {
125+
val target =
126+
directory.path
127+
.substringAfterLast(testDirWithSeparator)
128+
.substringAfterLast(buildGeneratedWithSeparator)
129+
.substringBeforeLast(mainWithSeparator)
130+
131+
val import =
132+
if (target == "android" || target == "jvm") importPackage
133+
else "kotlin.test.Ignore"
134+
135+
val importClass =
136+
if (target == "android" || target == "jvm") importClass
137+
else "Ignore"
138+
139+
val fileContent = buildString {
140+
appendLine("package com.javiersc.kotlin.test")
141+
appendLine()
142+
if (name == target) {
143+
appendLine("import $import")
144+
appendLine()
145+
appendLine("public actual typealias $className = $importClass")
146+
} else {
147+
appendLine("public actual annotation class $className")
148+
}
149+
}
150+
151+
ignoreClass.writeText(fileContent)
152+
}
153+
154+
ignoreClass
155+
}
156+
}
157+
}
158+
159+
@TaskAction
160+
fun generate() {
161+
outputFiles.get()
162+
}
163+
164+
companion object {
165+
const val TASK_NAME = "generateIgnoreClasses"
166+
167+
fun register(
168+
project: Project,
169+
kotlinSourceSets: NamedDomainObjectContainer<KotlinSourceSet>
170+
) {
171+
val kotlinSourceSetsMap: Provider<Map<String, List<String>>> =
172+
project.provider {
173+
kotlinSourceSets.associate {
174+
it.name to it.kotlin.srcDirs.map { dir -> dir.path }
175+
}
176+
}
177+
178+
val generateIgnoreClassesTask: TaskProvider<GenerateIgnoreClassesTask> =
179+
project.tasks.register<GenerateIgnoreClassesTask>(TASK_NAME)
180+
181+
generateIgnoreClassesTask.configure { sourceSets.set(kotlinSourceSetsMap) }
182+
183+
project.tasks.withType<BaseKotlinCompile>().configureEach {
184+
dependsOn(generateIgnoreClassesTask)
185+
}
186+
187+
project.tasks.withType<KotlinCompile<*>>().configureEach {
188+
dependsOn(generateIgnoreClassesTask)
189+
}
190+
191+
project.tasks.withType<Jar>().configureEach { dependsOn(generateIgnoreClassesTask) }
192+
193+
project.afterEvaluate {
194+
listOf(
195+
"detekt",
196+
"spotlessKotlin",
197+
)
198+
.forEach { tasks.findByName(it)?.dependsOn(generateIgnoreClassesTask) }
199+
}
200+
201+
project.tasks.named(ASSEMBLE_TASK_NAME) { dependsOn(generateIgnoreClassesTask) }
202+
}
203+
}
204+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pom.scm.developerConnection=scm:git:[email protected]:JavierSegoviaCordoba/kotlin-s
3030
####################################################################################################
3131
kotlin.code.style=official
3232
kotlin.incremental.useClasspathSnapshot=true
33-
kotlin.js.compiler=both
33+
kotlin.js.compiler=ir
3434
org.gradle.caching=true
3535
#org.gradle.configureondemand=true
3636
org.gradle.jvmargs=-Xmx3072m

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
hubdle = "0.5.0-alpha.8"
2+
hubdle = "0.5.0-alpha.10"
33

44
[plugins]
55
javiersc-hubdle = { id = "com.javiersc.hubdle", version.ref = "hubdle" }

0 commit comments

Comments
 (0)