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/15 10:42:28 UTC

[camel] branch master updated (8bc6f17 -> f3c62a8)

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

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


    from 8bc6f17  Upgrade Spring Security to version 5.1.3.RELEASE
     new 734548c  CAMEL-13055: Polished and optimized the camelpackage-maven-plugin
     new f3c62a8  CAMEL-13055: generate legal can be done a bit later in the maven lifecycle.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 camel-core/pom.xml                                 |  5 +-
 components/pom.xml                                 |  9 +-
 .../maven/packaging/PackageComponentMojo.java      | 16 ++--
 .../maven/packaging/PackageDataFormatMojo.java     | 22 +++--
 .../camel/maven/packaging/PackageHelper.java       |  2 +-
 .../camel/maven/packaging/PackageLanguageMojo.java | 20 +++--
 .../camel/maven/packaging/PackageLegalMojo.java    | 98 +++++++---------------
 .../camel/maven/packaging/PackageOtherMojo.java    | 28 +++----
 .../maven/packaging/PrepareComponentMojo.java      | 12 ++-
 9 files changed, 95 insertions(+), 117 deletions(-)


[camel] 02/02: CAMEL-13055: generate legal can be done a bit later in the maven lifecycle.

Posted by da...@apache.org.
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

commit f3c62a82400184f36ed1dbb0de5c358bf9605171
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 15 11:14:51 2019 +0100

    CAMEL-13055: generate legal can be done a bit later in the maven lifecycle.
---
 camel-core/pom.xml                                 |  5 +-
 components/pom.xml                                 |  9 +--
 .../camel/maven/packaging/PackageLegalMojo.java    | 93 ++++++----------------
 3 files changed, 29 insertions(+), 78 deletions(-)

diff --git a/camel-core/pom.xml b/camel-core/pom.xml
index 9eae541..1da0224 100644
--- a/camel-core/pom.xml
+++ b/camel-core/pom.xml
@@ -438,7 +438,6 @@
               <goal>generate-components-list</goal>
               <goal>generate-dataformats-list</goal>
               <goal>generate-languages-list</goal>
-              <goal>generate-legal</goal>
             </goals>
             <phase>process-classes</phase>
           </execution>
@@ -448,6 +447,7 @@
               <goal>validate-components</goal>
               <goal>prepare-spring-boot-starter</goal>
               <goal>prepare-spring-boot-auto-configuration</goal>
+              <goal>generate-legal</goal>
             </goals>
             <phase>prepare-package</phase>
           </execution>
@@ -486,9 +486,6 @@
                 <resource>
                   <directory>${basedir}/target/generated/camel/jaxb</directory>
                 </resource>
-                <resource>
-                  <directory>${basedir}/target/generated/camel/legal</directory>
-                </resource>
               </resources>
             </configuration>
           </execution>
diff --git a/components/pom.xml b/components/pom.xml
index c255ba7..09646c3 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -313,8 +313,7 @@
           <execution>
             <id>generate</id>
             <goals>
-              <goal>prepare-components</goal>
-              <goal>generate-legal</goal>
+              <goal>prepare-components</goal>             
             </goals>
             <phase>process-classes</phase>
           </execution>
@@ -324,13 +323,14 @@
               <goal>validate-components</goal>
               <goal>prepare-spring-boot-starter</goal>
               <goal>prepare-spring-boot-auto-configuration</goal>
+              <goal>generate-legal</goal>
             </goals>
             <phase>prepare-package</phase>
           </execution>
           <execution>
             <id>readme</id>
             <goals>
-              <goal>update-readme</goal>
+              <goal>update-readme</goal>             
             </goals>
             <phase>package</phase>
           </execution>
@@ -359,9 +359,6 @@
                 <resource>
                   <directory>${basedir}/target/generated/camel/others</directory>
                 </resource>
-                <resource>
-                  <directory>${basedir}/target/generated/camel/legal</directory>
-                </resource>
               </resources>
             </configuration>
           </execution>
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
index 917d180..5cb3713 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
@@ -17,19 +17,14 @@
 package org.apache.camel.maven.packaging;
 
 import java.io.File;
-import java.io.IOError;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collections;
-import java.util.Objects;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -39,12 +34,11 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
-import org.sonatype.plexus.build.incremental.BuildContext;
 
 /**
  * Analyses the Camel plugins in a project and generates legal files.
  */
