diff --git a/build.gradle.kts b/build.gradle.kts index 8643f52..8589791 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,12 +46,6 @@ application { mainClass.set("br.com.felipezorzo.zpa.cli.MainKt") } -val copyDependencies = tasks.create("copyDependencies") { - from(configurations.runtimeClasspath) - into(layout.buildDirectory.dir("dependencies/flat")) -} -tasks["assemble"].dependsOn(copyDependencies) - publishing { repositories { maven { @@ -190,11 +184,13 @@ jreleaser { path.set(file(jdkPath)) } - mainJar { - path.set(file("build/libs/zpa-cli-{{projectVersion}}.jar")) + javaArchive { + path = "build/distributions/zpa-cli-{{projectVersion}}.tar" } - jars { - pattern.set("build/dependencies/flat/*.jar") + fileSet { + input = "src/dist/plugins" + output = "plugins" + includes = listOf("*") } } } diff --git a/src/dist/plugins/README.txt b/src/dist/plugins/README.txt new file mode 100644 index 0000000..c3d102b --- /dev/null +++ b/src/dist/plugins/README.txt @@ -0,0 +1,3 @@ +Put your custom plugins in this directory. + +Follow the instructions at https://github.com/felipebz/zpa/wiki/Create-a-plugin-with-custom-rules to create a custom plugin with additional rules. \ No newline at end of file diff --git a/src/main/kotlin/br/com/felipezorzo/zpa/cli/Main.kt b/src/main/kotlin/br/com/felipezorzo/zpa/cli/Main.kt index 7cc9097..4666c09 100644 --- a/src/main/kotlin/br/com/felipezorzo/zpa/cli/Main.kt +++ b/src/main/kotlin/br/com/felipezorzo/zpa/cli/Main.kt @@ -23,10 +23,14 @@ import org.sonar.plugins.plsqlopen.api.PlSqlFile import org.sonar.plugins.plsqlopen.api.checks.PlSqlVisitor import java.io.File import java.nio.charset.StandardCharsets +import java.nio.file.Path import java.util.* import java.util.concurrent.TimeUnit import java.util.logging.LogManager import java.util.stream.Collectors +import kotlin.io.path.absolute +import kotlin.io.path.extension +import kotlin.io.path.name import kotlin.system.measureTimeMillis import br.com.felipezorzo.zpa.cli.sqissue.Issue as GenericIssue @@ -40,7 +44,14 @@ class Main(private val args: Arguments) { LogManager.getLogManager().readConfiguration(it) } - val pluginManager = PluginManager() + val codePath = Path.of(Main::class.java.protectionDomain.codeSource.location.path).absolute() + val appHome = if (codePath.extension == "jar" && (codePath.parent.name == "lib" || codePath.parent.name == "jars")) { + codePath.parent.parent.name + } else { + "." + } + + val pluginManager = PluginManager(Path.of(appHome, "plugins")) pluginManager.loadPlugins() pluginManager.startPlugins() diff --git a/src/main/kotlin/br/com/felipezorzo/zpa/cli/plugin/PluginManager.kt b/src/main/kotlin/br/com/felipezorzo/zpa/cli/plugin/PluginManager.kt index 41fe180..f7e8ca8 100644 --- a/src/main/kotlin/br/com/felipezorzo/zpa/cli/plugin/PluginManager.kt +++ b/src/main/kotlin/br/com/felipezorzo/zpa/cli/plugin/PluginManager.kt @@ -2,8 +2,9 @@ package br.com.felipezorzo.zpa.cli.plugin import org.pf4j.DefaultPluginManager import org.pf4j.PluginDescriptorFinder +import java.nio.file.Path -class PluginManager: DefaultPluginManager() { +class PluginManager(pluginRoot: Path): DefaultPluginManager(pluginRoot) { override fun createPluginDescriptorFinder(): PluginDescriptorFinder { return ZpaPluginDescriptorFinder()