You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/06/07 10:01:27 UTC

[camel-k-runtime] branch master updated: catalog: generate license header

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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/master by this push:
     new 09d2014  catalog: generate license header
     new 7b0cbf3  Merge pull request #77 from lburgazzoli/catalog-license-camel-3
09d2014 is described below

commit 09d2014bb935fd7d53a0893eaab994d29d235d01
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri Jun 7 11:50:33 2019 +0200

    catalog: generate license header
---
 .../camel/k/tooling/maven/GenerateCatalogMojo.java | 10 +++++-
 .../camel/k/tooling/maven/GenerateSupport.java     | 38 ++++++++++++++++++++++
 .../src/main/resources/catalog-license.txt         | 17 ++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index 1b5a2ba..a37ff79 100644
--- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -17,6 +17,7 @@
 package org.apache.camel.k.tooling.maven;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
@@ -53,6 +54,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.utils.io.IOUtil;
 
 @Mojo(
     name = "generate-catalog",
@@ -145,7 +147,13 @@ public class GenerateCatalogMojo extends AbstractMojo {
                     .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
                     .configure(YAMLGenerator.Feature.WRITE_DOC_START_MARKER, false);
 
-                //new Yaml(representer, options).dump(cr, writer);
+
+                // write license header
+                writer.write(
+                    GenerateSupport.getResourceAsString("/catalog-license.txt")
+                );
+
+                // write catalog data
                 ObjectMapper mapper = new ObjectMapper(factory);
                 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                 mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateSupport.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateSupport.java
new file mode 100644
index 0000000..e1c2e10
--- /dev/null
+++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateSupport.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.k.tooling.maven;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.maven.shared.utils.io.IOUtil;
+
+public final class GenerateSupport {
+    private GenerateSupport() {
+    }
+
+    public static String getResourceAsString(String resource) throws IOException {
+        try (InputStream is = GenerateSupport.class.getResourceAsStream(resource)) {
+            if (is == null) {
+                throw new IllegalStateException("Unable to find catalog-license.txt");
+            }
+
+            return IOUtil.toString(is, StandardCharsets.UTF_8.name());
+        }
+    }
+}
diff --git a/camel-k-maven-plugin/src/main/resources/catalog-license.txt b/camel-k-maven-plugin/src/main/resources/catalog-license.txt
new file mode 100644
index 0000000..658e8dc
--- /dev/null
+++ b/camel-k-maven-plugin/src/main/resources/catalog-license.txt
@@ -0,0 +1,17 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# 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
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+