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.
Mark BuildMojo as threadSafe (asciidoctor#364)
* Mark BuildMojo as threadSafe This annotation will remove a maven build warning. Resolves: asciidoctor#326 * Add integration test for thread safe lable All three modules produces the same result. If the content is mixed during the parallel execution the results will be different and the test fails. * Make the test java 7 compatible * Don't generate header and footer Set 'headerFooter' to 'false'. The generated html files must not contain timestamps.
- Loading branch information
1 parent
869aa78
commit 48d1142
Showing
10 changed files
with
319 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<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-1</artifactId> | ||
|
||
<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> | ||
<headerFooter>false</headerFooter> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
40 changes: 40 additions & 0 deletions
40
src/it/thread-safe/asciidoctor-project-1/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,40 @@ | ||
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 | ||
|
||
== Section C | ||
|
||
[source,java] | ||
---- | ||
public class HelloWorld { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, World!!"); | ||
} | ||
} | ||
---- |
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,46 @@ | ||
<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-2</artifactId> | ||
|
||
<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> | ||
<headerFooter>false</headerFooter> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
40 changes: 40 additions & 0 deletions
40
src/it/thread-safe/asciidoctor-project-2/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,40 @@ | ||
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 | ||
|
||
== Section C | ||
|
||
[source,java] | ||
---- | ||
public class HelloWorld { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, World!!"); | ||
} | ||
} | ||
---- |
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,46 @@ | ||
<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-3</artifactId> | ||
|
||
<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> | ||
<headerFooter>false</headerFooter> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
40 changes: 40 additions & 0 deletions
40
src/it/thread-safe/asciidoctor-project-3/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,40 @@ | ||
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 | ||
|
||
== Section C | ||
|
||
[source,java] | ||
---- | ||
public class HelloWorld { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, World!!"); | ||
} | ||
} | ||
---- |
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=-T3 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,22 @@ | ||
<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 that the plugin is thread safe by checking that the result content are not mixed.</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<modules> | ||
<module>asciidoctor-project-1</module> | ||
<module>asciidoctor-project-2</module> | ||
<module>asciidoctor-project-3</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,37 @@ | ||
import java.nio.charset.Charset | ||
import java.nio.file.Files | ||
|
||
String fileTemplate = "asciidoctor-project-%s/target/docs/sample.html" | ||
|
||
List<String> contents = new ArrayList<>() | ||
List<String> files = new ArrayList<>() | ||
for (int i = 1; i <= 3; i++) { | ||
File file = new File(basedir, String.format(fileTemplate, i)) | ||
println("Checking for existence of " + file) | ||
if (!file.isFile()) { | ||
throw new Exception("Missing file " + file) | ||
} | ||
|
||
StringBuilder contentOfFile = new StringBuilder() | ||
for (String line : Files.readAllLines(file.toPath(), Charset.forName("UTF-8"))) { | ||
contentOfFile.append(line) | ||
} | ||
contents.add(contentOfFile.toString()) | ||
files.add(String.format(fileTemplate, i)) | ||
|
||
} | ||
|
||
|
||
if(!contents.get(0).equals(contents.get(1))) { | ||
throw new Exception(String.format("The content of two files are different.\n\n%s: %s\n%s: %s", files.get(0), contents.get(0), files.get(1), contents.get(1) )) | ||
} | ||
|
||
if(!contents.get(1).equals(contents.get(2))) { | ||
throw new Exception(String.format("The content of two files are different.\n\n%s: %s\n%s: %s", files.get(1), contents.get(1), files.get(2), contents.get(2) )) | ||
} | ||
|
||
if(!contents.get(2).equals(contents.get(0))) { | ||
throw new Exception(String.format("The content of two files are different.\n\n%s: %s\n%s: %s", files.get(2), contents.get(2), files.get(0), contents.get(0) )) | ||
} | ||
|
||
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