Un exemple de tâche Gradle pour générer la documentation DB à l'aide de SchemaSpy.
build.gradle
//-----------------------------------------------------------------------------
// Plugins
//-----------------------------------------------------------------------------
plugins {
id 'java'
id 'de.undercouch.download' version '4.0.1'
}
//-----------------------------------------------------------------------------
// Dependency Management
//-----------------------------------------------------------------------------
//Paramètres de configuration
configurations {
//Configuration pour le pilote JDBC
jdbc
}
//Dépôt de source d'acquisition de bibliothèque
repositories {
//Dépôt JCenter
jcenter()
//Dépôt central de Maven
mavenCentral()
}
//Paramètres de dépendance
dependencies {
//Bibliothèque de pilotes JDBC
jdbc(
'org.mariadb.jdbc:mariadb-java-client:2.5.1'
)
}
//-----------------------------------------------------------------------------
// Tasks
//-----------------------------------------------------------------------------
tasks.register( 'schemaSpy', JavaExec ) {
description = 'Generates database documents.'
group = name
ext.outputDir = file( "${buildDir}/${name}" )
download {
ext.schemaSpyFile = file( "${downloadTaskDir}/${name}/schemaspy.jar" )
src( 'https://github.com/schemaspy/schemaspy/releases/download/v6.1.0/schemaspy-6.1.0.jar' )
dest( schemaSpyFile )
overwrite = false
}
File driverFile = configurations.jdbc.files.first()
main = '-jar'
args = [
schemaSpyFile,
'-t', 'mariadb',
'-dp', driverFile,
'-host', 'localhost',
'-port', '3306',
'-u', 'user',
'-p', 'password',
'-db', 'sample',
'-s', 'sample',
'-o', outputDir
]
doFirst {
outputDir.deleteDir()
}
}
Recommended Posts