[doc] move RuleDocGenerator into pmd-doc

It'll be executed during package phase.
This commit is contained in:
Andreas Dangel
2017-08-10 19:18:35 +02:00
parent 8bdb0a5d22
commit d537b2acbe
3 changed files with 31 additions and 8 deletions

View File

@ -15,6 +15,30 @@
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<mainClass>net.sourceforge.pmd.docs.GenerateRuleDocsCmd</mainClass>
<arguments>
<argument>${project.basedir}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>

View File

@ -5,15 +5,16 @@
package net.sourceforge.pmd.docs;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import org.junit.Test;
public class GenerateRuleDocsCmd {
public class GenerateRuleDocsTest {
@Test
public void generateDocs() {
public static void main(String[] args) {
long start = System.currentTimeMillis();
RuleDocGenerator generator = new RuleDocGenerator();
generator.generate(FileSystems.getDefault().getPath("..").toAbsolutePath().normalize());
Path output = FileSystems.getDefault().getPath(args[0]).resolve("..").toAbsolutePath().normalize();
System.out.println("Generating docs into " + output);
generator.generate(output);
System.out.println("Generated docs in " + (System.currentTimeMillis() - start) + " ms");
}
}

View File

@ -6,7 +6,6 @@ package net.sourceforge.pmd.docs;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
@ -287,8 +286,7 @@ public class RuleDocGenerator {
* @return
* @throws IOException
*/
private static String getRuleSetSourceFilepath(RuleSet ruleset) throws IOException {
Path root = FileSystems.getDefault().getPath("..").toAbsolutePath().normalize();
private String getRuleSetSourceFilepath(RuleSet ruleset) throws IOException {
final String rulesetFilename = FilenameUtils.normalize(StringUtils.chomp(ruleset.getFileName()));
final List<Path> foundPathResult = new LinkedList<>();