Skip to content

Commit

Permalink
Feature/12 add option to configure output directory (#15)
Browse files Browse the repository at this point in the history
* feat: Add option to configure output directory
* chore: change release version to 0.3.0

Closes: #12
  • Loading branch information
denis-markushin committed Apr 26, 2024
1 parent 5b4c7de commit e82ae2a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and [Testcontainers](https://testcontainers.com)
dbName = "my_database"
liquibaseChangelog = file("/path/to/file.yml")
excludeTables = "(table1|table2)"
outputDir = project.layout.buildDirectory.dir("schemaspy/sakila").get()
}
```
3. Execute gradle `generateSchemaspyDocs` task:
Expand Down
1 change: 1 addition & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ plugins {
schemaspyConfig {
dbName = "sakila"
liquibaseChangelog = file("${project.projectDir}/src/main/resources/liquibase/changelog.yml")
outputDir = project.layout.buildDirectory.dir("schemaspy/sakila").get()
}
2 changes: 1 addition & 1 deletion plugin-build/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ID=io.github.denis-markushin.schemaspy-plugin
VERSION=0.2.2
VERSION=0.3.0
GROUP=io.github.denis-markushin.gradle.schemaspy
DISPLAY_NAME=SchemaSpy Gradle plugin
DESCRIPTION=The plugin to generate docs using Testcontainers and SchemaSpy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.denismarkushin.gradle.schemaspy

import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import javax.inject.Inject
Expand Down Expand Up @@ -46,4 +47,9 @@ abstract class SchemaspyExtension
* Should unzip output or not. Default value is: true
*/
val unzipOutput: Property<Boolean> = objects.property(Boolean::class.java).convention(true)

/**
* Target directory for output
*/
val outputDir: DirectoryProperty = objects.directoryProperty()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ private const val TASK_NAME = "generateSchemaspyDocs"
abstract class SchemaspyPlugin : Plugin<Project> {
override fun apply(project: Project) {
val extension = project.extensions.create(EXTENSION_NAME, SchemaspyExtension::class.java, project)
val defaultSchemaspyOutputDir = project.layout.buildDirectory.get().dir("schemaspy")

// Add a task that uses configuration from the extension object
project.tasks.register(TASK_NAME, SchemaspyTask::class.java) {
Expand All @@ -17,10 +18,8 @@ abstract class SchemaspyPlugin : Plugin<Project> {
it.excludeTables.set(extension.excludeTables)
it.postgresDockerImage.set(extension.postgresDockerImage)
it.schemaspyDockerImage.set(extension.schemaspyDockerImage)
it.outputDir.set(project.schemaSpyOutputDir().dir(it.dbName))
it.outputDir.set(extension.outputDir.getOrElse(defaultSchemaspyOutputDir))
it.unzipOutput.set(extension.unzipOutput)
}
}

private fun Project.schemaSpyOutputDir() = layout.buildDirectory.get().dir("schemaspy")
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ abstract class SchemaspyTask : DefaultTask() {
abstract val unzipOutput: Property<Boolean>

@get:OutputDirectory
@get:Optional
abstract val outputDir: DirectoryProperty

private val postgresImage by lazy {
Expand Down

0 comments on commit e82ae2a

Please sign in to comment.