From d537b2acbe35de0168d854819b53146060b7029d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 10 Aug 2017 19:18:35 +0200 Subject: [PATCH] [doc] move RuleDocGenerator into pmd-doc It'll be executed during package phase. --- pmd-doc/pom.xml | 24 +++++++++++++++++++ .../pmd/docs/GenerateRuleDocsCmd.java | 11 +++++---- .../pmd/docs/RuleDocGenerator.java | 4 +--- 3 files changed, 31 insertions(+), 8 deletions(-) rename pmd-dist/src/test/java/net/sourceforge/pmd/docs/GenerateRuleDocsTest.java => pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java (54%) rename {pmd-dist/src/test => pmd-doc/src/main}/java/net/sourceforge/pmd/docs/RuleDocGenerator.java (98%) diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index fbd856c710..bbf0aa0ac4 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -15,6 +15,30 @@ 1.8 + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + java + + package + + + + net.sourceforge.pmd.docs.GenerateRuleDocsCmd + + ${project.basedir} + + + + + + net.sourceforge.pmd diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/docs/GenerateRuleDocsTest.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java similarity index 54% rename from pmd-dist/src/test/java/net/sourceforge/pmd/docs/GenerateRuleDocsTest.java rename to pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java index 11546defa0..e4357bbc14 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/docs/GenerateRuleDocsTest.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java @@ -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"); } } diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java similarity index 98% rename from pmd-dist/src/test/java/net/sourceforge/pmd/docs/RuleDocGenerator.java rename to pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 562d2e43d8..d999dd5d10 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -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 foundPathResult = new LinkedList<>();