Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject maven properties in asciidoctor mojo (#459)
* inject Maven properties as attributes in Mojo same as site module * updates README * adds unit test * updates CHANGELOG
- Loading branch information
1 parent
30379a5
commit b7f4c34
Showing
12 changed files
with
171 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=clean generate-resources |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<name>Converts Asciidoctor Article to Html</name> | ||
<description>Processes attributes from different sections in the Maven pom</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.property.attribute>project property configuration</project.property.attribute> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>asciidoctor-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<attributes> | ||
<plugin-configuration-attribute>plugin configuration</plugin-configuration-attribute> | ||
</attributes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>asciidoc-to-html</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>process-asciidoc</goal> | ||
</goals> | ||
<configuration> | ||
<attributes> | ||
<execution-attribute>execution configuration</execution-attribute> | ||
</attributes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
15 changes: 15 additions & 0 deletions
15
src/it/inject-attributes-from-maven-pom/src/docs/asciidoc/attributes-example.adoc
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Document Title | ||
============== | ||
Doc Writer <thedoc@asciidoctor.org> | ||
:execution.attribute: cosa | ||
:idprefix: id_ | ||
|
||
Preamble paragraph. | ||
|
||
NOTE: This is test, only a test. | ||
|
||
== Section A | ||
|
||
* This attribute is set in the plugin configuration: {plugin-configuration-attribute} | ||
* This attribute is set in the execution configuration: {execution-attribute} | ||
* This attribute is set in the project's properties: {project-property-attribute} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
final File outputDir = new File(basedir, "target/generated-docs"); | ||
final File expectedFile = new File(outputDir, 'attributes-example.html') | ||
|
||
if (!expectedFile.exists()) { | ||
throw new Exception("Missing file " + expectedFile) | ||
} | ||
|
||
expectedFile.text.with { outputContent -> | ||
assertContains(outputContent, 'This attribute is set in the plugin configuration: plugin configuration') | ||
assertContains(outputContent, 'This attribute is set in the execution configuration: execution configuration') | ||
assertContains(outputContent, 'This attribute is set in the project’s properties: project property configuration') | ||
} | ||
|
||
void assertContains(String text, String expectedValueToContain) { | ||
if (!text.contains(expectedValueToContain)) | ||
throw new Exception("Expected value '$expectedValueToContain' not found") | ||
} | ||
|
||
return true |
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
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
15 changes: 15 additions & 0 deletions
15
src/test/resources/src/asciidoctor/attributes-example.adoc
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Document Title | ||
============== | ||
Doc Writer <thedoc@asciidoctor.org> | ||
:execution.attribute: cosa | ||
:idprefix: id_ | ||
|
||
Preamble paragraph. | ||
|
||
NOTE: This is test, only a test. | ||
|
||
== Section A | ||
|
||
* This attribute is set in the plugin configuration: {plugin-configuration-attribute} | ||
* This attribute is set in the execution configuration: {execution-attribute} | ||
* This attribute is set in the project's properties: {project-property-attribute} |