Skip to content

Commit c4dae7c

Browse files
authored
Merge pull request #13 from 0xera/classpath_dependencies
add dependencies from grease configuration to compileOnly
2 parents c081400 + 6b7559d commit c4dae7c

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

grease/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
plugins {
2+
`jvm-test-suite`
23
`kotlin-dsl`
34
alias(libs.plugins.publisher)
45
}
56

67
group = "io.deepmedia.tools"
78
version = "0.3.2"
89

10+
testing {
11+
suites {
12+
register<JvmTestSuite>("functionalTest") {
13+
useJUnit()
14+
testType.set(TestSuiteType.FUNCTIONAL_TEST)
15+
16+
dependencies {
17+
implementation(gradleTestKit())
18+
implementation(project.dependencies.kotlin("test") as String)
19+
implementation(project.dependencies.kotlin("test-junit") as String)
20+
}
21+
}
22+
}
23+
}
24+
925
gradlePlugin {
1026
plugins {
1127
create("grease") {
1228
id = "io.deepmedia.tools.grease"
1329
implementationClass = "io.deepmedia.tools.grease.GreasePlugin"
1430
}
1531
}
32+
33+
testSourceSets(sourceSets["functionalTest"])
1634
}
1735

1836
dependencies {
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package io.deepmedia.tools.grease
2+
3+
import org.gradle.testkit.runner.GradleRunner
4+
import java.nio.file.Path
5+
import kotlin.io.path.ExperimentalPathApi
6+
import kotlin.io.path.createTempDirectory
7+
import kotlin.io.path.deleteRecursively
8+
import kotlin.io.path.readText
9+
import kotlin.io.path.writeText
10+
import kotlin.test.AfterTest
11+
import kotlin.test.BeforeTest
12+
import kotlin.test.Test
13+
import kotlin.test.assertContains
14+
import kotlin.test.assertFails
15+
import kotlin.test.assertFalse
16+
17+
class GeneratedPomFileTest {
18+
19+
private var testProjectDir = createTempDirectory("tmp")
20+
private lateinit var settingsFile: Path
21+
private lateinit var buildFile: Path
22+
23+
@BeforeTest
24+
fun setup() {
25+
settingsFile = testProjectDir.resolve("settings.gradle.kts")
26+
buildFile = testProjectDir.resolve("build.gradle.kts")
27+
}
28+
29+
@Test
30+
fun test() {
31+
buildFile.writeText(
32+
"""
33+
plugins {
34+
`maven-publish`
35+
id("com.android.library") version "8.1.4"
36+
}
37+
38+
apply<io.deepmedia.tools.grease.GreasePlugin>()
39+
40+
android {
41+
namespace = "io.deepmedia.tools.grease.sample"
42+
compileSdk = 34
43+
defaultConfig {
44+
minSdk = 21
45+
}
46+
publishing {
47+
singleVariant("debug") {
48+
withSourcesJar()
49+
}
50+
}
51+
}
52+
53+
repositories {
54+
google()
55+
gradlePluginPortal()
56+
mavenCentral()
57+
}
58+
59+
publishing {
60+
publications {
61+
create("Test", MavenPublication::class.java) {
62+
afterEvaluate {
63+
from(components["debug"])
64+
}
65+
}
66+
}
67+
}
68+
dependencies {
69+
"grease"("com.otaliastudios:cameraview:2.7.2")
70+
"greaseTree"("androidx.core:core:1.0.0")
71+
}
72+
""".trimIndent()
73+
)
74+
75+
settingsFile.writeText("""
76+
pluginManagement {
77+
repositories {
78+
google()
79+
gradlePluginPortal()
80+
mavenCentral()
81+
}
82+
}
83+
84+
rootProject.name = "Sample"
85+
""".trimIndent())
86+
87+
GradleRunner.create()
88+
.withPluginClasspath()
89+
.withProjectDir(testProjectDir.toFile())
90+
.forwardOutput()
91+
.withArguments("generatePomFileForTestPublication")
92+
.build()
93+
94+
val pomContent = testProjectDir.resolve("build/publications/Test/pom-default.xml").readText()
95+
assertFalse(pomContent.contains("<groupId>androidx.core</groupId>") )
96+
assertFalse(pomContent.contains("<groupId>com.otaliastudios</groupId>") )
97+
}
98+
99+
@OptIn(ExperimentalPathApi::class)
100+
@AfterTest
101+
fun teardown() {
102+
testProjectDir.deleteRecursively()
103+
}
104+
}

grease/src/main/kotlin/io/deepmedia/tools/grease/configurations.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private fun Project.createGrease(name: String, isTransitive: Boolean): Configura
8080
}
8181
configurations.configureEach {
8282
val other = this
83-
if (other.name == nameOf(name, "compileClasspath")) {
83+
if (other.name == nameOf(name, "compileOnly")) {
8484
other.extendsFrom(configuration)
8585
}
8686
}

0 commit comments

Comments
 (0)