You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/01/28 09:38:49 UTC

[camel] branch master updated: CAMEL-13133: camel3 - build system - Packaging dataformat and language needs to include json metadata

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 1868465  CAMEL-13133: camel3 - build system - Packaging dataformat and language needs to include json metadata
1868465 is described below

commit 1868465ec02a4ab57fb064805d20eb992d644fac
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 28 10:38:30 2019 +0100

    CAMEL-13133: camel3 - build system - Packaging dataformat and language needs to include json metadata
---
 bom/camel-bom/pom.xml                              |  10 ++
 camel-core/readme.adoc                             |   2 +-
 components/readme.adoc                             |  74 +++++++-
 .../camel-spring-boot-dependencies/pom.xml         |  10 ++
 .../maven/packaging/PackageDataFormatMojo.java     | 118 ++++++------
 .../camel/maven/packaging/PackageHelper.java       |  17 ++
 .../camel/maven/packaging/PackageLanguageMojo.java | 200 ++++++++++-----------
 7 files changed, 261 insertions(+), 170 deletions(-)

diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index 156044d..c083cad 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -2800,6 +2800,16 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-xslt</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-xslt-starter</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-xstream</artifactId>
         <version>${project.version}</version>
       </dependency>
diff --git a/camel-core/readme.adoc b/camel-core/readme.adoc
index a402aa4..fbba290 100644
--- a/camel-core/readme.adoc
+++ b/camel-core/readme.adoc
@@ -47,7 +47,7 @@ Number of Components: 7 in 1 JAR artifacts (0 deprecated)
 
 
 // dataformats: START
