added jpms-check plugin
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This Kotlin source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package net.woggioni.plugins.dependency.export
|
||||
|
||||
import org.gradle.testkit.runner.GradleRunner
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
class DependencyExportPluginTest {
|
||||
|
||||
@TempDir
|
||||
lateinit var testGradleHomeDir : Path
|
||||
|
||||
@TempDir
|
||||
lateinit var testProjectDir : Path
|
||||
lateinit var buildFile : Path
|
||||
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
buildFile = testProjectDir.resolve("build.gradle.kts")
|
||||
}
|
||||
|
||||
fun getStandardGradleRunnerFor(taskName: String): GradleRunner {
|
||||
return GradleRunner.create()
|
||||
.withDebug(true)
|
||||
.withProjectDir(testProjectDir.toFile())
|
||||
.withArguments(taskName, "-s", "--info", "-g", testGradleHomeDir.toString())
|
||||
.withPluginClasspath()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlin() {
|
||||
installResource("build.gradle.kts", testProjectDir)
|
||||
installResource("settings.gradle.kts", testProjectDir)
|
||||
installResource("gradle.properties", testProjectDir)
|
||||
val runner = getStandardGradleRunnerFor("exportDependencies")
|
||||
runner.build()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGroovy() {
|
||||
installResource("build.gradle", testProjectDir)
|
||||
installResource("settings.gradle.kts", testProjectDir)
|
||||
installResource("gradle.properties", testProjectDir)
|
||||
val runner = getStandardGradleRunnerFor("exportDependencies")
|
||||
runner.build()
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package net.woggioni.plugins.dependency.export
|
||||
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun Any.installResource(resourceName: String, destination: Path) {
|
||||
val outputFile = run {
|
||||
val realDestination = if (Files.isSymbolicLink(destination)) {
|
||||
destination.toRealPath()
|
||||
} else {
|
||||
destination
|
||||
}
|
||||
when {
|
||||
!Files.exists(realDestination) -> {
|
||||
Files.createDirectories(realDestination.parent)
|
||||
realDestination
|
||||
}
|
||||
Files.isDirectory(realDestination) ->
|
||||
realDestination.resolve(resourceName.substring(1 + resourceName.lastIndexOf('/')))
|
||||
Files.isRegularFile(realDestination) -> realDestination
|
||||
else -> throw IllegalStateException("Path '${realDestination}' is neither a file nor a directory")
|
||||
}
|
||||
}
|
||||
(javaClass.getResourceAsStream(resourceName)
|
||||
?: javaClass.classLoader.getResourceAsStream(resourceName))?.use { inputStream ->
|
||||
Files.copy(inputStream, outputFile, StandardCopyOption.REPLACE_EXISTING)
|
||||
} ?: throw FileNotFoundException(resourceName)
|
||||
}
|
2
dependency-export/src/test/resources/gradle.properties
Normal file
2
dependency-export/src/test/resources/gradle.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
org.gradle.jvmargs=-Xmx256m
|
||||
org.gradle.caching=false
|
@@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "1.3.61"
|
||||
id "net.woggioni.plugins.dependency-export"
|
||||
}
|
||||
|
||||
exportDependencies {
|
||||
configurationName = 'runtime'
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
runtime("org.hibernate:hibernate-core:5.4.13.Final")
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.3.71"
|
||||
id("net.woggioni.plugins.dependency-export")
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
runtime("org.hibernate:hibernate-core:5.4.13.Final")
|
||||
}
|
||||
|
Reference in New Issue
Block a user