-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting included sources to run full refresh on change
- Loading branch information
1 parent
37c545c
commit 788e2f6
Showing
6 changed files
with
124 additions
and
19 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
4 changes: 4 additions & 0 deletions
4
docs/modules/plugin/partials/auto-refresh-mojo-parameters.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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
interval:: time in milliseconds between checks of the filesystem. | ||
Defaults to `2000` | ||
|
||
refreshOn:: regular expression describing additional sources that force a full refresh. | ||
Useful when working with included/partial sources that aren't converted individually. | ||
Defaults to `empty` |
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
35 changes: 35 additions & 0 deletions
35
...ain/java/org/asciidoctor/maven/refresh/AdditionalSourceFileAlterationListenerAdaptor.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,35 @@ | ||
package org.asciidoctor.maven.refresh; | ||
|
||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.logging.Log; | ||
import org.asciidoctor.maven.AsciidoctorRefreshMojo; | ||
import org.asciidoctor.maven.process.ResourcesProcessor; | ||
|
||
import java.io.File; | ||
import java.util.Collections; | ||
|
||
public class AdditionalSourceFileAlterationListenerAdaptor extends AbstractFileAlterationListenerAdaptor { | ||
|
||
private static final ResourcesProcessor EMPTY_RESOURCES_PROCESSOR = (sourcesDir, outputDir, encoding, configuration) -> { | ||
}; | ||
|
||
|
||
public AdditionalSourceFileAlterationListenerAdaptor(AsciidoctorRefreshMojo mojo, Runnable postAction, Log log) { | ||
super(mojo, postAction, log); | ||
} | ||
|
||
@Override | ||
synchronized void processFile(File file, String actionName) { | ||
getLog().info(String.format("Additional source file %s %s", file.getAbsolutePath(), actionName)); | ||
getLog().info("Full refresh"); | ||
long timeInMillis = TimeCounter.timed(() -> { | ||
try { | ||
getMojo().processAllSources(EMPTY_RESOURCES_PROCESSOR); | ||
} catch (MojoExecutionException e) { | ||
getLog().error(e); | ||
} | ||
}); | ||
getLog().info("Converted document(s) in " + timeInMillis + "ms"); | ||
} | ||
|
||
} |
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