Skip to content

Commit 1a4d0a8

Browse files
committed
Use 'grace-doc' Gradle plugin to generate documentation
Closes gh-64
1 parent 0a0e788 commit 1a4d0a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+711
-268
lines changed

build.gradle

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ buildscript {
66
dependencies {
77
classpath "org.graceframework:grace-gradle-plugin:$graceVersion"
88
classpath "io.github.gradle-nexus:publish-plugin:2.0.0"
9-
classpath "org.asciidoctor:asciidoctor-gradle-jvm:3.3.2"
109
}
1110
}
1211

@@ -25,12 +24,13 @@ group = "org.graceframework.plugins"
2524

2625
apply plugin: "eclipse"
2726
apply plugin: "idea"
27+
apply plugin: "groovy"
2828
apply plugin: "java-library"
29+
apply plugin: "org.graceframework.grace-doc"
2930
apply plugin: "org.graceframework.grace-plugin"
3031
apply plugin: "io.github.gradle-nexus.publish-plugin"
3132
apply plugin: "maven-publish"
3233
apply plugin: "signing"
33-
apply plugin: "org.asciidoctor.jvm.convert"
3434

3535
repositories {
3636
mavenCentral()
@@ -88,29 +88,52 @@ java {
8888
withSourcesJar()
8989
}
9090

91-
tasks.withType(Groovydoc) {
92-
configure {
93-
docTitle = "Grace Database Migration Plugin ${version}"
94-
source = project.files('src/main/groovy')
95-
destinationDir = new File(buildDir, 'docs/api')
96-
classpath = configurations.documentation
97-
groovyClasspath = configurations.documentation
98-
}
99-
}
100-
101-
task docs(type:Copy, group: 'documentation') {
102-
dependsOn(groovydoc, asciidoctor)
103-
from "$buildDir/asciidoc"
104-
into "$buildDir/docs"
105-
}
106-
10791
jar {
10892
enabled = true
10993
archiveClassifier.set('plugin')
11094
includeEmptyDirs = false
11195
exclude 'testapp/*.class', 'databasemigration/*.class'
11296
}
11397

98+
def cleanTask = project.tasks.findByName('clean')
99+
if (cleanTask == null) {
100+
task clean(type: Delete) {
101+
delete(buildDir)
102+
}
103+
}
104+
else {
105+
cleanTask.doLast {
106+
ant.delete(dir: 'build/docs')
107+
}
108+
}
109+
110+
tasks.withType(Groovydoc) {
111+
group = 'Documentation'
112+
docTitle = "Grace Database Migration Plugin - ${project.version}"
113+
destinationDir = project.file('build/docs/manual/api')
114+
def files = []
115+
project.rootProject.subprojects
116+
.findAll { !it.name != 'docs' && !it.name.startsWith('examples') }
117+
.each { subproject ->
118+
if(subproject.file('src/main/groovy').exists()) {
119+
files += subproject.files('src/main/groovy')
120+
}
121+
if(subproject.file('src/main/java').exists()) {
122+
files += subproject.files('src/main/java')
123+
}
124+
}
125+
if (project.file('src/main/groovy').exists()) {
126+
files += project.files('src/main/groovy')
127+
}
128+
source = files
129+
classpath += configurations.documentation
130+
}
131+
132+
docs {
133+
dependsOn groovydoc
134+
sourceDir = project.file('src/docs')
135+
}
136+
114137
publishing {
115138
publications {
116139
maven(MavenPublication) {

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ projectVersion=6.3.0-SNAPSHOT
22
graceVersion=2023.3.0-RC2
33
gormVersion=2023.3.0-RC1
44
gormHibernateVersion=2023.3.0-RC1
5-
websiteUrl=https://github.com/graceframework/grace-database-migration
6-
issueTrackerUrl=https://github.com/graceframework/grace-database-migration/issues
7-
vcsUrl=https://github.com/graceframework/grace-database-migration
85
org.gradle.parallel=true
96
org.gradle.caching=true
107
org.gradle.daemon=true

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = "database-migration"
1+
rootProject.name = "grace-database-migration"
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
:includedir: _includes
2-
:integrationtestresources: ../../integration-test/resources
3-
4-
== Configuration
2+
:integrationtestresources: src/integration-test/resources
53

64
There are a few configuration options for the plugin. All configurations are prefixed with `grails.plugin.databasemigration`:
75

86
[options="header"]
97
|==================================
108
|Property |Default |Meaning
11-
|changelogLocation |`grails-app/migrations` |the folder containing the main changelog file (which can include one or more other files)
9+
|changelogLocation |`app/migrations` |the folder containing the main changelog file (which can include one or more other files)
1210
|changelogFileName |`changelog.groovy` |the name of the main changelog file
1311
|changelogProperties |none |a map of properties to use for property substitution in Groovy DSL changelogs
14-
|contexts |none |A comma-delimited list of http://www.liquibase.org/manual/contexts[context] names. If specified, only changesets tagged with one of the context names will be run
15-
|dbDocLocation |`target/dbdoc` |the directory where the output from the <<ref-documentation-scripts-dbm-db-doc,dbm-db-doc>> script is written
12+
|contexts |none |A comma-delimited list of https://docs.liquibase.com/concepts/changelogs/attributes/contexts.html[context] names. If specified, only changesets tagged with one of the context names will be run
13+
|dbDocLocation |`build/dbdoc` |the directory where the output from the link:../ref/Documentation%20Scripts/dbm-db-doc.html[dbm-db-doc] script is written
1614
|dbDocController.enabled |`true` in dev mode |whether the /dbdoc/ url is accessible at runtime
1715
|dropOnStart |`false` |if `true` then drops all tables before auto-running migrations (if updateOnStart is true)
1816
|updateOnStart |`false` |if `true` then changesets from the specified list of names will be run at startup
1917
|updateOnStartFileName |none |the file name (relative to `changelogLocation`) to run at startup if `updateOnStart` is `true`
2018
|updateOnStartDefaultSchema |none |the default schema to use when running auto-migrate on start
21-
|updateOnStartContexts |none |A comma-delimited list of http://www.liquibase.org/manual/contexts[context] names. If specified, only changesets tagged with one of the context names will be run
22-
|updateAllOnStart |false |if `true` then changesets from the specified list of names will be run at startup for all dataSources. Useful for Grails Multitenancy with Multiple Databases (same db schema)
19+
|updateOnStartContexts |none |A comma-delimited list of https://docs.liquibase.com/concepts/changelogs/attributes/contexts.html[context] names. If specified, only changesets tagged with one of the context names will be run
20+
|updateAllOnStart |false |if `true` then changesets from the specified list of names will be run at startup for all dataSources. Useful for Grace Multitenancy with Multiple Databases (same db schema)
2321
|autoMigrateScripts |['RunApp'] |the scripts when running auto-migrate. Useful to run auto-migrate during test phase with: ['RunApp', 'TestApp']
2422
|excludeObjects |none |A comma-delimited list of database object names to ignore while performing a dbm-gorm-diff or dbm-generate-gorm-changelog
2523
|includeObjects |none |A comma-delimited list of database object names to look for while performing a dbm-gorm-diff or dbm-generate-gorm-changelog
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
== DbDoc Controller
2-
3-
You can use the <<ref-documentation-scripts-dbm-db-doc,dbm-db-doc>> script to generate static HTML files to view changelog information, but another option is to use the `DbDocController` at runtime. By default this controller is mapped to `/appname/dbdoc/` but this can be customized with `UrlMappings` like any controller.
1+
You can use the link:../ref/Documentation%20Scripts/dbm-db-doc.html[dbm-db-doc] script to generate static HTML files to view changelog information, but another option is to use the `DbDocController` at runtime. By default this controller is mapped to `/appname/dbdoc/` but this can be customized with `UrlMappings` like any controller.
42

53
You probably don't want to expose this information to all of your application's users so by default the controller is only enabled in the development environment. But you can enable or disable it for any environment in `application.groovy` with the `dbDocController.enabled` config option. For example to enable for all environments (be sure to guard the URL with a security plugin in prod):
64

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
== General Usage
2-
31
After creating the initial changelog, the typical workflow will be along the lines of:
42

53
* make domain class changes that affect the schema
64
* add changes to the changelog for them
75
* backup your database in case something goes wrong
8-
* run `grails dbm-update` to update your development environment (or wherever you're applying the changes)
6+
* run `grace dbm-update` to update your development environment (or wherever you're applying the changes)
97
* check the updated domain class(es) and changelog(s) into source control
108
119
[WARNING]
@@ -14,7 +12,7 @@ After creating the initial changelog, the typical workflow will be along the lin
1412
2. Setting the dbCreate setting to "none" is recommended when executing the dbm migration commands. Otherwise you might run into troubles and the commands could not be executed.
1513
====
1614

17-
To create the changelog additions, you can either manually create the changes or with the <<ref-diff-scripts-dbm-gorm-diff,dbm-gorm-diff>> script (you can also use the <<ref-diff-scripts-dbm-diff,dbm-diff>> script but it's far less convenient and requires a 2nd temporary database).
15+
To create the changelog additions, you can either manually create the changes or with the link:../ref/Diff%20Scripts/dbm-gorm-diff.html[dbm-gorm-diff] script (you can also use the link:../ref/Diff%20Scripts/dbm-diff.html[dbm-diff] script but it's far less convenient and requires a 2nd temporary database).
1816

1917
You have a few options with `dbm-gorm-diff`:
2018

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
== Getting Started
2-
3-
*The first step is to add a dependency for the plugin in `build.gradle`:*
1+
The first step is to add a dependency for the plugin in `build.gradle`:
42

53
[source,groovy,subs="attributes"]
64
----
75
buildscript {
86
dependencies {
97
...
10-
classpath '{groupId}:{artifactId}:{version}'
8+
classpath 'org.graceframework.plugins:database-migration:{version}'
119
}
1210
}
1311
1412
dependencies {
1513
...
16-
implementation '{groupId}:{artifactId}:{version}'
14+
implementation 'org.graceframework.plugins:database-migration:{version}'
1715
}
1816
----
1917

@@ -23,19 +21,19 @@ It is also recommended to add a direct dependency to liquibase because Spring Bo
2321
----
2422
dependencies {
2523
...
26-
implementation 'org.liquibase:liquibase-core:{liquibaseVersion}'
24+
implementation 'org.liquibase:liquibase-core'
2725
}
2826
----
2927

30-
You should also tell Gradle about the migrations folder. If using Grails 4, make sure the configuration below is BEFORE the
28+
You should also tell Gradle about the migrations folder. If using Grace 4, make sure the configuration below is BEFORE the
3129
`dependencies` configuration, so that the `sourceSets` declaration takes effect.
3230

3331
[source,groovy,subs="attributes"]
3432
----
3533
sourceSets {
3634
main {
3735
resources {
38-
srcDir 'grails-app/migrations'
36+
srcDir 'db/migrations'
3937
}
4038
}
4139
}
@@ -47,61 +45,61 @@ Next you'll need to create an initial changelog. You can use Liquibase XML or th
4745

4846
Depending on the state of your database and code, you have two options; either create a changelog from the database or create it from your domain classes. The decision tends to be based on whether you prefer to design the database and adjust the domain classes to work with it, or to design your domain classes and use Hibernate to create the corresponding database structure.
4947

50-
To create a changelog from the database, use the <<ref-rollback-scripts-dbm-generate-changelog,dbm-generate-changelog>> script:
48+
To create a changelog from the database, use the link:../ref/Rollback%20Scripts/dbm-generate-changelog.html[dbm-generate-changelog] script:
5149
[source,groovy]
5250
----
53-
grails dbm-generate-changelog changelog.groovy
51+
grace dbm-generate-changelog changelog.groovy
5452
----
5553

5654
or
5755

5856
[source,groovy]
5957
----
60-
grails dbm-generate-changelog changelog.xml
58+
grace dbm-generate-changelog changelog.xml
6159
----
6260

63-
depending on whether you prefer the Groovy DSL or XML. The filename is relative to the changelog base folder, which defaults to `grails-app/migrations`.
61+
depending on whether you prefer the Groovy DSL or XML. The filename is relative to the changelog base folder, which defaults to `app/migrations`.
6462

6563
NOTE: If you use the XML format (or use a non-default Groovy filename), be sure to change the name of the file in `application.groovy` so `dbm-update` and other scripts find the file:
6664
[source,groovy]
6765
----
6866
grails.plugin.databasemigration.changelogFileName = 'changelog.xml'
6967
----
7068

71-
Since the database is already correct, run the <<ref-maintenance-scripts-dbm-changelog-sync,dbm-changelog-sync>> script to record that the changes have already been applied:
69+
Since the database is already correct, run the link:../ref/Maintenance%20Scripts/dbm-changelog-sync.html[dbm-changelog-sync] script to record that the changes have already been applied:
7270
[source,groovy]
7371
----
74-
grails dbm-changelog-sync
72+
grace dbm-changelog-sync
7573
----
7674

7775
Running this script is primarily a no-op except that it records the execution(s) in the Liquibase DATABASECHANGELOG table.
7876

79-
To create a changelog from your domain classes, use the <<ref-rollback-scripts-dbm-generate-gorm-changelog,dbm-generate-gorm-changelog>> script:
77+
To create a changelog from your domain classes, use the link:../ref/Rollback%20Scripts/dbm-generate-gorm-changelog.html[dbm-generate-gorm-changelog] script:
8078

8179
[source,groovy]
8280
----
83-
grails dbm-generate-gorm-changelog changelog.groovy
81+
grace dbm-generate-gorm-changelog changelog.groovy
8482
----
8583

8684
or
8785

8886
[source,groovy]
8987
----
90-
grails dbm-generate-gorm-changelog changelog.xml
88+
grace dbm-generate-gorm-changelog changelog.xml
9189
----
9290

93-
If you haven't created the database yet, run the <<ref-update-scripts-dbm-update,dbm-update>> script to create the corresponding tables:
91+
If you haven't created the database yet, run the link:../ref/Update%20Scripts/dbm-update.html[dbm-update] script to create the corresponding tables:
9492

9593
[source,groovy]
9694
----
97-
grails dbm-update
95+
grace dbm-update
9896
----
9997

100-
or the <<ref-maintenance-scripts-dbm-changelog-sync,dbm-changelog-sync>> script if the database is already in sync with your code:
98+
or the link:../ref/Maintenance%20Scripts/dbm-changelog-sync.html[dbm-changelog-sync] script if the database is already in sync with your code:
10199

102100
[source,groovy]
103101
----
104-
grails dbm-changelog-sync
102+
grace dbm-changelog-sync
105103
----
106104

107105
*Source control*
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
== GORM Support
2-
31
The plugin's support for GORM is one feature that differentiates it from using Liquibase directly. Typically, when using Liquibase you make changes to a database yourself, and then create changesets manually, or use a diff script to compare your updated database to one that hasn't been updated yet. This is a decent amount of work and is rather error-prone. It's easy to forget some changes that aren't required but help performance, for example creating an index on a foreign key when using MySQL.
42

53
*create-drop, create, and update*
@@ -22,4 +20,4 @@ So a good workflow would be:
2220
2321
*dbm-generate-gorm-changelog*
2422

25-
The <<ref-rollback-scripts-dbm-generate-gorm-changelog,dbm-generate-gorm-changelog>> script is useful for when you want to switch from `create-drop` mode to doing proper migrations. It's not very useful if you already have a database that's in sync with your code, since you can just use the <<ref-rollback-scripts-dbm-generate-changelog,dbm-generate-changelog>> script that creates a changelog from your database.
23+
The link:../ref/Rollback%20Scripts/dbm-generate-gorm-changelog.html[dbm-generate-gorm-changelog] script is useful for when you want to switch from `create-drop` mode to doing proper migrations. It's not very useful if you already have a database that's in sync with your code, since you can just use the link:../ref/Rollback%20Scripts/dbm-generate-changelog.html[dbm-generate-changelog] script that creates a changelog from your database.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
== Groovy Changes
2-
3-
In addition to the built-in Liquibase changes (see http://www.liquibase.org/manual/home[the documentation] for what's available) you can also make database changes using Groovy code (as long as you're using the Groovy DSL file format). These changes use the `grailsChange` tag name and are contained in a `changeSet` tag like standard built-in tags.
1+
In addition to the built-in https://docs.liquibase.com/concepts/changelogs/home.html[Liquibase changes] you can also make database changes using Groovy code (as long as you're using the Groovy DSL file format). These changes use the `grailsChange` tag name and are contained in a `changeSet` tag like standard built-in tags.
42

53
There are four supported inner tags and two callable methods (to override the default confirmation message and checksum value).
64

src/docs/asciidoc/groovyPreconditions.adoc renamed to src/docs/guide/groovyPreconditions.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
== Groovy Preconditions
2-
3-
In addition to the built-in Liquibase preconditions (see http://www.liquibase.org/manual/preconditions[the documentation] for what's available) you can also specify preconditions using Groovy code (as long as you're using the Groovy DSL file format). These changes use the `grailsPrecondition` tag name and are contained in the `databaseChangeLog` tag or in a `changeSet` tag like standard built-in tags.
1+
In addition to the built-in https://docs.liquibase.com/concepts/changelogs/preconditions[Liquibase preconditions] you can also specify preconditions using Groovy code (as long as you're using the Groovy DSL file format). These changes use the `grailsPrecondition` tag name and are contained in the `databaseChangeLog` tag or in a `changeSet` tag like standard built-in tags.
42

53
=== General format
64

0 commit comments

Comments
 (0)