Repository: camel Updated Branches: refs/heads/master d2c2b2436 -> c8b48821f
CAMEL-9842: Enrich camel-spring XSD with documentation for the non EIP nodes which was not documented before. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c8b48821 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c8b48821 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c8b48821 Branch: refs/heads/master Commit: c8b48821f4c492aa68e9b3e902b35d6bcd8cfad3 Parents: d2c2b24 Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Aug 11 12:05:41 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Aug 11 12:05:41 2016 +0200 ---------------------------------------------------------------------- .../maven/EipDocumentationEnricherMojo.java | 26 +++++++++++++++++--- .../integration/EIPDocumentationMojoTest.java | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/c8b48821/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java index 21d8440..d549a39 100644 --- a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java +++ b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java @@ -47,7 +47,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; /** * Injects EIP documentation to camel schema. */ -@Mojo(name = "eip-documentation-enricher", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true, +@Mojo(name = "eip-documentation-enricher", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, defaultPhase = LifecyclePhase.PREPARE_PACKAGE) public class EipDocumentationEnricherMojo extends AbstractMojo { @@ -66,15 +66,27 @@ public class EipDocumentationEnricherMojo extends AbstractMojo { /** * Path to camel core project root directory. */ - @Parameter(defaultValue = "${project.build.directory}/../../..//camel-core") + @Parameter(defaultValue = "${project.build.directory}/../../../camel-core") public File camelCoreDir; /** + * Path to camel core project root directory. + */ + @Parameter(defaultValue = "${project.build.directory}/../../../components/camel-spring") + public File camelSpringDir; + + /** * Sub path from camel core directory to model directory with generated json files for components. */ @Parameter(defaultValue = "target/classes/org/apache/camel/model") public String pathToModelDir; + /** + * Sub path from camel spring directory to model directory with generated json files for components. + */ + @Parameter(defaultValue = "target/classes/org/apache/camel/spring") + public String pathToSpringModelDir; + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (pathToModelDir == null) { @@ -83,7 +95,9 @@ public class EipDocumentationEnricherMojo extends AbstractMojo { validateExists(inputCamelSchemaFile, "inputCamelSchemaFile"); validateIsFile(inputCamelSchemaFile, "inputCamelSchemaFile"); validateExists(camelCoreDir, "camelCoreDir"); + validateExists(camelSpringDir, "camelSpringDir"); validateIsDirectory(camelCoreDir, "camelCoreDir"); + validateIsDirectory(camelSpringDir, "camelSpringDir"); try { runPlugin(); } catch (Exception e) { @@ -92,12 +106,18 @@ public class EipDocumentationEnricherMojo extends AbstractMojo { } private void runPlugin() throws Exception { - File rootDir = new File(camelCoreDir, pathToModelDir); Document document = XmlHelper.buildNamespaceAwareDocument(inputCamelSchemaFile); XPath xPath = XmlHelper.buildXPath(new CamelSpringNamespace()); DomFinder domFinder = new DomFinder(document, xPath); DocumentationEnricher documentationEnricher = new DocumentationEnricher(document); + + // include schema files from camel-core, and from camel-spring + File rootDir = new File(camelCoreDir, pathToModelDir); Map<String, File> jsonFiles = PackageHelper.findJsonFiles(rootDir); + File rootDir2 = new File(camelSpringDir, pathToSpringModelDir); + Map<String, File> jsonFiles2 = PackageHelper.findJsonFiles(rootDir2); + // merge the json files together + jsonFiles.putAll(jsonFiles2); NodeList elementsAndTypes = domFinder.findElementsAndTypes(); documentationEnricher.enrichTopLevelElementsDocumentation(elementsAndTypes, jsonFiles); http://git-wip-us.apache.org/repos/asf/camel/blob/c8b48821/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/test/java/org/apache/camel/maven/integration/EIPDocumentationMojoTest.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/test/java/org/apache/camel/maven/integration/EIPDocumentationMojoTest.java b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/test/java/org/apache/camel/maven/integration/EIPDocumentationMojoTest.java index efe20f7..ec837f7 100644 --- a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/test/java/org/apache/camel/maven/integration/EIPDocumentationMojoTest.java +++ b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/test/java/org/apache/camel/maven/integration/EIPDocumentationMojoTest.java @@ -49,8 +49,10 @@ public class EIPDocumentationMojoTest { @Before public void setUp() throws Exception { eipDocumentationEnricherMojo.camelCoreDir = ResourceUtils.getResourceAsFile("integration/camel-core-integration"); + eipDocumentationEnricherMojo.camelSpringDir = ResourceUtils.getResourceAsFile("integration/camel-core-integration"); eipDocumentationEnricherMojo.inputCamelSchemaFile = ResourceUtils.getResourceAsFile("integration/camel-spring.xsd"); eipDocumentationEnricherMojo.pathToModelDir = "trgt/classes/org/apache/camel/model"; + eipDocumentationEnricherMojo.pathToSpringModelDir = "trgt/classes/org/apache/camel/model"; xPath.setNamespaceContext(new CamelSpringNamespace()); tempFile = File.createTempFile("outputXml", ".xml"); tempFile.deleteOnExit();