-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First step : making sure the plugin definition is common, yet easily modifiable * Use modern version of maven plugin for all artifacts * Don't forget to validate adaptation of architecture-documentation 🚨 * Find a smart way to handle project issues url
- Loading branch information
Showing
15 changed files
with
532 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
aadarchi-maven-plugin/src/it/2_generate_html_docs/verify.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
assert new File(basedir, "target/docs/html/index.html").exists() | ||
assert new File(basedir, "target/asciidoc/docs/html/index.html").exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
assert new File(basedir, "target/docs/pdf/index.pdf").exists() | ||
assert new File(basedir, "target/asciidoc/docs/pdf/index.pdf").exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
aadarchi-maven-plugin/src/it/4_generate_html_slides/verify.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
assert new File(basedir, "target/asciidoc/slides/test.html").exists() | ||
assert new File(basedir, "target/asciidoc/slides/html/test.html").exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 50 additions & 84 deletions
134
...n/java/org/ndx/agile/architecture/documentation/system/maven/plugin/GenerateHtmlDocs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,62 @@ | ||
package org.ndx.agile.architecture.documentation.system.maven.plugin; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.BuildPluginManager; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.Component; | ||
import static org.twdata.maven.mojoexecutor.MojoExecutor.element; | ||
import static org.twdata.maven.mojoexecutor.MojoExecutor.name; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.apache.maven.model.Dependency; | ||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
import static org.twdata.maven.mojoexecutor.MojoExecutor.*; | ||
|
||
import org.ndx.agile.architecture.documentation.system.maven.plugin.asciidoctor.AbstractAsciidoctorCallingMojo; | ||
import org.twdata.maven.mojoexecutor.MojoExecutor; | ||
import org.twdata.maven.mojoexecutor.MojoExecutor.Element; | ||
|
||
/** | ||
* Generates html version of the documents stored in source folder. | ||
* | ||
* This mojo is a specific invocation of asciidoctor-maven-plugin with a "correct" set | ||
* of parameters for our use case | ||
* | ||
* @author nicolas-delsaux | ||
* | ||
*/ | ||
@Mojo(name = "generate-html-docs", defaultPhase = LifecyclePhase.PREPARE_PACKAGE) | ||
public class GenerateHtmlDocs extends AbstractMojo { | ||
@Component | ||
private MavenProject mavenProject; | ||
|
||
@Component | ||
private MavenSession mavenSession; | ||
|
||
@Component | ||
private BuildPluginManager pluginManager; | ||
|
||
@Parameter(name = "asciidoctor-maven-plugin-version", defaultValue = "2.1.0") | ||
private String asciidoctorMavenPluginVersion; | ||
|
||
@Parameter(name = "asciidoctorj-pdf-version", defaultValue = "1.5.4") | ||
private String asciidoctorjPdfVersion; | ||
|
||
@Parameter(name = "jruby-version", defaultValue = "9.2.9.0") | ||
private String jrubyVersion; | ||
|
||
@Parameter(name = "asciidoctorj-version", defaultValue = "2.4.3") | ||
private String asciidoctorjVersion; | ||
|
||
@Parameter(name = "kroki-server-url", defaultValue = "${kroki.server.url}") | ||
private String krokiServerUrl; | ||
|
||
public class GenerateHtmlDocs extends AbstractAsciidoctorCallingMojo { | ||
/** | ||
* Input folder where asciidoc files are stored. | ||
*/ | ||
@Parameter(name="html-docs-source-dir", defaultValue="${project.basedir}/src/docs/asciidoc", property = "asciidoc.source.docs.directory") | ||
private File htmlDocsSourceDir; | ||
/** | ||
* Output folder where html docs are produced | ||
*/ | ||
@Parameter(name="html-docs-output-dir", defaultValue="${project.build.directory}/asciidoc/docs/html", property = "asciidoc.target.html.docs.directory") | ||
private File htmlDocsOutputDir; | ||
|
||
@Override | ||
public void execute() throws MojoExecutionException, MojoFailureException { | ||
executeMojo( | ||
plugin( | ||
groupId("org.asciidoctor"), | ||
artifactId("asciidoctor-maven-plugin"), | ||
version(asciidoctorMavenPluginVersion), | ||
dependencies( | ||
dependency("org.asciidoctor", "asciidoctorj-pdf", asciidoctorjPdfVersion), | ||
dependency("org.jruby", "jruby-complete", jrubyVersion), | ||
dependency("org.asciidoctor", "asciidoctorj", asciidoctorjVersion) | ||
) | ||
), | ||
goal("process-asciidoc"), | ||
configuration( | ||
// TODO conditionalize that invocation : add all gems dependencies here | ||
element(name("requires"), | ||
element(name("require"), "asciidoctor-kroki")), | ||
element(name("gemPath"), "${project.build.directory}/gems"), | ||
element(name("attributes"), | ||
element(name("allow-uri-read")), // allow to include distant content in the created document | ||
element(name("kroki-server-url"), krokiServerUrl), | ||
protected List<Dependency> dependencies() { | ||
return MojoExecutor.dependencies( | ||
dependencyJRuby(), | ||
dependencyAsciidoctor() | ||
); | ||
} | ||
|
||
element(name("structurizrdir"), "${agile.architecture.output.diagrams}"), | ||
element(name("imagesdir"), "./images"), | ||
element(name("toc"), "left"), // put the table of content on the left side of the window | ||
element(name("icons"), "font"), // allow to use icons from "fonticones" | ||
element(name("sectanchors"), "true"), // sections behave like anchors/links to move around the document | ||
element(name("idseparator"), "-"), // put a separator between identifiers pieces | ||
element(name("hideBugReport"), "${asciidoc.documents.hide.bug.report}"), // add link to allow users to report some bugs | ||
@Override | ||
protected String getSourceDirectory() { | ||
return htmlDocsSourceDir.getAbsolutePath(); | ||
} | ||
|
||
element(name("sectnums"), "true"), // display section number in the summary | ||
element(name("revnumber"), "${project.version}"), // add project version in the footer | ||
element(name("revdate"), "${maven.build.timestamp}"), // add the date in the footer | ||
@Override | ||
protected String getOutputDirectory() { | ||
return htmlDocsOutputDir.getAbsolutePath(); | ||
} | ||
|
||
element(name("project-group-id"), "${project.groupId}"), // catch the groupId defined in the pom.xml file | ||
element(name("project-artifact-id"), "${project.artifactId}"), // catch the artifactId defined in the pom.xml file | ||
element(name("project-name"), "${project.name}"), // catch the project name defined in the pom.xml file | ||
element(name("project-version"), "${project.version}"), // catch the project version defined in the pom.xml file | ||
element(name("project-build-timestamp"), "${maven.build.timestamp}"), // catch the timestamp defined when maven build | ||
element(name("project-pom-path"), "../../../pom.xml"), // catch pom.xml file path | ||
element(name("project-issues-on-github"), "${issues.url}"), // catch the issue url defined in the pom.xml file | ||
element(name("organization"), "${project.organization.name}"), // catch the organization name defined in the pom.xml file | ||
element(name("enhancements-dir"), "${agile.architecture.output.enhancements}") // catch the path to the enhancements directory defined in the pom.xml file | ||
), | ||
element(name("outputDirectory"), "${project.build.directory}/docs/html") // define the path where the html files will get created | ||
), | ||
executionEnvironment( | ||
mavenProject, | ||
mavenSession, | ||
pluginManager | ||
) | ||
); | ||
@Override | ||
protected Element configurationBackend() { | ||
return element(name("backend"), "html5"); | ||
} | ||
|
||
} |
Oops, something went wrong.