Usage

The SchemaSpy plugin generates SchemaSpy reports describing a relational database. It will look for an appropriate JDBC driver on the classpath (based on the database type), and by default will generate a report in the 'target/site/schemaspy' directory.

To include a SchemaSpy report in your project site, set the following in the <reporting> section of your pom:

<project>
  ...
  <reporting>
    <plugins>
        <plugin>
            <groupId>nl.geodienstencentrum.maven</groupId>
            <artifactId>schemaspy-maven-plugin</artifactId>
            <version>${schemaspy.plugin.version}</version>
            <configuration>
                <databaseType>mysql</databaseType>
                <database>testdb</database>
                <host>localhost</host>
                <user>scott</user>
                <password>tiger</password>
            </configuration>
        </plugin> 
    </plugins>
  </reporting>
</project>

Configuration

The SchemaSpy plugin accepts all of the standard SchemaSpy parameters.

Most databases with JDBC drivers available in the standard Maven repository should work out-of-the-box. Currently, these are: * Derby * MySQL * HSQLDB * PostgreSQL * MS SQLServer using the Microsoft JDBC driver (mssql-jdbc) Others, such as Firebird, don't have drivers in the repositories.

In this case, add a dependency for the driver you need to the plugin configuration in the <build> section of your pom.xml:

        <build>
          <plugins>
                        <plugin>
                                <groupId>nl.geodienstencentrum.maven</groupId>
                                <artifactId>schemaspy-maven-plugin</artifactId>
                                <version>${schemaspy.plugin.version}</version>
                                <dependencies>
                                        <dependency>
                                                <groupId>com.oracle</groupId>
                                                <artifactId>ojdbc</artifactId>
                                                <version>${oracle.jdbc.version}</version>
                                        </dependency>
                                </dependencies>
                        </plugin>
                    ...
                  </plugins>
                </build>

Alternatively, if this doesn't work, you can to specify the driver manually using the <pathToDrivers> parameter:

<project>
  ...
  <reporting>
    <plugins>
        <plugin>
            <groupId>nl.geodienstencentrum.maven</groupId>
            <artifactId>schemaspy-maven-plugin</artifactId>
            <version>1.0</version>
            <configuration>
              <databaseType>mysql</databaseType>
              <database>testdb</database>
              <host>localhost</host>
              <user>scott</user>
              <password>tiger</password>
              <outputDirectory>target/site/schemaSpy-full</outputDirectory>
              <pathToDrivers>${com.oracle:ojdbc:jar}</pathToDrivers>     
              <commentsInitiallyDisplayed>true</commentsInitiallyDisplayed>
              <noTableComments>true</noTableComments>
              <noImplied>true</noImplied>
              <allowHtmlInComments>true</allowHtmlInComments>
              <cssStylesheet>testSchemaSpy.css</cssStylesheet>
              <schemaDescription>Maven Plugin SchemaSpy Test</schemaDescription>
            </configuration>
        </plugin> 
    </plugins>
  </reporting>
</project>

For MSSQL Server, the plugin will use the open source Microsoft driver mssql-jdbc.

Rather than defining the database and host names and letting SchemaSpy build the URL, you can alternatively specify the complete JDBC URL using this parameter. If this parameter is defined, it will override the host address (which, as a result, is not needed). Note that you still need to specify the database type, since SchemaSpy uses its own database properties file for extra information about each database.

<project>
  ...
  <reporting>
    <plugins>
        <plugin>
            <groupId>nl.geodienstencentrum.maven</groupId>
            <artifactId>schemaspy-maven-plugin</artifactId>
            <version>1.0</version>
            <configuration>
              <databaseType>mysql</databaseType>
              <jdbcUrl>jdbc:mysql://localhost/testdb</jdbcUrl>
              <user>scott</user>
              <password>tiger</password>
            </configuration>
        </plugin> 
    </plugins>
  </reporting>
</project>

As a rule, it is not a good idea to keep usernames and passwords in the source code repository. An alternative is to define the user and password values in your setting.xml file, as shown here:

<settings>
  <localRepository>C:/maven/repository</localRepository>
  <profiles>  
   <profile>
      <id>development</id>
      <activation>
         <activeByDefault>true</activeByDefault>
     </activation>
     <properties>
        <schemaspy.username>john</schemaspy.username>
        <schemaspy.password></schemaspy.password>
     </properties>
   </profile>
  </profiles>  
</settings>

With this setup, you can use the $schemaspy.username and $schemaspy.password values directly in your SchemaSpy plugin configuration:

<project>
  ...
  <reporting>
    <plugins>
        <plugin>
            <groupId>nl.geodienstencentrum.maven</groupId>
            <artifactId>schemaspy-maven-plugin</artifactId>
            <version>${schemaspy.plugin.version}</version>
            <configuration>
              <database>testdb</database>     
              <jdbcUrl>jdbc:mysql://localhost/testdb</jdbcUrl>
              <user>${schemaspy.username}</user>
              <password>${schemaspy.password}</password>
            </configuration>
        </plugin> 
    </plugins>
  </reporting>
</project>