dead code and dependency removal
This commit is contained in:
@@ -19,21 +19,13 @@ configure<ExtraPropertiesExtension> {
|
||||
|
||||
dependencies {
|
||||
|
||||
// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
||||
|
||||
|
||||
// Align versions of all Kotlin components
|
||||
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
|
||||
|
||||
// Use the Kotlin JDK 8 standard library.
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("net.woggioni:worth:1.0")
|
||||
|
||||
// Use the Kotlin test library.
|
||||
// testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
|
||||
// Use the Kotlin JUnit integration.
|
||||
// testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.2")
|
||||
testImplementation(gradleTestKit())
|
||||
|
||||
@@ -41,31 +33,12 @@ dependencies {
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
// Define the plugin
|
||||
val my_first_plugin by plugins.creating {
|
||||
val dependencyExportPlugin by plugins.creating {
|
||||
id = "net.woggioni.plugins.dependency-export"
|
||||
implementationClass = "net.woggioni.plugins.DependencyExportPlugin"
|
||||
}
|
||||
}
|
||||
|
||||
// Add a source set for the functional test suite
|
||||
//val functionalTestSourceSet = sourceSets.create("functionalTest") {
|
||||
//}
|
||||
//
|
||||
//gradlePlugin.testSourceSets(functionalTestSourceSet)
|
||||
//configurations.getByName("functionalTestImplementation").extendsFrom(configurations.getByName("testImplementation"))
|
||||
|
||||
// Add a task to run the functional tests
|
||||
//val functionalTest by tasks.creating(Test::class) {
|
||||
// testClassesDirs = functionalTestSourceSet.output.classesDirs
|
||||
// classpath = functionalTestSourceSet.runtimeClasspath
|
||||
//}
|
||||
//
|
||||
//val check by tasks.getting(Task::class) {
|
||||
// // Run the functional tests as part of `check`
|
||||
// dependsOn(functionalTest)
|
||||
//}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
systemProperty("plugin.build.dir", tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().first().destinationDir)
|
||||
@@ -74,7 +47,7 @@ tasks.withType<Test>().configureEach {
|
||||
}
|
||||
|
||||
tasks.withType<Wrapper>().configureEach {
|
||||
gradleVersion = "6.1.1"
|
||||
gradleVersion = "6.3"
|
||||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This Kotlin source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package my.first.plugin
|
||||
|
||||
import java.io.File
|
||||
import org.gradle.testkit.runner.GradleRunner
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* A simple functional test for the 'my.first.plugin.greeting' plugin.
|
||||
*/
|
||||
class MyFirstPluginPluginFunctionalTest {
|
||||
@Test
|
||||
fun `can run task`() {
|
||||
// Setup the test build
|
||||
val projectDir = File("build/functionalTest")
|
||||
projectDir.mkdirs()
|
||||
projectDir.resolve("settings.gradle").writeText("")
|
||||
projectDir.resolve("build.gradle").writeText("""
|
||||
plugins {
|
||||
id('my.first.plugin.greeting')
|
||||
}
|
||||
""")
|
||||
|
||||
// Run the build
|
||||
val runner = GradleRunner.create()
|
||||
runner.forwardOutput()
|
||||
runner.withPluginClasspath()
|
||||
runner.withArguments("greeting")
|
||||
runner.withProjectDir(projectDir)
|
||||
val result = runner.build();
|
||||
|
||||
// Verify the result
|
||||
Assert.assertTrue(result.output.contains("Hello from plugin 'my.first.plugin.greeting'"))
|
||||
}
|
||||
}
|
@@ -3,14 +3,6 @@
|
||||
*/
|
||||
package net.woggioni.plugins
|
||||
|
||||
import net.woggioni.jwo.JWO
|
||||
import net.woggioni.jwo.tree.StackContext
|
||||
import net.woggioni.jwo.tree.TreeNode
|
||||
import net.woggioni.jwo.tree.TreeNodeVisitor
|
||||
import net.woggioni.jwo.tree.TreeWalker
|
||||
import net.woggioni.worth.serialization.json.JSONDumper
|
||||
import net.woggioni.worth.value.ObjectValue
|
||||
import net.woggioni.worth.xface.Value
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
|
||||
@@ -21,7 +13,6 @@ import org.gradle.api.artifacts.result.UnresolvedDependencyResult
|
||||
import java.io.BufferedWriter
|
||||
import java.io.OutputStreamWriter
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
|
||||
open class DependencyExportPluginExtension {
|
||||
var configurationName: String = "default"
|
||||
@@ -92,71 +83,6 @@ object DependencyExporter {
|
||||
}
|
||||
}
|
||||
|
||||
class DependencyTreeNode(val component: ResolvedComponentResult) : TreeNode<DependencyTreeNode> {
|
||||
override fun children(): Iterator<DependencyTreeNode> {
|
||||
return object : Iterator<DependencyTreeNode> {
|
||||
val it = component.dependencies.iterator()
|
||||
override fun hasNext(): Boolean {
|
||||
return it.hasNext()
|
||||
}
|
||||
|
||||
override fun next(): DependencyTreeNode {
|
||||
val dependency = it.next()
|
||||
return when (dependency) {
|
||||
is ResolvedDependencyResult -> {
|
||||
DependencyTreeNode(dependency.selected)
|
||||
}
|
||||
is UnresolvedDependencyResult -> {
|
||||
throw dependency.failure
|
||||
}
|
||||
else -> {
|
||||
throw NotImplementedError("${dependency::class}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun export(project: Project) {
|
||||
val cfg = Value.Configuration.builder()
|
||||
.serializeReferences(true)
|
||||
.objectValueImplementation(ObjectValue.Implementation.ArrayList)
|
||||
.build()
|
||||
val result = ObjectValue.newInstance(cfg)
|
||||
project.configurations.all { configuration ->
|
||||
if (configuration.isCanBeResolved) {
|
||||
val configDeps = ObjectValue.newInstance(cfg)
|
||||
val visitor = object : TreeNodeVisitor<DependencyTreeNode, ObjectValue> {
|
||||
override fun visitPre(stack: MutableList<StackContext<DependencyTreeNode, ObjectValue>>): TreeNodeVisitor.VisitOutcome {
|
||||
val stackElement = JWO.tail(stack)
|
||||
stackElement.context = ObjectValue.newInstance(cfg)
|
||||
val id = stackElement.node.component.id
|
||||
if (stack.size == 1) {
|
||||
configDeps.put(id.displayName, stackElement.context)
|
||||
} else if (stack.size > 1) {
|
||||
val parentStackElement = JWO.tail(stack, -2)
|
||||
parentStackElement.context.put(id.displayName, stackElement.context)
|
||||
}
|
||||
return TreeNodeVisitor.VisitOutcome.CONTINUE
|
||||
}
|
||||
// override fun visitPost(stack: MutableList<StackContext<DependencyTreeNode, ObjectValue>>?) {
|
||||
// val stackElement = JWO.tail(stack)
|
||||
// if(stack.size > 1) {
|
||||
// val parentStackElement = JWO.tail(stack, -2)
|
||||
// parentStackElement.context.add(StringValue(stackElement.node.component.toString()))
|
||||
// }
|
||||
// }
|
||||
}
|
||||
TreeWalker(visitor).walk(DependencyTreeNode(configuration.incoming.resolutionResult.root))
|
||||
result.put(configuration.name, configDeps)
|
||||
}
|
||||
}
|
||||
BufferedWriter(OutputStreamWriter(Files.newOutputStream(Paths.get("/tmp/dependencies.json")))).use {
|
||||
JSONDumper.newInstance(cfg).dump(result, it)
|
||||
}
|
||||
}
|
||||
|
||||
class DependencyExportPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
val extension = DependencyExportPluginExtension()
|
||||
|
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
package net.woggioni.plugins
|
||||
|
||||
import net.woggioni.plugins.installResource
|
||||
import org.gradle.testkit.runner.GradleRunner
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
Reference in New Issue
Block a user