forked from deepmedia/Grease
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request deepmedia#13 from 0xera/classpath_dependencies
add dependencies from grease configuration to compileOnly
- Loading branch information
Showing
3 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
grease/src/functionalTest/kotlin/io/deepmedia/tools/grease/GeneratedPomFileTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package io.deepmedia.tools.grease | ||
|
||
import org.gradle.testkit.runner.GradleRunner | ||
import java.nio.file.Path | ||
import kotlin.io.path.ExperimentalPathApi | ||
import kotlin.io.path.createTempDirectory | ||
import kotlin.io.path.deleteRecursively | ||
import kotlin.io.path.readText | ||
import kotlin.io.path.writeText | ||
import kotlin.test.AfterTest | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
import kotlin.test.assertContains | ||
import kotlin.test.assertFails | ||
import kotlin.test.assertFalse | ||
|
||
class GeneratedPomFileTest { | ||
|
||
private var testProjectDir = createTempDirectory("tmp") | ||
private lateinit var settingsFile: Path | ||
private lateinit var buildFile: Path | ||
|
||
@BeforeTest | ||
fun setup() { | ||
settingsFile = testProjectDir.resolve("settings.gradle.kts") | ||
buildFile = testProjectDir.resolve("build.gradle.kts") | ||
} | ||
|
||
@Test | ||
fun test() { | ||
buildFile.writeText( | ||
""" | ||
plugins { | ||
`maven-publish` | ||
id("com.android.library") version "8.1.4" | ||
} | ||
apply<io.deepmedia.tools.grease.GreasePlugin>() | ||
android { | ||
namespace = "io.deepmedia.tools.grease.sample" | ||
compileSdk = 34 | ||
defaultConfig { | ||
minSdk = 21 | ||
} | ||
publishing { | ||
singleVariant("debug") { | ||
withSourcesJar() | ||
} | ||
} | ||
} | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
publishing { | ||
publications { | ||
create("Test", MavenPublication::class.java) { | ||
afterEvaluate { | ||
from(components["debug"]) | ||
} | ||
} | ||
} | ||
} | ||
dependencies { | ||
"grease"("com.otaliastudios:cameraview:2.7.2") | ||
"greaseTree"("androidx.core:core:1.0.0") | ||
} | ||
""".trimIndent() | ||
) | ||
|
||
settingsFile.writeText(""" | ||
pluginManagement { | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
rootProject.name = "Sample" | ||
""".trimIndent()) | ||
|
||
GradleRunner.create() | ||
.withPluginClasspath() | ||
.withProjectDir(testProjectDir.toFile()) | ||
.forwardOutput() | ||
.withArguments("generatePomFileForTestPublication") | ||
.build() | ||
|
||
val pomContent = testProjectDir.resolve("build/publications/Test/pom-default.xml").readText() | ||
assertFalse(pomContent.contains("<groupId>androidx.core</groupId>") ) | ||
assertFalse(pomContent.contains("<groupId>com.otaliastudios</groupId>") ) | ||
} | ||
|
||
@OptIn(ExperimentalPathApi::class) | ||
@AfterTest | ||
fun teardown() { | ||
testProjectDir.deleteRecursively() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters