forked from asciidoctor/asciidoctor-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new feature to fail based on different conditions (asciidoctor#363
- Loading branch information
1 parent
48d1142
commit f38a472
Showing
25 changed files
with
814 additions
and
68 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,52 @@ | ||
<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>asciidoctor-project</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<parent> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>test-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<description>Runs asciidoctor-maven-plugin:process-asciidoc</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>asciidoctor-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>html</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>process-asciidoc</goal> | ||
</goals> | ||
<configuration> | ||
<sourceDirectory>src/main/doc</sourceDirectory> | ||
<outputDirectory>target/docs</outputDirectory> | ||
<backend>html</backend> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>log-handler</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
29 changes: 29 additions & 0 deletions
29
src/it/spi-registered-log/asciidoctor-project/src/main/doc/sample.asciidoc
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,29 @@ | ||
Document Title | ||
============== | ||
Doc Writer <thedoc@asciidoctor.org> | ||
:idprefix: id_ | ||
|
||
Preamble paragraph. | ||
|
||
NOTE: This is test, only a test. | ||
|
||
== Section A | ||
|
||
*Section A* paragraph. | ||
|
||
=== Section A Subsection | ||
|
||
*Section A* 'subsection' paragraph. | ||
|
||
== Section B | ||
|
||
*Section B* paragraph. | ||
|
||
.Section B list | ||
* Item 1 | ||
* Item 2 | ||
* Item 3 | ||
|
||
== Missing include | ||
|
||
include::something.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 @@ | ||
invoker.goals=clean compile |
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,52 @@ | ||
<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>log-handler</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<parent> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>test-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<description>Implements a custom AsciidoctorJ LogHandler</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.java.version>1.7</project.java.version> | ||
<maven.compiler.plugin.version>3.7.0</maven.compiler.plugin.version> | ||
<asciidoctorj.version>1.5.7</asciidoctorj.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven.compiler.plugin.version}</version> | ||
<configuration> | ||
<source>${project.java.version}</source> | ||
<target>${project.java.version}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>asciidoctorj</artifactId> | ||
<version>${asciidoctorj.version}</version> | ||
</dependency> | ||
<!-- Include to use MojoExecutionException, MojoFailureException and cause Build failures integrated with maven --> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>3.0.5</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
53 changes: 53 additions & 0 deletions
53
...tered-log/log-handler/src/main/java/org/asciidoctor/maven/test/TestLogHandlerService.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.asciidoctor.maven.test; | ||
|
||
import org.asciidoctor.log.LogHandler; | ||
import org.asciidoctor.log.LogRecord; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class TestLogHandlerService implements LogHandler { | ||
|
||
public static final String CUSTOM_LOG = "custom_log.log"; | ||
|
||
final FileOutputStream logFile; | ||
|
||
private static List<LogRecord> logRecords = new ArrayList<>(); | ||
|
||
public static List<LogRecord> getLogRecords() { | ||
return logRecords; | ||
} | ||
|
||
public static void clear() { | ||
logRecords.clear(); | ||
} | ||
|
||
public TestLogHandlerService() { | ||
try { | ||
logFile = new FileOutputStream(new File(CUSTOM_LOG)); | ||
} catch (FileNotFoundException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void log(LogRecord logRecord) { | ||
writeLine("Logging from TestLogHandlerService: " + logRecord.getMessage()); | ||
logRecords.add(logRecord); | ||
} | ||
|
||
private void writeLine(String message) { | ||
try { | ||
logFile.write(message.getBytes()); | ||
logFile.flush(); | ||
logFile.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...ler/src/main/resources/META-INF/services/_org.asciidoctor.extension.spi.ExtensionRegistry
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 @@ | ||
org.asciidoctor.maven.test.processors.AutoregisteredProcessor |
1 change: 1 addition & 0 deletions
1
...tered-log/log-handler/src/main/resources/META-INF/services/org.asciidoctor.log.LogHandler
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 @@ | ||
org.asciidoctor.maven.test.TestLogHandlerService |
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,21 @@ | ||
<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-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<description>Tests SPI registration of an AsciidoctorJ LogHandler</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<modules> | ||
<module>log-handler</module> | ||
<module>asciidoctor-project</module> | ||
</modules> | ||
|
||
</project> |
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,9 @@ | ||
final def file = new File(basedir, "custom_log.log") | ||
|
||
if (!file.exists()) | ||
throw new Exception("Log file not initialized") | ||
|
||
if (!file.text.contains("Logging from TestLogHandlerService: include file not found:")) | ||
throw new Exception("Expected LogHandler message not found in log file") | ||
|
||
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
Oops, something went wrong.