-Number of Data Formats: 4 in 7 JAR artifacts (0 deprecated)
+Number of Data Formats: 4 in 35 JAR artifacts (0 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
diff --git a/components/readme.adoc b/components/readme.adoc
index 0803b04..cf6adeb 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -881,33 +881,101 @@ Number of Components: 289 in 209 JAR artifacts (0 deprecated)
 ==== Data Formats
 
 // dataformats: START
-Number of Data Formats: 11 in 7 JAR artifacts (0 deprecated)
+Number of Data Formats: 45 in 35 JAR artifacts (0 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
 | Data Format | Available From | Description
 
+| link:camel-asn1/src/main/docs/asn1-dataformat.adoc[ASN.1 File] (camel-asn1) | 2.20 | The ASN.1 data format is used for file transfer with telecommunications protocols.
+
+| link:camel-avro/src/main/docs/avro-dataformat.adoc[Avro] (camel-avro) | 2.14 | The Avro data format is used for serialization and deserialization of messages using Apache Avro binary dataformat.
+
+| link:camel-barcode/src/main/docs/barcode-dataformat.adoc[Barcode] (camel-barcode) | 2.14 | The Barcode data format is used for creating barccode images (such as QR-Code)
+
+| link:camel-base64/src/main/docs/base64-dataformat.adoc[Base64] (camel-base64) | 2.11 | The Base64 data format is used for base64 encoding and decoding.
+
+| link:camel-beanio/src/main/docs/beanio-dataformat.adoc[BeanIO] (camel-beanio) | 2.10 | The BeanIO data format is used for working with flat payloads (such as CSV, delimited, or fixed length formats).
+
+| link:camel-bindy/src/main/docs/bindy-dataformat.adoc[Bindy CSV] (camel-bindy) | 2.0 | The Bindy data format is used for working with flat payloads (such as CSV, delimited, fixed length formats, or FIX messages).
+
+| link:camel-bindy/src/main/docs/bindy-dataformat.adoc[Bindy Fixed Length] (camel-bindy) | 2.0 | The Bindy data format is used for working with flat payloads (such as CSV, delimited, fixed length formats, or FIX messages).
+
+| link:camel-bindy/src/main/docs/bindy-dataformat.adoc[Bindy Key Value Pair] (camel-bindy) | 2.0 | The Bindy data format is used for working with flat payloads (such as CSV, delimited, fixed length formats, or FIX messages).
+
+| link:camel-boon/src/main/docs/boon-dataformat.adoc[Boon] (camel-boon) | 2.16 | Boon data format is used for unmarshal a JSon payload to POJO or to marshal POJO back to JSon payload.
+
+| link:camel-crypto/src/main/docs/crypto-dataformat.adoc[Crypto (Java Cryptographic Extension)] (camel-crypto) | 2.3 | Crypto data format is used for encrypting and decrypting of messages using Java Cryptographic Extension.
+
+| link:camel-csv/src/main/docs/csv-dataformat.adoc[CSV] (camel-csv) | 1.3 | The CSV data format is used for handling CSV payloads.
+
+| link:camel-fhir/camel-fhir-component/src/main/docs/fhirJson-dataformat.adoc[FHIR JSon] (camel-fhir) | 2.21 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON.
+
+| link:camel-fhir/camel-fhir-component/src/main/docs/fhirXml-dataformat.adoc[FHIR XML] (camel-fhir) | 2.21 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML.
+
 | link:camel-flatpack/src/main/docs/flatpack-dataformat.adoc[Flatpack] (camel-flatpack) | 2.1 | The Flatpack data format is used for working with flat payloads (such as CSV, delimited, or fixed length formats).
 
 | link:../camel-core/src/main/docs/gzip-dataformat.adoc[GZip] (camel-core) | 2.0 | The GZip data format is a message compression and de-compression format (which works with the popular gzip/gunzip tools).
 
 | link:camel-hl7/src/main/docs/hl7-dataformat.adoc[HL7] (camel-hl7) | 2.0 | The HL7 data format can be used to marshal or unmarshal HL7 (Health Care) model objects.
 
+| link:camel-ical/src/main/docs/ical-dataformat.adoc[iCal] (camel-ical) | 2.12 | The iCal dataformat is used for working with iCalendar messages.
+
+| link:camel-jacksonxml/src/main/docs/jacksonxml-dataformat.adoc[JacksonXML] (camel-jacksonxml) | 2.16 | JacksonXML data format is used for unmarshal a XML payload to POJO or to marshal POJO back to XML payload.
+
 | link:../camel-core/src/main/docs/serialization-dataformat.adoc[Java Object Serialization] (camel-core) | 2.12 | Serialization is a data format which uses the standard Java Serialization mechanism to unmarshal a binary payload into Java objects or to marshal Java objects into a binary blob.
 
 | link:camel-jaxb/src/main/docs/jaxb-dataformat.adoc[JAXB] (camel-jaxb) | 1.0 | JAXB data format uses the JAXB2 XML marshalling standard to unmarshal an XML payload into Java objects or to marshal Java objects into an XML payload.
 
+| link:camel-jibx/src/main/docs/jibx-dataformat.adoc[JiBX] (camel-jibx) | 2.6 | JiBX data format is used for unmarshal a XML payload to POJO or to marshal POJO back to XML payload.
+
+| link:camel-fastjson/src/main/docs/json-fastjson-dataformat.adoc[JSon Fastjson] (camel-fastjson) | 2.20 | JSon data format is used for unmarshal a JSon payload to POJO or to marshal POJO back to JSon payload.
+
+| link:camel-gson/src/main/docs/json-gson-dataformat.adoc[JSon GSon] (camel-gson) | 2.10 | JSon data format is used for unmarshal a JSon payload to POJO or to marshal POJO back to JSon payload.
+
+| link:camel-jackson/src/main/docs/json-jackson-dataformat.adoc[JSon Jackson] (camel-jackson) | 2.0 | JSon data format is used for unmarshal a JSon payload to POJO or to marshal POJO back to JSon payload.
+
+| link:camel-johnzon/src/main/docs/json-johnzon-dataformat.adoc[JSon Johnzon] (camel-johnzon) | 2.18 | JSon data format is used for unmarshal a JSon payload to POJO or to marshal POJO back to JSon payload.
+
 | link:camel-xstream/src/main/docs/json-xstream-dataformat.adoc[JSon XStream] (camel-xstream) | 2.0 | JSon data format is used for unmarshal a JSon payload to POJO or to marshal POJO back to JSon payload.
 
+| link:camel-lzf/src/main/docs/lzf-dataformat.adoc[LZF Deflate Compression] (camel-lzf) | 2.17 | The LZF data format is a message compression and de-compression format (uses the LZF deflate algorithm).
+
+| link:camel-mail/src/main/docs/mime-multipart-dataformat.adoc[MIME Multipart] (camel-mail) | 2.17 | The MIME Multipart data format can marshal a Camel message with attachments into a Camel message having a MIME-Multipart message as message body (and no attachments), and vise-versa when unmarshalling.
+
+| link:camel-crypto/src/main/docs/pgp-dataformat.adoc[PGP] (camel-crypto) | 2.9 | PGP data format is used for encrypting and decrypting of messages using Java Cryptographic Extension and PGP.
+
+| link:camel-protobuf/src/main/docs/protobuf-dataformat.adoc[Protobuf] (camel-protobuf) | 2.2 | The Protobuf data format is used for serializing between Java objects and the Google Protobuf protocol.
+
+| link:camel-rss/src/main/docs/rss-dataformat.adoc[RSS] (camel-rss) | 2.1 | RSS data format is used for working with RSS sync feed Java Objects and transforming to XML and vice-versa.
+
+| link:camel-soap/src/main/docs/soapjaxb-dataformat.adoc[SOAP] (camel-soap) | 2.3 | SOAP is a data format which uses JAXB2 and JAX-WS annotations to marshal and unmarshal SOAP payloads.
+
 | link:../camel-core/src/main/docs/string-dataformat.adoc[String Encoding] (camel-core) | 2.12 | String data format is a textual based format that supports character encoding.
 
+| link:camel-syslog/src/main/docs/syslog-dataformat.adoc[Syslog] (camel-syslog) | 2.6 | The Syslog dataformat is used for working with RFC3164 and RFC5424 messages (logging and monitoring).
+
 | link:camel-tarfile/src/main/docs/tarfile-dataformat.adoc[Tar File] (camel-tarfile) | 2.16 | The Tar File data format is a message compression and de-compression format of tar files.
 
+| link:camel-thrift/src/main/docs/thrift-dataformat.adoc[Thrift] (camel-thrift) | 2.20 | The Thrift data format is used for serialization and deserialization of messages using Apache Thrift binary dataformat.
+
+| link:camel-tagsoup/src/main/docs/tidyMarkup-dataformat.adoc[TidyMarkup] (camel-tagsoup) | 2.0 | TidyMarkup data format is used for parsing HTML and return it as pretty well-formed HTML.
+
+| link:camel-univocity-parsers/src/main/docs/univocity-csv-dataformat.adoc[uniVocity CSV] (camel-univocity-parsers) | 2.15 | The uniVocity CSV data format is used for working with CSV (Comma Separated Values) flat payloads.
+
+| link:camel-univocity-parsers/src/main/docs/univocity-fixed-dataformat.adoc[uniVocity Fixed Length] (camel-univocity-parsers) | 2.15 | The uniVocity Fixed Length data format is used for working with fixed length flat payloads.
+
+| link:camel-univocity-parsers/src/main/docs/univocity-tsv-dataformat.adoc[uniVocity TSV] (camel-univocity-parsers) | 2.15 | The uniVocity TSV data format is used for working with TSV (Tabular Separated Values) flat payloads.
+
 | link:camel-xmlsecurity/src/main/docs/secureXML-dataformat.adoc[XML Security] (camel-xmlsecurity) | 2.0 | The XML Security data format facilitates encryption and decryption of XML payloads.
 
 | link:camel-xstream/src/main/docs/xstream-dataformat.adoc[XStream] (camel-xstream) | 1.3 | XSTream data format is used for unmarshal a XML payload to POJO or to marshal POJO back to XML payload.
 
+| link:camel-snakeyaml/src/main/docs/yaml-snakeyaml-dataformat.adoc[YAML SnakeYAML] (camel-snakeyaml) | 2.17 | YAML is a data format to marshal and unmarshal Java objects to and from YAML.
+
 | link:../camel-core/src/main/docs/zip-dataformat.adoc[Zip Deflate Compression] (camel-core) | 2.12 | Zip Deflate Compression data format is a message compression and de-compression format (not zip files).
+
+| link:camel-zipfile/src/main/docs/zipfile-dataformat.adoc[Zip File] (camel-zipfile) | 2.11 | The Zip File data format is a message compression and de-compression format of zip files.
 |===
 // dataformats: END
 
@@ -915,7 +983,7 @@ Number of Data Formats: 11 in 7 JAR artifacts (0 deprecated)
 ==== Expression Languages
 
 // languages: START
-Number of Languages: 17 in 8 JAR artifacts (1 deprecated)
+Number of Languages: 18 in 9 JAR artifacts (1 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
@@ -929,6 +997,8 @@ Number of Languages: 17 in 8 JAR artifacts (1 deprecated)
 
 | link:../camel-core/src/main/docs/file-language.adoc[File] (camel-core) | 1.1 | For expressions and predicates using the file/simple language
 
+| link:camel-groovy/src/main/docs/groovy-language.adoc[Groovy] (camel-groovy) | 1.3 | To use Groovy scripts in Camel expressions or predicates.
+
 | link:../camel-core/src/main/docs/header-language.adoc[Header] (camel-core) | 1.5 | To use a Camel Message header in expressions or predicates.
 
 | link:camel-hl7/src/main/docs/terser-language.adoc[HL7 Terser] (camel-hl7) | 2.11 | To use HL7 terser scripts in Camel expressions or predicates.
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index 6205fdd..cffc6a3 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -3010,6 +3010,16 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-xslt</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-xslt-starter</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-xstream</artifactId>
         <version>${project.version}</version>
       </dependency>
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
index afbd13b..50c8ceb 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageDataFormatMojo.java
@@ -25,7 +25,6 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -43,6 +42,7 @@ import org.apache.maven.project.MavenProjectHelper;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 import static org.apache.camel.maven.packaging.PackageHelper.after;
+import static org.apache.camel.maven.packaging.PackageHelper.findCamelCoreDirectory;
 import static org.apache.camel.maven.packaging.PackageHelper.loadText;
 import static org.apache.camel.maven.packaging.PackageHelper.parseAsMap;
 
@@ -139,60 +139,59 @@ public class PackageDataFormatMojo extends AbstractMojo {
         // and create json schema model file for this data format
         try {
             if (apacheCamel && count > 0) {
-                Artifact camelCore = findCamelCoreArtifact(project);
-                if (camelCore != null) {
-                    File core = camelCore.getFile();
-                    if (core != null) {
-                        URL url = new URL("file", null, core.getAbsolutePath());
-                        try (URLClassLoader loader = new URLClassLoader(new URL[] {url})) {
-                            for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
-                                String name = entry.getKey();
-                                String javaType = entry.getValue();
-                                String modelName = asModelName(name);
-
-                                InputStream is = loader.getResourceAsStream("org/apache/camel/model/dataformat/" + modelName + ".json");
-                                if (is == null) {
-                                    // use file input stream if we build
-                                    // camel-core itself, and thus do not have a
-                                    // JAR which can be loaded by URLClassLoader
-                                    is = new FileInputStream(new File(core, "org/apache/camel/model/dataformat/" + modelName + ".json"));
-                                }
-                                String json = loadText(is);
-
-                                DataFormatModel dataFormatModel = extractDataFormatModel(project, json, modelName, name, javaType);
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Model: " + dataFormatModel);
-                                }
-
-                                // build json schema for the data format
-                                String properties = after(json, "  \"properties\": {");
-
-                                // special prepare for bindy/json properties
-                                properties = prepareBindyProperties(name, properties);
-                                properties = prepareJsonProperties(name, properties);
-
-                                String schema = createParameterJsonSchema(dataFormatModel, properties);
-                                if (log.isDebugEnabled()) {
-                                    log.debug("JSon schema:\n" + schema);
-                                }
-
-                                // write this to the directory
-                                File dir = new File(schemaOutDir, schemaSubDirectory(dataFormatModel.getJavaType()));
-                                dir.mkdirs();
-
-                                File out = new File(dir, name + ".json");
-                                OutputStream fos = buildContext.newFileOutputStream(out);
-                                fos.write(schema.getBytes());
-                                fos.close();
-
-                                buildContext.refresh(out);
-
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Generated " + out + " containing JSon schema for " + name + " data format");
-                                }
+                File core = findCamelCoreJar(project);
+                if (core != null) {
+                    URL url = new URL("file", null, core.getAbsolutePath());
+                    try (URLClassLoader loader = new URLClassLoader(new URL[] {url})) {
+                        for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
+                            String name = entry.getKey();
+                            String javaType = entry.getValue();
+                            String modelName = asModelName(name);
+
+                            InputStream is = loader.getResourceAsStream("org/apache/camel/model/dataformat/" + modelName + ".json");
+                            if (is == null) {
+                                // use file input stream if we build
+                                // camel-core itself, and thus do not have a
+                                // JAR which can be loaded by URLClassLoader
+                                is = new FileInputStream(new File(core, "org/apache/camel/model/dataformat/" + modelName + ".json"));
+                            }
+                            String json = loadText(is);
+
+                            DataFormatModel dataFormatModel = extractDataFormatModel(project, json, modelName, name, javaType);
+                            if (log.isDebugEnabled()) {
+                                log.debug("Model: " + dataFormatModel);
+                            }
+
+                            // build json schema for the data format
+                            String properties = after(json, "  \"properties\": {");
+
+                            // special prepare for bindy/json properties
+                            properties = prepareBindyProperties(name, properties);
+                            properties = prepareJsonProperties(name, properties);
+
+                            String schema = createParameterJsonSchema(dataFormatModel, properties);
+                            if (log.isDebugEnabled()) {
+                                log.debug("JSon schema:\n" + schema);
+                            }
+
+                            // write this to the directory
+                            File dir = new File(schemaOutDir, schemaSubDirectory(dataFormatModel.getJavaType()));
+                            dir.mkdirs();
+
+                            File out = new File(dir, name + ".json");
+                            OutputStream fos = buildContext.newFileOutputStream(out);
+                            fos.write(schema.getBytes());
+                            fos.close();
+
+                            buildContext.refresh(out);
+
+                            if (log.isDebugEnabled()) {
+                                log.debug("Generated " + out + " containing JSon schema for " + name + " data format");
                             }
                         }
                     }
+                } else {
+                    throw new MojoExecutionException("Error finding camel-core/target/camel-core-" + project.getVersion() + ".jar file. Make sure camel-core has been built first.");
                 }
             }
         } catch (Exception e) {
@@ -427,22 +426,15 @@ public class PackageDataFormatMojo extends AbstractMojo {
         return title;
     }
 
-    private static Artifact findCamelCoreArtifact(MavenProject project) {
+    private static File findCamelCoreJar(MavenProject project) {
         // maybe this project is camel-core itself
         Artifact artifact = project.getArtifact();
         if (artifact.getGroupId().equals("org.apache.camel") && artifact.getArtifactId().equals("camel-core")) {
-            return artifact;
+            return artifact.getFile();
         }
 
-        // or its a component which has a dependency to camel-core
-        Iterator<?> it = project.getDependencyArtifacts().iterator();
-        while (it.hasNext()) {
-            artifact = (Artifact) it.next();
-            if (artifact.getGroupId().equals("org.apache.camel") && artifact.getArtifactId().equals("camel-core")) {
-                return artifact;
-            }
-        }
-        return null;
+        // okay we are a custom dataformat so we need to find camel-core by walking down the folders
+        return findCamelCoreDirectory(project, project.getBasedir());
     }
 
     private static String schemaSubDirectory(String javaType) {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
index e342db6..8134f49 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageHelper.java
@@ -184,4 +184,21 @@ public final class PackageHelper {
         }
     }
 
+    public static File findCamelCoreDirectory(MavenProject project, File dir) {
+        if (dir == null) {
+            return null;
+        }
+        File[] files = dir.listFiles(f -> f.getName().equals("camel-core"));
+        if (files != null && files.length == 1) {
+            // okay the file are in the target folder
+            File target = new File(files[0], "target");
+            String version = project.getVersion();
+            return new File(target, "camel-core-" + version + ".jar");
+        } else {
+            // okay walk up the parent dir
+            return findCamelCoreDirectory(project, dir.getParentFile());
+        }
+    }
+
+
 }
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
index 4aca430..3790f1c 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLanguageMojo.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,6 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -43,6 +42,7 @@ import org.apache.maven.project.MavenProjectHelper;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 import static org.apache.camel.maven.packaging.PackageHelper.after;
+import static org.apache.camel.maven.packaging.PackageHelper.findCamelCoreDirectory;
 import static org.apache.camel.maven.packaging.PackageHelper.loadText;
 import static org.apache.camel.maven.packaging.PackageHelper.parseAsMap;
 
@@ -95,7 +95,7 @@ public class PackageLanguageMojo extends AbstractMojo {
     }
 
     public static int prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper, File languageOutDir,
-                                       File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
+                                      File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
 
         File camelMetaDir = new File(languageOutDir, "META-INF/services/org/apache/camel/");
 
@@ -140,94 +140,93 @@ public class PackageLanguageMojo extends AbstractMojo {
         // and create json schema model file for this language
         try {
             if (apacheCamel && count > 0) {
-                Artifact camelCore = findCamelCoreArtifact(project);
-                if (camelCore != null) {
-                    File core = camelCore.getFile();
-                    if (core != null) {
-                        URL url = new URL("file", null, core.getAbsolutePath());
-                        try (URLClassLoader loader = new URLClassLoader(new URL[] {url})) {
-                            for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
-                                String name = entry.getKey();
-                                String javaType = entry.getValue();
-                                String modelName = asModelName(name);
-
-                                InputStream is = loader.getResourceAsStream("org/apache/camel/model/language/" + modelName + ".json");
-                                if (is == null) {
-                                    // use file input stream if we build
-                                    // camel-core itself, and thus do not have a
-                                    // JAR which can be loaded by URLClassLoader
-                                    is = new FileInputStream(new File(core, "org/apache/camel/model/language/" + modelName + ".json"));
+                File core = findCamelCoreJar(project);
+                if (core != null) {
+                    URL url = new URL("file", null, core.getAbsolutePath());
+                    try (URLClassLoader loader = new URLClassLoader(new URL[] {url})) {
+                        for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
+                            String name = entry.getKey();
+                            String javaType = entry.getValue();
+                            String modelName = asModelName(name);
+
+                            InputStream is = loader.getResourceAsStream("org/apache/camel/model/language/" + modelName + ".json");
+                            if (is == null) {
+                                // use file input stream if we build
+                                // camel-core itself, and thus do not have a
+                                // JAR which can be loaded by URLClassLoader
+                                is = new FileInputStream(new File(core, "org/apache/camel/model/language/" + modelName + ".json"));
+                            }
+                            String json = loadText(is);
+                            LanguageModel languageModel = new LanguageModel();
+                            languageModel.setName(name);
+                            languageModel.setTitle("");
+                            languageModel.setModelName(modelName);
+                            languageModel.setLabel("");
+                            languageModel.setDescription("");
+                            languageModel.setJavaType(javaType);
+                            languageModel.setGroupId(project.getGroupId());
+                            languageModel.setArtifactId(project.getArtifactId());
+                            languageModel.setVersion(project.getVersion());
+
+                            List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("model", json, false);
+                            for (Map<String, String> row : rows) {
+                                if (row.containsKey("title")) {
+                                    // title may be special for some
+                                    // languages
+                                    String title = asTitle(name, row.get("title"));
+                                    languageModel.setTitle(title);
                                 }
-                                String json = loadText(is);
-                                LanguageModel languageModel = new LanguageModel();
-                                languageModel.setName(name);
-                                languageModel.setTitle("");
-                                languageModel.setModelName(modelName);
-                                languageModel.setLabel("");
-                                languageModel.setDescription("");
-                                languageModel.setJavaType(javaType);
-                                languageModel.setGroupId(project.getGroupId());
-                                languageModel.setArtifactId(project.getArtifactId());
-                                languageModel.setVersion(project.getVersion());
-
-                                List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("model", json, false);
-                                for (Map<String, String> row : rows) {
-                                    if (row.containsKey("title")) {
-                                        // title may be special for some
-                                        // languages
-                                        String title = asTitle(name, row.get("title"));
-                                        languageModel.setTitle(title);
-                                    }
-                                    if (row.containsKey("description")) {
-                                        // description may be special for some
-                                        // languages
-                                        String desc = asDescription(name, row.get("description"));
-                                        languageModel.setDescription(desc);
-                                    }
-                                    if (row.containsKey("label")) {
-                                        languageModel.setLabel(row.get("label"));
-                                    }
-                                    if (row.containsKey("deprecated")) {
-                                        languageModel.setDeprecated(row.get("deprecated"));
-                                    }
-                                    if (row.containsKey("deprecationNote")) {
-                                        languageModel.setDeprecationNote(row.get("deprecationNote"));
-                                    }
-                                    if (row.containsKey("javaType")) {
-                                        languageModel.setModelJavaType(row.get("javaType"));
-                                    }
-                                    if (row.containsKey("firstVersion")) {
-                                        languageModel.setFirstVersion(row.get("firstVersion"));
-                                    }
+                                if (row.containsKey("description")) {
+                                    // description may be special for some
+                                    // languages
+                                    String desc = asDescription(name, row.get("description"));
+                                    languageModel.setDescription(desc);
                                 }
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Model: " + languageModel);
+                                if (row.containsKey("label")) {
+                                    languageModel.setLabel(row.get("label"));
                                 }
-
-                                // build json schema for the data format
-                                String properties = after(json, "  \"properties\": {");
-                                String schema = createParameterJsonSchema(languageModel, properties);
-                                if (log.isDebugEnabled()) {
-                                    log.debug("JSon schema\n" + schema);
+                                if (row.containsKey("deprecated")) {
+                                    languageModel.setDeprecated(row.get("deprecated"));
+                                }
+                                if (row.containsKey("deprecationNote")) {
+                                    languageModel.setDeprecationNote(row.get("deprecationNote"));
                                 }
+                                if (row.containsKey("javaType")) {
+                                    languageModel.setModelJavaType(row.get("javaType"));
+                                }
+                                if (row.containsKey("firstVersion")) {
+                                    languageModel.setFirstVersion(row.get("firstVersion"));
+                                }
+                            }
+                            if (log.isDebugEnabled()) {
+                                log.debug("Model: " + languageModel);
+                            }
 
-                                // write this to the directory
-                                File dir = new File(schemaOutDir, schemaSubDirectory(languageModel.getJavaType()));
-                                dir.mkdirs();
+                            // build json schema for the data format
+                            String properties = after(json, "  \"properties\": {");
+                            String schema = createParameterJsonSchema(languageModel, properties);
+                            if (log.isDebugEnabled()) {
+                                log.debug("JSon schema\n" + schema);
+                            }
 
-                                File out = new File(dir, name + ".json");
-                                OutputStream fos = buildContext.newFileOutputStream(out);
-                                fos.write(schema.getBytes());
-                                fos.close();
+                            // write this to the directory
+                            File dir = new File(schemaOutDir, schemaSubDirectory(languageModel.getJavaType()));
+                            dir.mkdirs();
 
-                                buildContext.refresh(out);
+                            File out = new File(dir, name + ".json");
+                            OutputStream fos = buildContext.newFileOutputStream(out);
+                            fos.write(schema.getBytes());
+                            fos.close();
 
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Generated " + out + " containing JSon schema for " + name + " language");
-                                }
+                            buildContext.refresh(out);
+
+                            if (log.isDebugEnabled()) {
+                                log.debug("Generated " + out + " containing JSon schema for " + name + " language");
                             }
                         }
                     }
+                } else {
+                    throw new MojoExecutionException("Error finding camel-core/target/camel-core-" + project.getVersion() + ".jar file. Make sure camel-core has been built first.");
                 }
             }
         } catch (Exception e) {
@@ -345,22 +344,15 @@ public class PackageLanguageMojo extends AbstractMojo {
         return description;
     }
 
-    private static Artifact findCamelCoreArtifact(MavenProject project) {
+    private static File findCamelCoreJar(MavenProject project) {
         // maybe this project is camel-core itself
         Artifact artifact = project.getArtifact();
         if (artifact.getGroupId().equals("org.apache.camel") && artifact.getArtifactId().equals("camel-core")) {
-            return artifact;
+            return artifact.getFile();
         }
 
-        // or its a component which has a dependency to camel-core
-        Iterator<?> it = project.getDependencyArtifacts().iterator();
-        while (it.hasNext()) {
-            artifact = (Artifact) it.next();
-            if (artifact.getGroupId().equals("org.apache.camel") && artifact.getArtifactId().equals("camel-core")) {
-                return artifact;
-            }
-        }
-        return null;
+        // okay we are a custom dataformat so we need to find camel-core by walking down the folders
+        return findCamelCoreDirectory(project, project.getBasedir());
     }
 
     private static String schemaSubDirectory(String javaType) {
@@ -524,17 +516,17 @@ public class PackageLanguageMojo extends AbstractMojo {
         @Override
         public String toString() {
             return "LanguageModel["
-                    + "name='" + name + '\''
-                    + ", modelName='" + modelName + '\''
-                    + ", title='" + title + '\''
-                    + ", description='" + description + '\''
-                    + ", label='" + label + '\''
-                    + ", javaType='" + javaType + '\''
-                    + ", modelJavaType='" + modelJavaType + '\''
-                    + ", groupId='" + groupId + '\''
-                    + ", artifactId='" + artifactId + '\''
-                    + ", version='" + version + '\''
-                    + ']';
+                + "name='" + name + '\''
+                + ", modelName='" + modelName + '\''
+                + ", title='" + title + '\''
+                + ", description='" + description + '\''
+                + ", label='" + label + '\''
+                + ", javaType='" + javaType + '\''
+                + ", modelJavaType='" + modelJavaType + '\''
+                + ", groupId='" + groupId + '\''
+                + ", artifactId='" + artifactId + '\''
+                + ", version='" + version + '\''
+                + ']';
         }
     }