diff --git a/ecocode-rules-specifications/pom.xml b/ecocode-rules-specifications/pom.xml
index 6dee12f0d..d1857eb63 100644
--- a/ecocode-rules-specifications/pom.xml
+++ b/ecocode-rules-specifications/pom.xml
@@ -65,6 +65,11 @@
- syntax highlighting (see code blocks on ASCIIDOC rules)
- inclusions (see: php/EC74.asciidoc)
- table data generation from CSV (see: php/EC34.asciidoc)
+
+ NB: Current version has a bug which display following false positive warning :
+ [WARNING] Duplicated destination found: overwriting file ...
+
+ This issue is fixed in 3.x release of asciidoctor-maven-plugin
-->
org.asciidoctor
asciidoctor-maven-plugin
@@ -78,12 +83,13 @@
${project.basedir}/src/main/rules
- ${project.build.directory}/rules
+ ${project.build.directory}/rules-html
coderay
style
true
+ true
false
true
@@ -97,57 +103,24 @@
- org.apache.maven.plugins
- maven-antrun-plugin
- 3.1.0
+ org.codehaus.gmaven
+ groovy-maven-plugin
+ 2.1.1
- process-resources
+ generate-resources
- run
+ execute
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ ${project.build.directory}/rules-html
+ ${project.build.outputDirectory}/io/ecocode/rules
+
diff --git a/ecocode-rules-specifications/src/main/script/prepare-resources.groovy b/ecocode-rules-specifications/src/main/script/prepare-resources.groovy
new file mode 100644
index 000000000..15eb9bee7
--- /dev/null
+++ b/ecocode-rules-specifications/src/main/script/prepare-resources.groovy
@@ -0,0 +1,33 @@
+#!/usr/bin/env groovy
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.StandardCopyOption
+
+Path projectBasedir = Path.of(project.basedir.absolutePath)
+
+Path sourceDir = Path.of(Objects.requireNonNull(properties.sourceDir, "property must be set: sourceDir"))
+Path targetDir = Path.of(Objects.requireNonNull(properties.targetDir, "property must be set: targetDir"))
+
+def copyFile(Path basedirPath, Path source, Path target) {
+ log.debug("Copy: {} -> {}", basedirPath.relativize(source), basedirPath.relativize(target))
+ Files.createDirectories(target.parent)
+ Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING)
+}
+
+sourceDir.traverse(type: groovy.io.FileType.FILES, nameFilter: ~/.*\.html$/) { Path htmlPath ->
+ def language = htmlPath.parent.fileName.toString()
+ def languageDir = targetDir.resolve(language)
+
+ def ruleDir = htmlPath.parent.parent
+ def ruleKey = ruleDir.fileName.toString()
+
+ def metadataFileSourcePath = ruleDir.resolve(ruleKey + ".json")
+
+ def htmlTargetPath = languageDir.resolve(htmlPath.fileName)
+ def metadataFileTargetPath = languageDir.resolve(metadataFileSourcePath.fileName)
+
+ if(Files.exists(metadataFileSourcePath)) {
+ copyFile(projectBasedir, htmlPath, htmlTargetPath)
+ copyFile(projectBasedir, metadataFileSourcePath, metadataFileTargetPath)
+ }
+}