-@Mojo(name = "generate-legal", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES)
+@Mojo(name = "generate-legal", threadSafe = true, defaultPhase = LifecyclePhase.PREPARE_PACKAGE)
 public class PackageLegalMojo extends AbstractMojo {
 
     /**
@@ -56,7 +50,7 @@ public class PackageLegalMojo extends AbstractMojo {
     /**
      * The output directory for generated components file
      */
-    @Parameter(defaultValue = "${project.build.directory}/generated/camel/legal")
+    @Parameter(defaultValue = "${project.build.directory}/classes")
     protected File legalOutDir;
 
     /**
@@ -66,13 +60,6 @@ public class PackageLegalMojo extends AbstractMojo {
     private MavenProjectHelper projectHelper;
 
     /**
-     * build context to check changed files and mark them for refresh (used for
-     * m2e compatibility)
-     */
-    @Component
-    private BuildContext buildContext;
-
-    /**
      * Execute goal.
      *
      * @throws MojoExecutionException execution of the main class or one of the
@@ -81,8 +68,6 @@ public class PackageLegalMojo extends AbstractMojo {
      */
     public void execute() throws MojoExecutionException, MojoFailureException {
         processLegal(legalOutDir.toPath());
-
-        projectHelper.addResource(project, legalOutDir.getPath(), Collections.singletonList("**/*"), Collections.emptyList());
     }
 
     public void processLegal(Path legalOutDir) throws MojoExecutionException {
@@ -91,62 +76,34 @@ public class PackageLegalMojo extends AbstractMojo {
             return;
         }
 
-        boolean hasLicense = project.getResources().stream()
-                .map(Resource::getDirectory)
-                .map(Paths::get)
-                .map(p -> p.resolve("META-INF").resolve("LICENSE.txt"))
-                .anyMatch(Files::isRegularFile);
-        if (!hasLicense) {
-            try (InputStream isLicense = getClass().getResourceAsStream("/camel-LICENSE.txt")) {
-                String license = IOUtils.toString(isLicense, StandardCharsets.UTF_8);
-                updateResource(legalOutDir.resolve("META-INF").resolve("LICENSE.txt"), license);
-            } catch (IOException e) {
-                throw new MojoExecutionException("Failed to write legal files. Reason: " + e, e);
-            }
-        }
-        boolean hasNotice = project.getResources().stream()
-                .map(Resource::getDirectory)
-                .map(Paths::get)
-                .map(p -> p.resolve("META-INF").resolve("NOTICE.txt"))
-                .anyMatch(Files::isRegularFile);
-        if (!hasNotice) {
-            try (InputStream isNotice = getClass().getResourceAsStream("/camel-NOTICE.txt")) {
-                String notice = IOUtils.toString(isNotice, StandardCharsets.UTF_8);
-                updateResource(legalOutDir.resolve("META-INF").resolve("NOTICE.txt"), notice);
-            } catch (IOException e) {
-                throw new MojoExecutionException("Failed to write legal files. Reason: " + e, e);
-            }
+        try (InputStream isLicense = getClass().getResourceAsStream("/camel-LICENSE.txt")) {
+            String license = IOUtils.toString(isLicense, StandardCharsets.UTF_8);
+            updateResource(legalOutDir.resolve("META-INF").resolve("LICENSE.txt"), license);
+        } catch (IOException e) {
+            throw new MojoExecutionException("Failed to write legal files. Reason: " + e, e);
         }
-    }
-
-    protected void updateResource(Path out, String data) {
-        try {
-            if (data == null) {
-                if (Files.isRegularFile(out)) {
-                    Files.delete(out);
-                    refresh(out);
-                }
-            } else {
-                if (Files.isRegularFile(out) && Files.isReadable(out)) {
-                    String content = new String(Files.readAllBytes(out), StandardCharsets.UTF_8);
-                    if (Objects.equals(content, data)) {
-                        return;
-                    }
-                }
-                Files.createDirectories(out.getParent());
-                try (Writer w = Files.newBufferedWriter(out, StandardCharsets.UTF_8)) {
-                    w.append(data);
-                }
-                refresh(out);
-            }
+        try (InputStream isNotice = getClass().getResourceAsStream("/camel-NOTICE.txt")) {
+            String notice = IOUtils.toString(isNotice, StandardCharsets.UTF_8);
+            updateResource(legalOutDir.resolve("META-INF").resolve("NOTICE.txt"), notice);
         } catch (IOException e) {
-            throw new IOError(e);
+            throw new MojoExecutionException("Failed to write legal files. Reason: " + e, e);
         }
     }
 
-    protected void refresh(Path file) {
-        if (buildContext != null) {
-            buildContext.refresh(file.toFile());
+    protected void updateResource(Path out, String data) throws IOException {
+        if (Files.isRegularFile(out)) {
+            // file already exists
+            return;
+        }
+        if (data == null) {
+            if (Files.isRegularFile(out)) {
+                Files.delete(out);
+            }
+        } else {
+            Files.createDirectories(out.getParent());
+            try (Writer w = Files.newBufferedWriter(out, StandardCharsets.UTF_8)) {
+                w.append(data);
+            }
         }
     }
 


[camel] 01/02: CAMEL-13055: Polished and optimized the camelpackage-maven-plugin

Posted by da...@apache.org.
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

commit 734548c40bc9f86cd9ca19feea3c84f2a75dd277
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 15 10:53:53 2019 +0100

    CAMEL-13055: Polished and optimized the camelpackage-maven-plugin
---
 .../maven/packaging/PackageComponentMojo.java      | 16 +++++++++----
 .../maven/packaging/PackageDataFormatMojo.java     | 22 ++++++++++++-----
 .../camel/maven/packaging/PackageHelper.java       |  2 +-
 .../camel/maven/packaging/PackageLanguageMojo.java | 20 +++++++++++-----
 .../camel/maven/packaging/PackageLegalMojo.java    |  9 +++----
 .../camel/maven/packaging/PackageOtherMojo.java    | 28 ++++++++++------------
 .../maven/packaging/PrepareComponentMojo.java      | 12 ++++++----
 7 files changed, 68 insertions(+), 41 deletions(-)

diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
index 3e6a398..de29a45 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageComponentMojo.java
@@ -90,7 +90,7 @@ public class PackageComponentMojo extends AbstractMojo {
         prepareComponent(getLog(), project, projectHelper, buildDir, componentOutDir, buildContext);
     }
 
-    public static void prepareComponent(Log log, MavenProject project, MavenProjectHelper projectHelper, File buildDir, File componentOutDir, BuildContext buildContext) throws MojoExecutionException {
+    public static int prepareComponent(Log log, MavenProject project, MavenProjectHelper projectHelper, File buildDir, File componentOutDir, BuildContext buildContext) throws MojoExecutionException {
 
         File camelMetaDir = new File(componentOutDir, "META-INF/services/org/apache/camel/");
 
@@ -101,7 +101,7 @@ public class PackageComponentMojo extends AbstractMojo {
         }
 
         if (!PackageHelper.haveResourcesChanged(log, project, buildContext, "META-INF/services/org/apache/camel/component")) {
-            return;
+            return 0;
         }
 
         StringBuilder buffer = new StringBuilder();
@@ -145,8 +145,10 @@ public class PackageComponentMojo extends AbstractMojo {
             }
         }
 
-        // we need to enrich the component json files with data we know have from this plugin
-        enrichComponentJsonFiles(log, project, buildDir, components);
+        if (count > 0) {
+            // we need to enrich the component json files with data we know have from this plugin
+            enrichComponentJsonFiles(log, project, buildDir, components);
+        }
 
         if (count > 0) {
             Properties properties = new Properties();
@@ -176,7 +178,7 @@ public class PackageComponentMojo extends AbstractMojo {
                     // are the content the same?
                     if (existing.equals(properties)) {
                         log.debug("No component changes detected");
-                        return;
+                        return count;
                     }
                 } catch (IOException e) {
                     // ignore
@@ -190,12 +192,16 @@ public class PackageComponentMojo extends AbstractMojo {
 
                 log.info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "components: " : "component: ") + names);
 
+                buildContext.refresh(outFile);
+
             } catch (IOException e) {
                 throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
             }
         } else {
             log.debug("No META-INF/services/org/apache/camel/component directory found. Are you sure you have created a Camel component?");
         }
+
+        return count;
     }
 
     private static void enrichComponentJsonFiles(Log log, MavenProject project, File buildDir, Map<String, String> components) throws MojoExecutionException {
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 d7f2361..afbd13b 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
@@ -31,7 +31,6 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -95,7 +94,7 @@ public class PackageDataFormatMojo extends AbstractMojo {
         prepareDataFormat(getLog(), project, projectHelper, dataFormatOutDir, schemaOutDir, buildContext);
     }
 
-    public static void prepareDataFormat(Log log, MavenProject project, MavenProjectHelper projectHelper, File dataFormatOutDir,
+    public static int prepareDataFormat(Log log, MavenProject project, MavenProjectHelper projectHelper, File dataFormatOutDir,
                                          File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
 
         File camelMetaDir = new File(dataFormatOutDir, "META-INF/services/org/apache/camel/");
@@ -107,7 +106,7 @@ public class PackageDataFormatMojo extends AbstractMojo {
         }
 
         if (!PackageHelper.haveResourcesChanged(log, project, buildContext, "META-INF/services/org/apache/camel/dataformat")) {
-            return;
+            return 0;
         }
 
         Map<String, String> javaTypes = new HashMap<>();
@@ -161,7 +160,9 @@ public class PackageDataFormatMojo extends AbstractMojo {
                                 String json = loadText(is);
 
                                 DataFormatModel dataFormatModel = extractDataFormatModel(project, json, modelName, name, javaType);
-                                log.debug("Model " + dataFormatModel);
+                                if (log.isDebugEnabled()) {
+                                    log.debug("Model: " + dataFormatModel);
+                                }
 
                                 // build json schema for the data format
                                 String properties = after(json, "  \"properties\": {");
@@ -171,7 +172,9 @@ public class PackageDataFormatMojo extends AbstractMojo {
                                 properties = prepareJsonProperties(name, properties);
 
                                 String schema = createParameterJsonSchema(dataFormatModel, properties);
-                                log.debug("JSon schema\n" + schema);
+                                if (log.isDebugEnabled()) {
+                                    log.debug("JSon schema:\n" + schema);
+                                }
 
                                 // write this to the directory
                                 File dir = new File(schemaOutDir, schemaSubDirectory(dataFormatModel.getJavaType()));
@@ -181,6 +184,9 @@ public class PackageDataFormatMojo extends AbstractMojo {
                                 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");
                                 }
@@ -221,7 +227,7 @@ public class PackageDataFormatMojo extends AbstractMojo {
                     // are the content the same?
                     if (existing.equals(properties)) {
                         log.debug("No dataformat changes detected");
-                        return;
+                        return count;
                     }
                 } catch (IOException e) {
                     // ignore
@@ -235,12 +241,16 @@ public class PackageDataFormatMojo extends AbstractMojo {
 
                 log.info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "dataformats: " : "dataformat: ") + names);
 
+                buildContext.refresh(outFile);
+
             } catch (IOException e) {
                 throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
             }
         } else {
             log.debug("No META-INF/services/org/apache/camel/dataformat directory found. Are you sure you have created a Camel data format?");
         }
+
+        return count;
     }
 
     private static DataFormatModel extractDataFormatModel(MavenProject project, String json, String modelName, String name, String javaType) throws Exception {
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 4bdc8f7..e342db6 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
@@ -48,7 +48,7 @@ public final class PackageHelper {
             }
             String path = file.getPath() + "/" + suffix;
             if (log.isDebugEnabled()) {
-                log.debug("checking  if " + path + " (" + r.getDirectory() + "/" + suffix + ") has changed.");
+                log.debug("Checking  if " + path + " (" + r.getDirectory() + "/" + suffix + ") has changed.");
             }
             if (buildContext.hasDelta(path)) {
                 log.debug("Indeed " + suffix + " has changed.");
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 2e80c8c..4aca430 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
@@ -31,7 +31,6 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -95,7 +94,7 @@ public class PackageLanguageMojo extends AbstractMojo {
         prepareLanguage(getLog(), project, projectHelper, languageOutDir, schemaOutDir, buildContext);
     }
 
-    public static void prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper, File languageOutDir,
+    public static int prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper, File languageOutDir,
                                        File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
 
         File camelMetaDir = new File(languageOutDir, "META-INF/services/org/apache/camel/");
@@ -107,7 +106,7 @@ public class PackageLanguageMojo extends AbstractMojo {
         }
 
         if (!PackageHelper.haveResourcesChanged(log, project, buildContext, "META-INF/services/org/apache/camel/language")) {
-            return;
+            return 0;
         }
 
         Map<String, String> javaTypes = new HashMap<>();
@@ -201,12 +200,16 @@ public class PackageLanguageMojo extends AbstractMojo {
                                         languageModel.setFirstVersion(row.get("firstVersion"));
                                     }
                                 }
-                                log.debug("Model " + languageModel);
+                                if (log.isDebugEnabled()) {
+                                    log.debug("Model: " + languageModel);
+                                }
 
                                 // build json schema for the data format
                                 String properties = after(json, "  \"properties\": {");
                                 String schema = createParameterJsonSchema(languageModel, properties);
-                                log.debug("JSon schema\n" + schema);
+                                if (log.isDebugEnabled()) {
+                                    log.debug("JSon schema\n" + schema);
+                                }
 
                                 // write this to the directory
                                 File dir = new File(schemaOutDir, schemaSubDirectory(languageModel.getJavaType()));
@@ -218,6 +221,7 @@ public class PackageLanguageMojo extends AbstractMojo {
                                 fos.close();
 
                                 buildContext.refresh(out);
+
                                 if (log.isDebugEnabled()) {
                                     log.debug("Generated " + out + " containing JSon schema for " + name + " language");
                                 }
@@ -258,7 +262,7 @@ public class PackageLanguageMojo extends AbstractMojo {
                     // are the content the same?
                     if (existing.equals(properties)) {
                         log.debug("No language changes detected");
-                        return;
+                        return count;
                     }
                 } catch (IOException e) {
                     // ignore
@@ -272,12 +276,16 @@ public class PackageLanguageMojo extends AbstractMojo {
 
                 log.info("Generated " + outFile + " containing " + count + " Camel " + (count > 1 ? "languages: " : "language: ") + names);
 
+                buildContext.refresh(outFile);
+
             } catch (IOException e) {
                 throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
             }
         } else {
             log.debug("No META-INF/services/org/apache/camel/language directory found. Are you sure you have created a Camel language?");
         }
+
+        return count;
     }
 
     private static String readClassFromCamelResource(File file, StringBuilder buffer, BuildContext buildContext) throws MojoExecutionException {
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
index 565cb70..917d180 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageLegalMojo.java
@@ -42,7 +42,7 @@ import org.apache.maven.project.MavenProjectHelper;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 /**
- * Analyses the Camel plugins in a project and generates extra descriptor information for easier auto-discovery in Camel.
+ * Analyses the Camel plugins in a project and generates legal files.
  */
 @Mojo(name = "generate-legal", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES)
 public class PackageLegalMojo extends AbstractMojo {
@@ -85,11 +85,12 @@ public class PackageLegalMojo extends AbstractMojo {
         projectHelper.addResource(project, legalOutDir.getPath(), Collections.singletonList("**/*"), Collections.emptyList());
     }
 
-    public void processLegal(Path legalOutDir) {
+    public void processLegal(Path legalOutDir) throws MojoExecutionException {
         // Only take care about camel legal stuff
         if (!"org.apache.camel".equals(project.getGroupId())) {
             return;
         }
+
         boolean hasLicense = project.getResources().stream()
                 .map(Resource::getDirectory)
                 .map(Paths::get)
@@ -100,7 +101,7 @@ public class PackageLegalMojo extends AbstractMojo {
                 String license = IOUtils.toString(isLicense, StandardCharsets.UTF_8);
                 updateResource(legalOutDir.resolve("META-INF").resolve("LICENSE.txt"), license);
             } catch (IOException e) {
-                throw new IOError(e);
+                throw new MojoExecutionException("Failed to write legal files. Reason: " + e, e);
             }
         }
         boolean hasNotice = project.getResources().stream()
@@ -113,7 +114,7 @@ public class PackageLegalMojo extends AbstractMojo {
                 String notice = IOUtils.toString(isNotice, StandardCharsets.UTF_8);
                 updateResource(legalOutDir.resolve("META-INF").resolve("NOTICE.txt"), notice);
             } catch (IOException e) {
-                throw new IOError(e);
+                throw new MojoExecutionException("Failed to write legal files. Reason: " + e, e);
             }
         }
     }
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java
index e4cdaa6..8b18fc1 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageOtherMojo.java
@@ -83,12 +83,6 @@ public class PackageOtherMojo extends AbstractMojo {
      * @throws MojoFailureException something bad happened...
      */
     public void execute() throws MojoExecutionException, MojoFailureException {
-        prepareOthers(getLog(), project, projectHelper, otherOutDir, schemaOutDir, buildContext);
-    }
-
-    public static void prepareOthers(Log log, MavenProject project, MavenProjectHelper projectHelper, File otherOutDir,
-                                     File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
-
         File f = new File(project.getBasedir(), "target/classes");
         File comp = new File(f, "META-INF/services/org/apache/camel/component");
         if (comp.exists() && comp.isDirectory()) {
@@ -103,7 +97,11 @@ public class PackageOtherMojo extends AbstractMojo {
             return;
         }
 
-        // okay none of those then this is a other kind of artifact
+        prepareOthers(getLog(), project, projectHelper, otherOutDir, schemaOutDir, buildContext);
+    }
+
+    public static void prepareOthers(Log log, MavenProject project, MavenProjectHelper projectHelper, File otherOutDir,
+                                     File schemaOutDir, BuildContext buildContext) throws MojoExecutionException {
 
         // first we need to setup the output directory because the next check
         // can stop the build before the end and eclipse always needs to know about that directory
@@ -111,12 +109,6 @@ public class PackageOtherMojo extends AbstractMojo {
             projectHelper.addResource(project, otherOutDir.getPath(), Collections.singletonList("**/other.properties"), Collections.emptyList());
         }
 
-        if (!PackageHelper.haveResourcesChanged(log, project, buildContext, "META-INF/services/org/apache/camel/component")
-            && !PackageHelper.haveResourcesChanged(log, project, buildContext, "META-INF/services/org/apache/camel/dataformat")
-            && !PackageHelper.haveResourcesChanged(log, project, buildContext, "META-INF/services/org/apache/camel/language")) {
-            return;
-        }
-
         String name = project.getArtifactId();
         // strip leading camel-
         if (name.startsWith("camel-")) {
@@ -144,7 +136,9 @@ public class PackageOtherMojo extends AbstractMojo {
             }
             otherModel.setTitle(title);
 
-            log.debug("Model " + otherModel);
+            if (log.isDebugEnabled()) {
+                log.debug("Model: " + otherModel);
+            }
 
             // write this to the directory
             File dir = schemaOutDir;
@@ -158,7 +152,9 @@ public class PackageOtherMojo extends AbstractMojo {
 
             buildContext.refresh(out);
 
-            log.debug("Generated " + out + " containing JSon schema for " + name + " other");
+            if (log.isDebugEnabled()) {
+                log.debug("Generated " + out + " containing JSon schema for " + name + " other");
+            }
         } catch (Exception e) {
             throw new MojoExecutionException("Error loading other model. Reason: " + e, e);
         }
@@ -206,6 +202,8 @@ public class PackageOtherMojo extends AbstractMojo {
 
             log.info("Generated " + outFile);
 
+            buildContext.refresh(outFile);
+
         } catch (IOException e) {
             throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
         }
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java
index e0642f3..98f55cd 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareComponentMojo.java
@@ -115,10 +115,14 @@ public class PrepareComponentMojo extends AbstractMojo {
      * @throws org.apache.maven.plugin.MojoFailureException   something bad happened...
      */
     public void execute() throws MojoExecutionException, MojoFailureException {
-        prepareComponent(getLog(), project, projectHelper, buildDir, componentOutDir, buildContext);
-        prepareDataFormat(getLog(), project, projectHelper, dataFormatOutDir, schemaOutDir, buildContext);
-        prepareLanguage(getLog(), project, projectHelper, languageOutDir, schemaOutDir, buildContext);
-        prepareOthers(getLog(), project, projectHelper, otherOutDir, schemaOutDir, buildContext);
+        int count = 0;
+        count += prepareComponent(getLog(), project, projectHelper, buildDir, componentOutDir, buildContext);
+        count += prepareDataFormat(getLog(), project, projectHelper, dataFormatOutDir, schemaOutDir, buildContext);
+        count += prepareLanguage(getLog(), project, projectHelper, languageOutDir, schemaOutDir, buildContext);
+        if (count == 0) {
+            // okay its not any of the above then its other
+            prepareOthers(getLog(), project, projectHelper, otherOutDir, schemaOutDir, buildContext);
+        }
     }
 
 }